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

Implement SIOCGETSGCNT_IN6 ioctl #3615

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eqvinox
Copy link

@eqvinox eqvinox commented Sep 27, 2023

Unfortunately this isn't really done as-is since the ioctl value does not uniquely identify this ioctl. Some way to check the socket AF is needed to disambiguate :(


If someone with more experience in hacking on rr could take this off my hands that'd be much appreciated… I'm not sure I can dig through to implement figuring out the socket's AF

Unfortunately this isn't really done as-is since the ioctl value does
not uniquely identify this ioctl.  Some way to check the socket AF is
needed to disambiguate :(
@rocallahan
Copy link
Collaborator

If you extend this PR with testcases for IPv4 and IPv6, I can implement the socket-family tracking. Basically we're going to need a new subclass of FileMonitor, SocketMonitor, that carries the socket domain.

Another approach would be to get the inode number by reading /proc/<pid>/fdinfo/<fd> and then scan /proc/net/tcp(6) and /proc/net/udp(6) (and maybe more) for that inode number. SocketMonitor will be generally faster and cleaner (but can fail e.g. if the socket fd was delivered to the tracee over another socket, and the sender is not being recorded by rr).

@khuey
Copy link
Collaborator

khuey commented Oct 2, 2023

Attaching a FileMonitor subclass to every socket fd would be less than ideal because it would disable syscall buffering for them.

@rocallahan
Copy link
Collaborator

Attaching a FileMonitor subclass to every socket fd would be less than ideal because it would disable syscall buffering for them.

We could do something like FD_CLASS_PROC_MEM to fix that.

Another approach here might be to just ignore the socket family and treat everything as IPv6. Looks like that will mostly work since the IPv6 buffer is always longer than the IPv4 buffer and it's mostly OK to record more than we need. We would want to handle the case where the IPv4 buffer is at the end of a memory mapping so we can't record all of it.

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.

3 participants