Page MenuHomeFreeBSD

sockstat(1): print out full connection graph for unix(4) sockets
ClosedPublic

Authored by glebius on Jul 6 2022, 9:21 AM.
Tags
None
Referenced Files
F111656294: D35726.id107874.diff
Thu, Mar 6, 2:42 PM
F111648053: D35726.diff
Thu, Mar 6, 12:01 PM
Unknown Object (File)
Mon, Mar 3, 3:12 AM
Unknown Object (File)
Sun, Feb 23, 4:28 PM
Unknown Object (File)
Jan 21 2025, 6:38 AM
Unknown Object (File)
Jan 5 2025, 11:44 PM
Unknown Object (File)
Dec 4 2024, 3:46 PM
Unknown Object (File)
Sep 28 2024, 10:18 AM
Subscribers

Details

Summary

Kernel provides us with enough information to display all possible
connections between UNIX sockets.

o Store unp_conn, xu_firstref and xu_nextref in the faddr of a UNIX sock.
o Build tree of file descriptors, indexed by the socket pointer.
o In displaysock() print out all possible information:

  1. if socket is bound, print name of this socket
  2. if socket has connected to a peer with a name, print peers name
  3. if socket has connected to a peer without a name, print [pid fd]
  4. if a bound socket has received connections, print list of them as [pid fd] Previously, only 1) either 2) were printed.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Example output lines:

glebius  pulseaudio  1843 32  stream /tmp/pulse-NlQ2RYGlYGh0/native -> [71518 116]
glebius  firefox    71518 116 stream -> /tmp/pulse-NlQ2RYGlYGh0/native
root     automountd  1477 3   dgram  -> /var/run/log
root     syslogd     1440 6   dgram  /var/run/log <- [1824 15],[1843 3],[1506 3],[1477 3],[1168 8]
unbound  local-unbo  1242 5   stream /var/run/local_unbound.ctl
unbound  local-unbo  1242 6   stream -> [1242 7]
glebius  sockstat   76162 6   stream -> [76155 8]
glebius  sockstat   76155 8   stream -> [76162 6]
This revision is now accepted and ready to land.Jul 6 2022, 9:52 AM
This revision now requires review to proceed.Jul 6 2022, 8:03 PM
This revision is now accepted and ready to land.Jul 6 2022, 8:21 PM