Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nfnetlink_hook: Dump flowtable info

Introduce NFNL_HOOK_TYPE_NFT_FLOWTABLE to distinguish flowtable hooks
from base chain ones. Nested attributes are shared with the old NFTABLES
hook info type since they fit apart from their misleading name.

Old nftables in user space will ignore this new hook type and thus
continue to print flowtable hooks just like before, e.g.:

| family netdev {
| hook ingress device test0 {
| 0000000000 nf_flow_offload_ip_hook [nf_flow_table]
| }
| }

With this patch in place and support for the new hook info type, output
becomes more useful:

| family netdev {
| hook ingress device test0 {
| 0000000000 flowtable ip mytable myft [nf_flow_table]
| }
| }

Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Phil Sutter and committed by
Pablo Neira Ayuso
bc8c43ad b65504e7

+51 -11
+1
include/linux/netfilter.h
··· 92 92 NF_HOOK_OP_UNDEFINED, 93 93 NF_HOOK_OP_NF_TABLES, 94 94 NF_HOOK_OP_BPF, 95 + NF_HOOK_OP_NFT_FT, 95 96 }; 96 97 97 98 struct nf_hook_ops {
+13 -11
net/netfilter/nf_tables_api.c
··· 8895 8895 8896 8896 list_for_each_entry(hook, &flowtable_hook->list, list) { 8897 8897 list_for_each_entry(ops, &hook->ops_list, list) { 8898 - ops->pf = NFPROTO_NETDEV; 8899 - ops->hooknum = flowtable_hook->num; 8900 - ops->priority = flowtable_hook->priority; 8901 - ops->priv = &flowtable->data; 8902 - ops->hook = flowtable->data.type->hook; 8898 + ops->pf = NFPROTO_NETDEV; 8899 + ops->hooknum = flowtable_hook->num; 8900 + ops->priority = flowtable_hook->priority; 8901 + ops->priv = &flowtable->data; 8902 + ops->hook = flowtable->data.type->hook; 8903 + ops->hook_ops_type = NF_HOOK_OP_NFT_FT; 8903 8904 } 8904 8905 } 8905 8906 ··· 9728 9727 if (!ops) 9729 9728 return 1; 9730 9729 9731 - ops->pf = NFPROTO_NETDEV; 9732 - ops->hooknum = flowtable->hooknum; 9733 - ops->priority = flowtable->data.priority; 9734 - ops->priv = &flowtable->data; 9735 - ops->hook = flowtable->data.type->hook; 9736 - ops->dev = dev; 9730 + ops->pf = NFPROTO_NETDEV; 9731 + ops->hooknum = flowtable->hooknum; 9732 + ops->priority = flowtable->data.priority; 9733 + ops->priv = &flowtable->data; 9734 + ops->hook = flowtable->data.type->hook; 9735 + ops->hook_ops_type = NF_HOOK_OP_NFT_FT; 9736 + ops->dev = dev; 9737 9737 if (nft_register_flowtable_ops(dev_net(dev), 9738 9738 flowtable, ops)) { 9739 9739 kfree(ops);