[PATCH v3] decode extend getsockopt/setsockopt options

Dmitry V. Levin ldv at altlinux.org
Thu Aug 20 11:42:45 UTC 2015


On Wed, Aug 19, 2015 at 01:29:27PM -0400, Mike Frysinger wrote:
> 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.

Ideally, we also need a test for this, something like ip_mreq.test

> * util.c (printxval): Rename to ...
> (printxvals): ... this.  Rewrite to be varargs based.

OK, let's have two separate functions so that
the most frequent use case won't be penalized.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150820/6e0f9e91/attachment.bin>


More information about the Strace-devel mailing list