1 From bb4badf3a3dc81190f7c1c1fa063cdefb18df45f Mon Sep 17 00:00:00 2001
2 From: Florian Westphal <fw@strlen.de>
3 Date: Thu, 7 Dec 2017 16:28:25 +0100
4 Subject: [PATCH 07/11] netfilter: don't allocate space for decnet hooks unless
7 no need to define hook points if the family isn't supported.
9 Signed-off-by: Florian Westphal <fw@strlen.de>
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 include/linux/netfilter.h | 2 ++
13 include/net/netns/netfilter.h | 2 ++
14 net/netfilter/core.c | 4 ++++
15 3 files changed, 8 insertions(+)
17 --- a/include/linux/netfilter.h
18 +++ b/include/linux/netfilter.h
19 @@ -219,9 +219,11 @@ static inline int nf_hook(u_int8_t pf, u
21 hook_head = rcu_dereference(net->nf.hooks_bridge[hook]);
23 +#if IS_ENABLED(CONFIG_DECNET)
25 hook_head = rcu_dereference(net->nf.hooks_decnet[hook]);
31 --- a/include/net/netns/netfilter.h
32 +++ b/include/net/netns/netfilter.h
33 @@ -21,7 +21,9 @@ struct netns_nf {
34 struct nf_hook_entries __rcu *hooks_ipv6[NF_INET_NUMHOOKS];
35 struct nf_hook_entries __rcu *hooks_arp[NF_ARP_NUMHOOKS];
36 struct nf_hook_entries __rcu *hooks_bridge[NF_INET_NUMHOOKS];
37 +#if IS_ENABLED(CONFIG_DECNET)
38 struct nf_hook_entries __rcu *hooks_decnet[NF_DN_NUMHOOKS];
40 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
43 --- a/net/netfilter/core.c
44 +++ b/net/netfilter/core.c
45 @@ -283,10 +283,12 @@ static struct nf_hook_entries __rcu **nf
46 if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_ipv6) <= reg->hooknum))
48 return net->nf.hooks_ipv6 + reg->hooknum;
49 +#if IS_ENABLED(CONFIG_DECNET)
51 if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_decnet) <= reg->hooknum))
53 return net->nf.hooks_decnet + reg->hooknum;
58 @@ -573,7 +575,9 @@ static int __net_init netfilter_net_init
59 __netfilter_net_init(net->nf.hooks_ipv6, ARRAY_SIZE(net->nf.hooks_ipv6));
60 __netfilter_net_init(net->nf.hooks_arp, ARRAY_SIZE(net->nf.hooks_arp));
61 __netfilter_net_init(net->nf.hooks_bridge, ARRAY_SIZE(net->nf.hooks_bridge));
62 +#if IS_ENABLED(CONFIG_DECNET)
63 __netfilter_net_init(net->nf.hooks_decnet, ARRAY_SIZE(net->nf.hooks_decnet));
67 net->nf.proc_netfilter = proc_net_mkdir(net, "netfilter",