Commit Graph

203 Commits

Author SHA1 Message Date
00ba20aae1 net.c: when printing struct msghdr.msg_control, also print its name
* net.c (printcmsghdr): Skip control messages of zero length.
Always print "msg_control=" before the control message.
(do_msghdr): Print control message before its length, not after.
* tests/inet-cmsg.c (main): Update expected output.
* tests/scm_rights-fd.test: Likewise.
2016-06-26 23:57:18 +00:00
cf0ef0852c Assume that libc provides struct msghdr.msg_control
* configure.ac (AC_CHECK_MEMBERS): Remove struct msghdr.msg_control.
* net.c (do_msghdr): Remove HAVE_STRUCT_MSGHDR_MSG_CONTROL check.
2016-06-26 23:56:59 +00:00
e96aee7ebb net.c: move all sockaddr parsers to a separate file
* sockaddr_ll.c: Rename to sockaddr.c
(print_sockaddr_data_ll): Add static keyword.
* Makefile.am (strace_SOURCES): Likewise.
* defs.h (print_sockaddr_data_ll): Remove.
(addrfams): New prototype.
* net.c: Move all sockaddr parsers to sockaddr.c.
2016-06-25 15:47:27 +00:00
42e566ae74 net.c: rename printsock to decode_sockaddr
* defs.h (printsock): Rename to decode_sockaddr.
* net.c (printsock): Likewise.
(do_msghdr, SYS_FUNC(bind), do_sockname, SYS_FUNC(sendto),
SYS_FUNC(recvfrom)): Replace printsock with decode_sockaddr.
2016-06-25 15:45:20 +00:00
45ae937ced net.c: fix printing AF_PACKET socket addresses
* defs.h (print_ifindex, print_sockaddr_data_ll): New prototypes.
* net.c: Stop including "xlat/af_packet_types.h".
(print_ifindex): Remove static keyword.
(print_sockaddr_data_l): Remove.
* sockaddr_ll.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* xlat/arp_hardware_types.in: New file.
* xlat/ethernet_protocols.in: Likewise.
2016-06-24 17:43:52 +00:00
eef96acd1a net.c: skip details of too short socket addresses, part 2
* net.c (sa_printers): Add minimal address length for each socket family.
(print_sockaddr): Call socket family specific sockaddr printer
only when socket address length is greater or equal
the minimal address length for the socket family.
2016-06-24 15:49:31 +00:00
324f68d439 net.c: fix printing AF_BLUETOOTH socket addresses
* xlat/hci_channels.in: New file.
* net.c (print_sockaddr_data_raw): New function.
(print_sockaddr): Use it.
[HAVE_BLUETOOTH_BLUETOOTH_H]: Include "xlat/hci_channels.h".
[HAVE_BLUETOOTH_BLUETOOTH_H] (print_sockaddr_data_bt): Fix printing
sockaddr_hci, sockaddr_sco, sockaddr_rc, and sockaddr_l2 structures.
2016-06-24 15:49:31 +00:00
102c8ca79e net.c: fix printing AF_IPX sockets addresses, part 2
* net.c (print_sockaddr_data_ipx): Print sockaddr_ipx.sipx_network
using %#08x format.  Print elements of sockaddr_ipx.sipx_node array
and sockaddr_ipx.sipx_type using %#02x format.
2016-06-24 15:49:31 +00:00
0e09796e95 net.c: fix printing AF_UNIX abstract socket addresses
AF_UNIX abstract socket address specified by sockaddr_un.sun_path
is not a NUL-terminated string.

* net.c (SIZEOF_SA_FAMILY): New macro.
(print_sockaddr_data_un): Use it.  Specify actual address length
in print_quoted_string calls.  Do not set QUOTE_0_TERMINATED flag
when printing an abstract socket address.
2016-06-24 15:48:52 +00:00
71e05be60a net.c: fix printing field names of struct sockaddr_nl
* net.c (print_sockaddr_data_nl): Change "pid" to "nl_pid", "groups"
to "nl_groups".  Print sockaddr_nl.nl_groups using %#08x format.
* tests/net-yy-netlink.c (main): Update.
2016-06-24 01:47:59 +00:00
60bf6c7e7b net.c: fix printing struct sockaddr_in6.sin6_flowinfo
* net.c (print_sockaddr_data_in6): Convert sockaddr_in6.sin6_flowinfo
from network order to host order before printing.
2016-06-24 01:47:59 +00:00
c6fd08c6ed net.c: do not print sockaddr_in6.sin6_scope_id unnecessarily
Prior to RFC2553, struct sockaddr_in6 had no sin6_scope_id field.
As the kernel still accepts RFC2133 editions of struct sockaddr_in6,
print sockaddr_in6.sin6_scope_id only when it is specified.

* net.c (SIN6_MIN_LEN): New macro.
(print_sockaddr_data_in6): Print sockaddr_in6.sin6_scope_id only when
socket address length exceeds SIN6_MIN_LEN.
2016-06-23 09:32:24 +00:00
dcc7a3c1c6 net.c: fix printing raw data of socket addresses
* net.c (print_sockaddr): When printing socket address raw data, read
exactly the number of data bytes specified for the socket addess.
2016-06-23 01:11:35 +00:00
f52753aad5 net.c: skip details of too short socket addresses
* net.c (print_sockaddr): Print socket address details only when
the address size is greater than sizeof(struct sockaddr.sa_family).
(print_sockaddr_data_un): Remove handling of addrlen == 2.
* tests/net-y-unix.c (main): Update expected pattern.
* tests/net-yy-unix.c (main): Likewise.
* tests/net.expected: Likewise.
2016-06-23 01:10:17 +00:00
0a3d0e5f49 Assume that libc provides struct sockaddr_in6.sin6_scope_id
* configure.ac (AC_CHECK_MEMBERS): Remove
struct sockaddr_in6.sin6_scope_id.
* net.c (print_sockaddr_data_in6): Remove
HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID check.
2016-06-22 23:15:54 +00:00
42c5878867 Split print_sockaddr
* net.c (sockaddr_buf_t): Remove.
(sockaddr_printer): New type.
(sa_printers): New array of sockaddr_printer.
(print_sockaddr): Use it.  Move printers of family specific
sockaddr data to separate funcions.
2016-06-22 15:58:00 +00:00
Fabien Siron
2a54d8b257 Add a enum for decoding to tprint_iov() and tprint_iov_upto()
Introduce a new type iov_decode which will be used instead of the integer
"decode" as a parameter.

* defs.h (iov_decode): New enum.
(tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
* aio.c (print_iocb): Change type of "decode_iov" to enum iov_decode in
tprint_iov() call.
* keyctl.c (keyctl_instantiate_key_iov): Likewise.
* process.c (ptrace): Likewise.
* process_vm.c (process_vm_readv, process_vm_writev): Likewise.
* io.c (writev, do_pwritev, vmsplice): Likewise.
(print_iovec): Replace the condition with a switch.
(tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
(readv, do_preadv): Change type of "decode_iov" to enum iov_decode in
tprint_iov_upto() call.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): Likewise.
* net.c (do_msghdr): Adapt call of tprint_iov_upto().
2016-06-22 14:40:57 +00:00
64906b8f0a printsock: fix zero padding of sockaddr buffer
Before this change printsock used to erroneously clear the last byte
of sockaddr buffer.

* net.c (printsock): Use struct sockaddr_storage as a sockaddr buffer.
Reserve additional byte after the sockaddr buffer for zero padding.
Do not clear memory that is going to be overwritten by umoven.
Clear the tail of sockaddr buffer that was not overwritten by umoven.
2016-06-22 00:21:47 +00:00
Fabien Siron
0a1ce62062 Change printsock to return socket family
* defs.h (printsock): Change return type to int.
* net.c (printsock): Likewise.  Return socket family on success
and -1 in case of an error.
2016-06-21 23:38:05 +00:00
3bf9c190f1 Export print_sockaddr function
* defs.h (print_sockaddr): New prototype.
* net.c (print_sockaddr): Remove static keyword.
Change type of address pointer to "const void *".
(print_cmsg_ip_recverr, print_group_req): Remove redundant casts
in print_sockaddr invocations.
2016-06-21 16:55:22 +00:00
b5f1fd926a Assume that libc provides inet_ntop and inet_pton
* configure.ac (AC_CHECK_FUNCS): Remove inet_ntop and inet_pton.
* net.c (sockaddr_buf_t, print_sockaddr, print_mreq6): Remove
HAVE_INET_NTOP checks.
* tests/ip_mreq.c: Remove HAVE_INET_PTON check.
2016-06-21 16:44:50 +00:00
f8ed94b53a net.c: use SO_LINGER unconditionally
* net.c (print_linger, print_getsockopt, print_setsockopt): Do not check
for SO_LINGER availability.
2016-06-21 16:44:15 +00:00
43369fc103 net.c: use AF_BLUETOOTH unconditionally
* net.c (print_sockaddr, SYS_FUNC(socket)): Do not check
for AF_BLUETOOTH availability.
2016-06-21 16:43:30 +00:00
bc4102e81d net.c: fix printing AF_IPX sockets
* net.c (print_sockaddr): Print sockaddr_ipx as a regular structure.
(SYS_FUNC(socket)): Remove special handling of AF_IPX.
2016-06-19 22:02:45 +00:00
eb1c22b8c2 net.c: use AF_IPX unconditionally
* net.c (sockaddr_buf_t, print_sockaddr, SYS_FUNC(socket)): Do not check
for AF_IPX availability.
2016-06-19 22:02:45 +00:00
ebda41a44a Cleanup netipx/ipx.h availability check
* configure.ac (AC_CHECK_HEADERS): Add netipx/ipx.h.
* net.c: Check for HAVE_NETIPX_IPX_H instead of __GLIBC__.
2016-06-19 22:02:45 +00:00
5e26ee2221 net.c: use AF_INET6 unconditionally
* net.c (SYS_FUNC(socket)): Do not check for AF_INET6 availability.
2016-06-16 01:00:38 +00:00
c981b1f858 net.c: use AF_PACKET unconditionally
* net.c: Do not check for AF_PACKET availability.
2016-06-16 01:00:24 +00:00
4f689a1407 net.c: include <linux/if_packet.h> unconditionally
* configure.ac (AC_CHECK_HEADERS): Remove linux/if_packet.h.
* net.c: Include <linux/if_packet.h> unconditionally.
2016-06-16 01:00:24 +00:00
fba9db299c net.c: use ICMP_FILTER unconditionally
* net.c: Do not check for ICMP_FILTER availability.
2016-06-16 01:00:23 +00:00
d06010b3c4 net.c: include <linux/icmp.h> unconditionally
* configure.ac (AC_CHECK_HEADERS): Remove linux/icmp.h.
* net.c: Follow the example of tests/net-icmp_filter.c and include
<linux/icmp.h> unconditionally.
2016-06-16 01:00:23 +00:00
9457304b4c net.c: use AF_NETLINK unconditionally
* net.c: Do not check for AF_NETLINK availability.
2016-06-14 13:53:47 +00:00
b10ee4e0eb net.c: include <linux/netlink.h> unconditionally
* configure.ac (AC_CHECK_HEADERS): Remove linux/netlink.h.
* net.c: Follow the example of socketutils.c and include
<linux/netlink.h> unconditionally.
2016-06-14 13:53:47 +00:00
484326dbd8 Consistently use printaddr for printing addresses
* bjm.c (SYS_FUNC(init_module)): Use printaddr.
* clone.c (SYS_FUNC(clone)): Likewise.
* evdev.c (ff_effect_ioctl): Likewise.
* mtd.c (decode_mtd_oob_buf): Likewise.
* net.c (SYS_FUNC(sendmmsg), SYS_FUNC(recvmmsg), SYS_FUNC(getsockopt)):
Likewise.
* print_sigevent.c (print_sigevent): Likewise.
* printsiginfo.c (printsigval, print_si_info): Likewise.
* signal.c (decode_new_sigaction): Likewise.
* sysmips.c (SYS_FUNC(sysmips)): Likewise.
* util.c (printpathn, printstr, umoven_or_printaddr): Likewise.
* v4l2.c (print_v4l2_buffer, print_v4l2_framebuffer,
umoven_or_printaddr_ignore_syserror): Likewise.
* tests/net-icmp_filter.c (main): Update.

Based on patch by Eugene Syromyatnikov <evgsyr@gmail.com>.
2016-06-11 09:26:49 +00:00
9134aab407 Prepare for transition from xlookup64 to xlookup
* fcntl.c (print_fcntl, SYS_FUNC(fcntl), SYS_FUNC(fcntl64)):
Cast 2nd argument of xlookup to unsigned long.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* sched.c (SYS_FUNC(sched_getscheduler)): Likewise.
* time.c (do_adjtimex): Likewise.
* ioprio.c (sprint_ioprio): Change type of the argument
and local variables from int to unsigned int.
* keyctl.c (print_keyring_serial_number): Cast 2nd argument
of xlookup to unsigned int.
* net.c (tprint_sock_type): Change type of the argument to unsigned int.
* printmode.c (sprintmode): Likewise.
* printsiginfo.c (printsigval):  Change type of si_code argument
to unsigned int.
2016-05-14 22:05:06 +00:00
eb5c233d99 Fix corner cases of ICMP_FILTER decoding
* net.c (print_icmp_filter): Print icmp_filter for any positive length.
* tests/net-icmp_filter.c: New file.
* tests/net-icmp_filter.test: New test.
* tests/.gitignore: Add net-icmp_filter.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add net-icmp_filter.test.
2016-05-06 00:22:52 +00:00
71fe62e6b7 Replace PF_* constants with AF_*
AF_* constants appear to be more standardized, and in practice there's
always a one to one relationship between AF_* and PF_*, so let's
use AF_* instead of PF_*.

* xlat/domains.in: Remove.
* net.c: Do not define PF_UNSPEC.  Stop including "xlat/domains.h".
Replace PF_* with AF_*.  Replace domains with addrfams.
* tests/inet-cmsg.c: Replace PF_INET with AF_INET.
* tests/net-yy-inet.c: Likewise.
* tests/netlink_inet_diag.c: Likewise.
* tests/net-accept-connect.c: Replace PF_LOCAL with AF_LOCAL.
* tests/net-y-unix.c: Likewise.
* tests/net-yy-unix.c: Likewise.
* tests/netlink_unix_diag.c: Likewise.
* tests/net.expected: Replace PF_ with AF_.
2016-04-04 01:35:28 +00:00
f40ea796ba Consistently handle 2nd and 3rd arguments of [gs]etsockopt as unsigned
The second (level) and third (optname) arguments of getsockopt and
setsockopt syscalls are enums, so treat them consistently as enums:
use "unsigned int" type to avoid potential sign extension issues.

* net.c (print_sockopt_fd_level_name, print_getsockopt,
print_setsockopt): Change type of "level" and "name" arguments
from "int" to "unsigned int".
2016-04-01 01:03:20 +00:00
9b38885803 alpha, ia64, mips, sh*, sparc*: fix error path decoding of pipe syscall
* net.c (do_pipe) [HAVE_GETRVAL2]: Remove.
Always call decode_pair_fd on exiting.
(SYS_FUNC(pipe)) [HAVE_GETRVAL2]: Call printpair_fd instead of do_pipe.
2016-02-13 00:57:00 +00:00
d44707d889 Fix dumping of recvmmsg syscall in case of short read
* net.c (dumpiov_in_mmsghdr): Call dumpiov_upto instead of dumpiov,
pass data size limit to dumpiov_upto.
* NEWS: Mention this fix.
* tests/mmsg.c (main): Update.
2016-01-20 17:36:41 +00:00
93c9d1cdbd Fix dumping of recvmsg syscall in case of short read
* defs.h (dumpiov_in_msghdr): Add unsigned long argument.
* net.c (dumpiov_in_msghdr): Add data_size argument.  Call dumpiov_upto
instead of dumpiov, pass data_size to dumpiov_upto.
* syscall.c (dumpio): Pass data size limit to dumpiov_in_msghdr.
* NEWS: Mention this fix.
* tests/recvmsg.c: New file.
* tests/recvmsg.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add recvmsg.
(TESTS): Add recvmsg.test.
* tests/.gitignore: Add recvmsg.
2016-01-20 17:35:27 +00:00
a17f593e50 net: fix printing of IP_RECVOPTS/IP_RETOPTS cmsg options
* net.c (print_cmsg_ip_opts): Print each byte as unsigned char.
2015-11-22 23:09:59 +00:00
1f111cff5a Implement IPPROTO_IP control messages decoding
* net.c: Include "xlat/ip_cmsg_types.h".
(print_cmsg_ip_pktinfo, print_cmsg_ip_ttl, print_cmsg_ip_tos,
print_cmsg_ip_opts, print_cmsg_ip_recverr, print_cmsg_ip_checksum,
print_cmsg_ip_origdstaddr): New functions.
(print_cmsg_type_data): Add generic SOL_IP level decoding.
Use these functions for decoding of IP_PKTINFO, IP_TTL, IP_TOS,
IP_RECVOPTS, IP_RETOPTS, IP_RECVERR, IP_ORIGDSTADDR, IP_CHECKSUM,
and SCM_SECURITY type messages.
* xlat/ip_cmsg_types.in: New file.
* xlat/sockipoptions.in: Move IP_RETOPTS before IP_RECVRETOPTS.
* tests/inet-cmsg.c: New file.
* tests/inet-cmsg.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add inet-cmsg.
(TESTS): Add inet-cmsg.test.
* tests/.gitignore: Add inet-cmsg.

Suggested-by: Orion Poplawski <orion@cora.nwra.com>
2015-11-22 02:56:45 +00:00
1103b4ee86 Simplify control messages printers
Do not pass sizeof(struct cmsghdr) to every cmsg printer.

* net.c (printcmsghdr): Pass pointer to cmsg_data and length
of cmsg_data to print_cmsg_type_data.
(print_cmsg_type_data): Update prototype.  Pass pointer to cmsg_data
and length of cmsg_data to cmsg printers.
(print_scm_rights, print_scm_creds, print_scm_security): Update.
2015-11-22 02:42:45 +00:00
1019f002c1 net: factor out address printing code to a separate function
* net.c (sockaddr_buf_t): New type.
(print_sockaddr): New function.
(printsock, print_group_req): Use it.
2015-11-21 02:52:23 +00:00
f54cb96f7f printcmsghdr: move type and data decoders to a separate function
* net.c (print_scm_rights, print_scm_creds, print_scm_security): Change
to return void.  Move printing of struct cmsghdr closing '}' ...
(printcmsghdr): ... here.  Move type and data decoders to ...
(print_cmsg_type_data): ... new function.
2015-11-19 00:31:32 +00:00
b36d132907 Assume that libc provides sendmsg
Starting with commit v4.6-281-g7af9f35, we implicitly assume that
HAVE_SENDMSG is always defined.  Therefore, the check for sendmsg
availability is redundant and could be safely removed.

* configure.ac (AC_CHECK_FUNCS): Remove sendmsg.
* linux/dummy.h [!HAVE_SENDMSG] (sys_recvmsg, sys_sendmsg): Remove
stub aliases.
* net.c [HAVE_SENDMSG]: Define unconditionally.
* syscall.c (dumpio) [HAVE_SENDMSG]: Likewise.
2015-11-18 23:18:17 +00:00
3a1e95d14e net.c: move fallback definition of SCM_SECURITY to xlat/
* net.c: Move fallback definition of SCM_SECURITY ...
* xlat/scmvals.in: ... here.
2015-11-18 23:11:34 +00:00
2950de3631 Convert another parser of struct timespec to new mpers infrastructure
* print_time.c (sprint_timespec): New mpers printer.
* defs.h (TIMESPEC_TEXT_BUFSIZE): Update.
(sprint_timespec): Remove.
* time.c (sprint_timespec): Remove.
* net.c (sys_recvmmsg): Update callers.
* poll.c (decode_poll_exiting): Likewise.
2015-09-19 04:04:49 +03:00
Mike Frysinger
54646b8e05 decode extend getsockopt/setsockopt options
Currently the code assumes the set of valid options between getsockopt
and setsockopt are exactly the same and thus maintains one list.  The
kernel unfortunately does not do this -- it allows for different opts
between the get and set functions.  See the {g,s}et_opt{min,max} fields
in the various netfilter subcores.

To support this, extend the printxval function to take multiple sets of
xlats as varargs.  Then we add the new get/set lists, and pass them down
in the net code when decoding things.

A simple example is iptables; before:
	getsockopt(4, SOL_IP, 0x40 /* IP_??? */, ...) = 0
	getsockopt(4, SOL_IP, 0x41 /* IP_??? */, ...) = 0
after:
	getsockopt(4, SOL_IP, IPT_SO_GET_INFO, ...) = 0
	getsockopt(4, SOL_IP, IPT_SO_GET_ENTRIES, ...) = 0

If these were setsockopt calls, then 0x40 & 0x41 would be
IPT_SO_SET_REPLACE & IPT_SO_SET_ADD_COUNTERS.

* configure.ac: Check for netfilter headers.
* defs.h (printxvals): New prototype.
(printxval): Change to a define.
* net.c: Include netfilter headers and new sockopts headers.
(print_sockopt_fd_level_name): Add a is_getsockopt argument.  Change SOL_IP
and SOL_IPV6 decoding to use printxvals, and use is_getsockopt to pass more
xlats down.
(getsockopt): Call print_sockopt_fd_level_name with is_getsockopt as true.
(setsockopt): Call print_sockopt_fd_level_name with is_getsockopt as false.
* util.c (printxval): Rename to ...
(printxvals): ... this.  Rewrite to be varargs based.
* xlat/getsockipoptions.in: New xlat list.
* xlat/getsockipv6options.in, xlat/setsockipoptions.in,
xlat/setsockipv6options.in: Likewise.
2015-08-26 12:09:25 +00:00