netfilter: nfnetlink_hook: translate inet ingress to netdev

The NFPROTO_INET pseudofamily is not exposed through this new netlink
interface. The netlink dump either shows NFPROTO_IPV4 or NFPROTO_IPV6
for NFPROTO_INET prerouting/input/forward/output/postrouting hooks.
The NFNLA_CHAIN_FAMILY attribute provides the family chain, which
specifies if this hook applies to inet traffic only (either IPv4 or
IPv6).

Translate the inet/ingress hook to netdev/ingress to fully hide the
NFPROTO_INET implementation details.

Fixes: e2cf17d377 ("netfilter: add new hook nfnl subsystem")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Pablo Neira Ayuso 2021-08-06 12:33:57 +02:00
parent 4592ee7f52
commit 269fc69533
1 changed files with 7 additions and 1 deletions

View File

@ -119,6 +119,7 @@ static int nfnl_hook_dump_one(struct sk_buff *nlskb,
unsigned int portid = NETLINK_CB(nlskb).portid; unsigned int portid = NETLINK_CB(nlskb).portid;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
int ret = -EMSGSIZE; int ret = -EMSGSIZE;
u32 hooknum;
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
char sym[KSYM_SYMBOL_LEN]; char sym[KSYM_SYMBOL_LEN];
char *module_name; char *module_name;
@ -156,7 +157,12 @@ static int nfnl_hook_dump_one(struct sk_buff *nlskb,
goto nla_put_failure; goto nla_put_failure;
#endif #endif
ret = nla_put_be32(nlskb, NFNLA_HOOK_HOOKNUM, htonl(ops->hooknum)); if (ops->pf == NFPROTO_INET && ops->hooknum == NF_INET_INGRESS)
hooknum = NF_NETDEV_INGRESS;
else
hooknum = ops->hooknum;
ret = nla_put_be32(nlskb, NFNLA_HOOK_HOOKNUM, htonl(hooknum));
if (ret) if (ret)
goto nla_put_failure; goto nla_put_failure;