1 From 62a0fe46e2aaba1812d3cbcae014a41539f9eb09 Mon Sep 17 00:00:00 2001
2 From: Pablo Neira Ayuso <pablo@netfilter.org>
3 Date: Sat, 9 Dec 2017 15:23:51 +0100
4 Subject: [PATCH 09/11] netfilter: core: pass hook number, family and device to
7 Instead of passing struct nf_hook_ops, this is needed by follow up
8 patches to handle NFPROTO_INET from the core.
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 net/netfilter/core.c | 36 +++++++++++++++++++-----------------
13 1 file changed, 19 insertions(+), 17 deletions(-)
15 --- a/net/netfilter/core.c
16 +++ b/net/netfilter/core.c
17 @@ -262,36 +262,38 @@ out_assign:
21 -static struct nf_hook_entries __rcu **nf_hook_entry_head(struct net *net, const struct nf_hook_ops *reg)
22 +static struct nf_hook_entries __rcu **
23 +nf_hook_entry_head(struct net *net, int pf, unsigned int hooknum,
24 + struct net_device *dev)
30 #ifdef CONFIG_NETFILTER_FAMILY_ARP
32 - if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_arp) <= reg->hooknum))
33 + if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_arp) <= hooknum))
35 - return net->nf.hooks_arp + reg->hooknum;
36 + return net->nf.hooks_arp + hooknum;
38 #ifdef CONFIG_NETFILTER_FAMILY_BRIDGE
40 - if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_bridge) <= reg->hooknum))
41 + if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_bridge) <= hooknum))
43 - return net->nf.hooks_bridge + reg->hooknum;
44 + return net->nf.hooks_bridge + hooknum;
47 - if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_ipv4) <= reg->hooknum))
48 + if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_ipv4) <= hooknum))
50 - return net->nf.hooks_ipv4 + reg->hooknum;
51 + return net->nf.hooks_ipv4 + hooknum;
53 - if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_ipv6) <= reg->hooknum))
54 + if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_ipv6) <= hooknum))
56 - return net->nf.hooks_ipv6 + reg->hooknum;
57 + return net->nf.hooks_ipv6 + hooknum;
58 #if IS_ENABLED(CONFIG_DECNET)
60 - if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_decnet) <= reg->hooknum))
61 + if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_decnet) <= hooknum))
63 - return net->nf.hooks_decnet + reg->hooknum;
64 + return net->nf.hooks_decnet + hooknum;
68 @@ -299,9 +301,9 @@ static struct nf_hook_entries __rcu **nf
71 #ifdef CONFIG_NETFILTER_INGRESS
72 - if (reg->hooknum == NF_NETDEV_INGRESS) {
73 - if (reg->dev && dev_net(reg->dev) == net)
74 - return ®->dev->nf_hooks_ingress;
75 + if (hooknum == NF_NETDEV_INGRESS) {
76 + if (dev && dev_net(dev) == net)
77 + return &dev->nf_hooks_ingress;
81 @@ -323,7 +325,7 @@ int nf_register_net_hook(struct net *net
85 - pp = nf_hook_entry_head(net, reg);
86 + pp = nf_hook_entry_head(net, reg->pf, reg->hooknum, reg->dev);
90 @@ -397,7 +399,7 @@ void nf_unregister_net_hook(struct net *
91 struct nf_hook_entries __rcu **pp;
92 struct nf_hook_entries *p;
94 - pp = nf_hook_entry_head(net, reg);
95 + pp = nf_hook_entry_head(net, reg->pf, reg->hooknum, reg->dev);