Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sock_diag(7): Netlink support for AF_INET & IPPROTO_TCP #25

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

saminiir
Copy link
Owner

This PR introduces support for Netlink AF_INET/IPPROTO_TCP socket information gathering. See man sock_diag.

Useful with the ss tool (from iproute2):

$ ./tools/level-ip ss -n4t
State                             Recv-Q                          Send-Q                                                    Local Address:Port                                                      Peer Address:Port
TIME-WAIT                         0                               0                                                              10.0.0.4:43241                                                   216.58.211.142:80
TIME-WAIT                         0                               0                                                              10.0.0.4:42332                                                   216.58.211.142:80

This is enforced by e.g. the `ss` tool.
This is an error with clang, so avoid it.
This is the order Linux header uses, so let's switch to it.
This is more accurate than protocol, since e.g. SOCK_STREAM implies TCP
This change is introduced because suddenly CAP_NET_ADMIN
stopped working for my Arch Linux. In essence, doing

$ sudo setcap cap_net_admin=ep $(which ip)

Has no effect anymore:

$ ip link set dev tap0 up
RTNETLINK answers: Operation not permitted

Searching the Internet, one error case is if the directory is mounted
with `nosuid`, but this does not seem to be the case in my Linux.
Since iproute2 changed its capability handling, seems like it is
simpler to just guide the user to create the tap device itself.

This is also what Google's Netstack does.

iproute2/iproute2@9b13cc9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants