26a93c40ae293e7ac2ecc9c377170115e0d352bd
[oweals/openwrt.git] /
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
5  needed
6
7 no need to define hook points if the family isn't supported.
8
9 Signed-off-by: Florian Westphal <fw@strlen.de>
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 ---
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(+)
16
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
20         case NFPROTO_BRIDGE:
21                 hook_head = rcu_dereference(net->nf.hooks_bridge[hook]);
22                 break;
23 +#if IS_ENABLED(CONFIG_DECNET)
24         case NFPROTO_DECNET:
25                 hook_head = rcu_dereference(net->nf.hooks_decnet[hook]);
26                 break;
27 +#endif
28         default:
29                 WARN_ON_ONCE(1);
30                 break;
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];
39 +#endif
40  #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
41         bool                    defrag_ipv4;
42  #endif
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))
47                         return NULL;
48                 return net->nf.hooks_ipv6 + reg->hooknum;
49 +#if IS_ENABLED(CONFIG_DECNET)
50         case NFPROTO_DECNET:
51                 if (WARN_ON_ONCE(ARRAY_SIZE(net->nf.hooks_decnet) <= reg->hooknum))
52                         return NULL;
53                 return net->nf.hooks_decnet + reg->hooknum;
54 +#endif
55         default:
56                 WARN_ON_ONCE(1);
57                 return NULL;
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));
64 +#endif
65  
66  #ifdef CONFIG_PROC_FS
67         net->nf.proc_netfilter = proc_net_mkdir(net, "netfilter",