]> git.ipfire.org Git - thirdparty/nftables.git/commit
src: mnl: clean up hook listing code
authorFlorian Westphal <fw@strlen.de>
Wed, 31 Jul 2024 16:51:01 +0000 (18:51 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 19 Aug 2024 12:00:35 +0000 (14:00 +0200)
commitaf712117df54d8620ed046d19a37ee62516d5f38
tree722620a8772ec2c54bbad48107f4a9360f4cad2d
parentb5205165bd708ac2be4dabd21de0c14f086e1a35
src: mnl: clean up hook listing code

mnl_nft_dump_nf_hooks() can call itself for the UNSPEC case, this
avoids the second switch/case to handle printing for inet/unspec.

As for the error handling, 'nft list hooks' should not print an error,
even if nothing is printed, UNLESS there was also a lowlevel (syscall)
error from the kernel.

We don't want to indicate failure just because e.g. kernel doesn't support
NFPROTO_ARP.

This also fixes a display bug, 'nft list hooks device foo' would show hooks
registered for that device as 'bridge' family instead of the expected
'netdev' family.

This was because UNSPEC handling did not query 'netdev' family and did
pass the device name to the lowlevel function.  Add it, and pass NULL
device name for those families that don't support device attachment.

The lowelevel function currently always queries NFPROTO_NETDEV to handle
the 'inet' ingress case.

This is dubious, as 'inet ingress' is a pseudo-alias to netdev family
(inet itself is a pseudo-family that ends up registering for both ipv4
 and ipv6 hooks).

This is resolved in next patch.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/mnl.c