Masatake YAMATO
120e5dbcac
Support unix domain sockets in -yy option
This change extends -yy option to handle unix domain sockets: their peer addresses will be printed, similar to inet sockets. For a listening socket, its socket inode and socket path are printed. For an accepted socket, its socket inode, the peer inode, and the socket path are printed. For a client socket, its socket inode and the peer inode are printed. An example of a server side communication using netcat: $ ./strace -yy -e network nc -l -U /tmp/example.sock socket(PF_LOCAL, SOCK_STREAM, 0) = 3 setsockopt(3<UNIX:[14728348]>, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(3<UNIX:[14728348]>, {sa_family=AF_LOCAL, sun_path="/tmp/example.sock"}, 19) = 0 listen(3<UNIX:[14728348,"/tmp/example.sock"]>, 10) = 0 accept(3<UNIX:[14728348,"/tmp/example.sock"]>, {sa_family=AF_LOCAL, NULL}, [2]) = 4<UNIX:[14727246->14727245,"/tmp/example.sock"]> recvfrom(4<UNIX:[14727246->14727245,"/tmp/example.sock"]>, "INPUT\n", 8192, 0, NULL, NULL) = 6 INPUT An example of a client side communication using netcat: $ ./strace -yy -e network nc -U /tmp/example.sock socket(PF_LOCAL, SOCK_STREAM, 0) = 3 connect(3<UNIX:[14727245]>, {sa_family=AF_LOCAL, sun_path="/tmp/example.sock"}, 19) = 0 getsockopt(3<UNIX:[14727245]>, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 INPUT ... sendto(3<UNIX:[14727245->14727246]>, "INPUT\n", 6, 0, NULL, 0) = 6 * linux/unix_diag.h: New file. * socketutils.c (send_query): Rename to inet_send_query. (parse_response): Rename to inet_parse_response. (unix_print, unix_send_query, unix_parse_response): New functions. (receive_responses): Add a new argument named parser: a function for handling protocol specific data parts of diag messages. (print_sockaddr_by_inode): Call unix_print. Replace NETLINK_INET_DIAG with NETLINK_SOCK_DIAG, they are equal but NETLINK_SOCK_DIAG looks more generic. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
This is strace, a system call tracer for Linux. strace is released under a Berkeley-style license at the request of Paul Kranenburg; see the file COPYING for details. See the file CREDITS for a list of authors and other contributors. See the file INSTALL for compilation and installation instructions. See the file NEWS for information on what has changed in recent versions. You can get the latest version of strace from its homepage at http://sourceforge.net/projects/strace/ . Please send bug reports and enhancements to the strace mailinglist at strace-devel@lists.sourceforge.net.
Description
Languages
C
92.2%
Shell
3.4%
M4
1.4%
Makefile
0.8%
Roff
0.7%
Other
1.5%