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

netfilter: add new hook nfnl subsystem

This nfnl subsystem allows to dump the list of all active netfiler hooks,
e.g. defrag, conntrack, nf/ip/arp/ip6tables and so on.

This helps to see what kind of features are currently enabled in
the network stack.

Sample output from nft tool using this infra:

$ nft list hook ip input
family ip hook input {
+0000000010 nft_do_chain_inet [nf_tables] # nft table firewalld INPUT
+0000000100 nf_nat_ipv4_local_in [nf_nat]
+2147483647 ipv4_confirm [nf_conntrack]
}

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
e2cf17d3 7b4b2fa3

+443 -1
+2 -1
include/uapi/linux/netfilter/nfnetlink.h
··· 60 60 #define NFNL_SUBSYS_CTHELPER 9 61 61 #define NFNL_SUBSYS_NFTABLES 10 62 62 #define NFNL_SUBSYS_NFT_COMPAT 11 63 - #define NFNL_SUBSYS_COUNT 12 63 + #define NFNL_SUBSYS_HOOK 12 64 + #define NFNL_SUBSYS_COUNT 13 64 65 65 66 /* Reserved control nfnetlink messages */ 66 67 #define NFNL_MSG_BATCH_BEGIN NLMSG_MIN_TYPE
+9
net/netfilter/Kconfig
··· 19 19 config NETFILTER_FAMILY_ARP 20 20 bool 21 21 22 + config NETFILTER_NETLINK_HOOK 23 + tristate "Netfilter base hook dump support" 24 + depends on NETFILTER_ADVANCED 25 + select NETFILTER_NETLINK 26 + help 27 + If this option is enabled, the kernel will include support 28 + to list the base netfilter hooks via NFNETLINK. 29 + This is helpful for debugging. 30 + 22 31 config NETFILTER_NETLINK_ACCT 23 32 tristate "Netfilter NFACCT over NFNETLINK interface" 24 33 depends on NETFILTER_ADVANCED
+1
net/netfilter/Makefile
··· 22 22 obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o 23 23 obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o 24 24 obj-$(CONFIG_NETFILTER_NETLINK_OSF) += nfnetlink_osf.o 25 + obj-$(CONFIG_NETFILTER_NETLINK_HOOK) += nfnetlink_hook.o 25 26 26 27 # connection tracking 27 28 obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
+1
net/netfilter/nfnetlink.c
··· 68 68 [NFNL_SUBSYS_CTHELPER] = "nfnl_subsys_cthelper", 69 69 [NFNL_SUBSYS_NFTABLES] = "nfnl_subsys_nftables", 70 70 [NFNL_SUBSYS_NFT_COMPAT] = "nfnl_subsys_nftcompat", 71 + [NFNL_SUBSYS_HOOK] = "nfnl_subsys_hook", 71 72 }; 72 73 73 74 static const int nfnl_group2type[NFNLGRP_MAX+1] = {