netfilter: ctnetlink: allow to filter dump by status bits
authorFlorian Westphal <fw@strlen.de>
Fri, 30 Jul 2021 13:14:22 +0000 (15:14 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 5 Aug 2021 11:36:39 +0000 (13:36 +0200)
commit9344988d2979ce9eefe136a69efcf692615ebba8
treeb99cd41bb9628a98b4993532d88eeaf1d8360ab2
parentff1199db8c3b7cdc3ac4430badfd254023c5142e
netfilter: ctnetlink: allow to filter dump by status bits

If CTA_STATUS is present, but CTA_STATUS_MASK is not, then the
mask is automatically set to 'status', so that kernel returns those
entries that have all of the requested bits set.

This makes more sense than using a all-one mask since we'd hardly
ever find a match.

There are no other checks for status bits, so if e.g. userspace
sets impossible combinations it will get an empty dump.

If kernel would reject unknown status bits, then a program that works on
a future kernel that has IPS_FOO bit fails on old kernels.

Same for 'impossible' combinations:

Kernel never sets ASSURED without first having set SEEN_REPLY, but its
possible that a future kernel could do so.

Therefore no sanity tests other than a 0-mask.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/uapi/linux/netfilter/nfnetlink_conntrack.h
net/netfilter/nf_conntrack_netlink.c