mnl: revisit hook listing
Pablo Neira Ayuso
maintainerPATCH v2 1/1 mnl: revisit hook listing
A few updates on the hook listing support:
- Group hooks by family, e.g. ip
- Group hooks by number, e.g. input.
- Order hooks by priority, from INT_MIN to INT_MAX.
- Do not add sign to hook priority zero.
- Ignore EPROTONOSUPPORT, on older kernels this command results in EINVAL. On new kernels, just list nothing on unsupported families.
- Update include/linux/netfilter/nfnetlink_hook.h to include NFNLA_* attributes.
- Use NFNLA_CHAIN_* attributes to print the chain family, table and name. If NFNLA_CHAIN_* attributes are not available, display the hookfn name.
# nft list hooks
family ip {
hook prerouting {
+0000000500 chain ip x z [nf_tables]
}
hook input {
+0000000300 chain inet foo bar [nf_tables]
+0000000500 chain ip x y [nf_tables]
}
hook forward {
-0000000225 selinux_ipv4_forward
}
hook output {
-0000000225 selinux_ipv4_output
}
hook postrouting {
+0000000225 selinux_ipv4_postroute
}
}
family ip6 {
hook input {
+0000000300 chain inet foo bar [nf_tables]
}
hook forward {
-0000000225 selinux_ipv6_forward
}
hook output {
-0000000225 selinux_ipv6_output
}
hook postrouting {
+0000000225 selinux_ipv6_postroute
}
}Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/linux/netfilter/nfnetlink_hook.h | 14 +- src/mnl.c | 361 +++++++++++++++++------ 2 files changed, 275 insertions(+), 100 deletions(-)
include/linux/netfilter/nfnetlink_hook.h +12 -2
@@ -8,10 +8,10 @@ enum nfnl_hook_msg_types { };/** -* enum nfnl_hook_attributes - nf_tables netfilter hook netlink attributes +* enum nfnl_hook_attributes - netfilter hook netlink attributes * * @NFNLA_HOOK_HOOKNUM: netfilter hook number (NLA_U32) -* @NFNLAA_HOOK_PRIORITY: netfilter hook priority (NLA_U32) +* @NFNLA_HOOK_PRIORITY: netfilter hook priority (NLA_U32) * @NFNLA_HOOK_DEV: netdevice name (NLA_STRING) * @NFNLA_HOOK_FUNCTION_NAME: hook function name (NLA_STRING) * @NFNLA_HOOK_MODULE_NAME: kernel module that registered this hook (NLA_STRING)
@@ -43,6 +43,15 @@ enum nfnl_hook_chain_info_attributes { };#define NFNLA_HOOK_INFO_MAX (__NFNLA_HOOK_INFO_MAX - 1) +enum nfnl_hook_chain_desc_attributes { +NFNLA_CHAIN_UNSPEC , +NFNLA_CHAIN_TABLE , +NFNLA_CHAIN_FAMILY , +NFNLA_CHAIN_NAME , + __NFNLA_CHAIN_MAX, +}; +#define NFNLA_CHAIN_MAX (__NFNLA_CHAIN_MAX - 1) +/** * enum nfnl_hook_chaintype - chain type *
@@ -51,4 +60,5 @@ enum nfnl_hook_chain_info_attributes {enum nfnl_hook_chaintype {NFNL_HOOK_TYPE_NFTABLES =0x1 , }; +#endif /* _NFNL_HOOK_H */
src/mnl.c +263 -98
473 lines not on this page · raw message
Signature · 1 line
2.20.1