]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lsfd: fill ENDPOINTS column for UNIX one-way sockets
authorMasatake YAMATO <yamato@redhat.com>
Sun, 9 Mar 2025 21:54:04 +0000 (06:54 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 14 Mar 2025 21:25:27 +0000 (06:25 +0900)
commit4d123ede99fa527c586224f00fe7a4db8c52c43b
treeb62aac049e3eaf1a13a8ec7acc345f765ef75cb8
parentcafae2d19742ad56a05a51bb23b798dbbd5c62a8
lsfd: fill ENDPOINTS column for UNIX one-way sockets

With recvfrom(2) and sendto(2), we can use a UNIX datagram socket at
server side without assigning a peer address with connect(2). Here, I
call such sockets one-way sockets.

    # ss -x -p
    Netid State Recv-Q Send-Q        Local Address:Port  Peer Address:Port Process
    ...
    u_dgr ESTAB      0      0 /run/systemd/notify 13465               * 0  users:(("systemd",pid=1,fd=227))
    u_dgr ESTAB      0      0                   * 35438           * 13465  users:(("systemd-journal",pid=1280,fd=15))
    u_dgr ESTAB      0      0                   * 74792           * 13465  users:(("bluetoothd",pid=13874,fd=4))
    ...

The orignal code could not fill ENDPOINTS for UNIX one-way sockets:

  # ./original-lsfd -Q 'INODE == 13465' -oCOMMAND,PID,TYPE,INODE,NAME,ENDPOINTS
  COMMAND PID TYPE INODE NAME                                                ENDPOINTS
  systemd   1 UNIX 13465 state=connected path=/run/systemd/notify type=dgram

With this change, lsfd can fill the column:

  # ./new-lsfd -Q 'INODE == 13465' -oCOMMAND,PID,TYPE,INODE,NAME,ENDPOINTS
  COMMAND PID TYPE INODE NAME                                                ENDPOINTS
  systemd   1 UNIX 13465 state=connected path=/run/systemd/notify type=dgram 1280,systemd-journal,15rw
                                                                             13874,bluetoothd,4rw

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
lsfd-cmd/lsfd.1.adoc
lsfd-cmd/sock-xinfo.c
tests/expected/lsfd/mkfds-unix-dgram-ENDPOINTS-column
tests/ts/lsfd/mkfds-unix-dgram