]> granicus.if.org Git - strace/commit
decode extend getsockopt/setsockopt options
authorMike Frysinger <vapier@gentoo.org>
Wed, 19 Aug 2015 17:29:27 +0000 (13:29 -0400)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 26 Aug 2015 12:09:25 +0000 (12:09 +0000)
commit54646b8e057443f0b76afe9a231eae63afbf5d5a
treedd72a9b65c90ef2b00086fb218d6a9cabf0d4745
parentfffe50d321653a90fa288ed0b486c2537c203955
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.
configure.ac
defs.h
net.c
util.c
xlat/getsockipoptions.in [new file with mode: 0644]
xlat/getsockipv6options.in [new file with mode: 0644]
xlat/setsockipoptions.in [new file with mode: 0644]
xlat/setsockipv6options.in [new file with mode: 0644]