6d19743dfe64edd10b987ae8383ac4bd2234a0f8
[openwrt/staging/linusw.git] /
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Sat, 9 Dec 2017 17:05:53 +0100
3 Subject: [PATCH] netfilter: remove struct nf_afinfo and its helper functions
4
5 This abstraction has no clients anymore, remove it.
6
7 This is what remains from previous authors, so correct copyright
8 statement after recent modifications and code removal.
9
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 ---
12
13 --- a/include/linux/netfilter.h
14 +++ b/include/linux/netfilter.h
15 @@ -272,16 +272,6 @@ int skb_make_writable(struct sk_buff *sk
16 struct flowi;
17 struct nf_queue_entry;
18
19 -struct nf_afinfo {
20 - unsigned short family;
21 -};
22 -
23 -extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
24 -static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
25 -{
26 - return rcu_dereference(nf_afinfo[family]);
27 -}
28 -
29 __sum16 nf_checksum(struct sk_buff *skb, unsigned int hook,
30 unsigned int dataoff, u_int8_t protocol,
31 unsigned short family);
32 @@ -293,9 +283,6 @@ int nf_route(struct net *net, struct dst
33 bool strict, unsigned short family);
34 int nf_reroute(struct sk_buff *skb, struct nf_queue_entry *entry);
35
36 -int nf_register_afinfo(const struct nf_afinfo *afinfo);
37 -void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
38 -
39 #include <net/flow.h>
40 extern void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
41
42 --- a/net/bridge/netfilter/nf_tables_bridge.c
43 +++ b/net/bridge/netfilter/nf_tables_bridge.c
44 @@ -95,30 +95,23 @@ static const struct nf_chain_type filter
45 (1 << NF_BR_POST_ROUTING),
46 };
47
48 -static const struct nf_afinfo nf_br_afinfo = {
49 - .family = AF_BRIDGE,
50 - .route_key_size = 0,
51 -};
52 -
53 static int __init nf_tables_bridge_init(void)
54 {
55 int ret;
56
57 - nf_register_afinfo(&nf_br_afinfo);
58 ret = nft_register_chain_type(&filter_bridge);
59 if (ret < 0)
60 - goto err1;
61 + return ret;
62
63 ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
64 if (ret < 0)
65 - goto err2;
66 + goto err_register_subsys;
67
68 return ret;
69
70 -err2:
71 +err_register_subsys:
72 nft_unregister_chain_type(&filter_bridge);
73 -err1:
74 - nf_unregister_afinfo(&nf_br_afinfo);
75 +
76 return ret;
77 }
78
79 @@ -126,7 +119,6 @@ static void __exit nf_tables_bridge_exit
80 {
81 unregister_pernet_subsys(&nf_tables_bridge_net_ops);
82 nft_unregister_chain_type(&filter_bridge);
83 - nf_unregister_afinfo(&nf_br_afinfo);
84 }
85
86 module_init(nf_tables_bridge_init);
87 --- a/net/ipv4/netfilter.c
88 +++ b/net/ipv4/netfilter.c
89 @@ -161,13 +161,3 @@ int nf_ip_route(struct net *net, struct
90 return 0;
91 }
92 EXPORT_SYMBOL_GPL(nf_ip_route);
93 -
94 -static const struct nf_afinfo nf_ip_afinfo = {
95 - .family = AF_INET,
96 -};
97 -
98 -static int __init ipv4_netfilter_init(void)
99 -{
100 - return nf_register_afinfo(&nf_ip_afinfo);
101 -}
102 -subsys_initcall(ipv4_netfilter_init);
103 --- a/net/ipv6/netfilter.c
104 +++ b/net/ipv6/netfilter.c
105 @@ -175,14 +175,10 @@ static const struct nf_ipv6_ops ipv6ops
106 .reroute = nf_ip6_reroute,
107 };
108
109 -static const struct nf_afinfo nf_ip6_afinfo = {
110 - .family = AF_INET6,
111 -};
112 -
113 int __init ipv6_netfilter_init(void)
114 {
115 RCU_INIT_POINTER(nf_ipv6_ops, &ipv6ops);
116 - return nf_register_afinfo(&nf_ip6_afinfo);
117 + return 0;
118 }
119
120 /* This can be called from inet6_init() on errors, so it cannot
121 @@ -191,5 +187,4 @@ int __init ipv6_netfilter_init(void)
122 void ipv6_netfilter_fini(void)
123 {
124 RCU_INIT_POINTER(nf_ipv6_ops, NULL);
125 - nf_unregister_afinfo(&nf_ip6_afinfo);
126 }
127 --- a/net/netfilter/core.c
128 +++ b/net/netfilter/core.c
129 @@ -4,8 +4,7 @@
130 * Thanks to Rob `CmdrTaco' Malda for not influencing this code in any
131 * way.
132 *
133 - * Rusty Russell (C)2000 -- This code is GPL.
134 - * Patrick McHardy (c) 2006-2012
135 + * This code is GPL.
136 */
137 #include <linux/kernel.h>
138 #include <linux/netfilter.h>
139 @@ -28,34 +27,12 @@
140
141 #include "nf_internals.h"
142
143 -static DEFINE_MUTEX(afinfo_mutex);
144 -
145 -const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO] __read_mostly;
146 -EXPORT_SYMBOL(nf_afinfo);
147 const struct nf_ipv6_ops __rcu *nf_ipv6_ops __read_mostly;
148 EXPORT_SYMBOL_GPL(nf_ipv6_ops);
149
150 DEFINE_PER_CPU(bool, nf_skb_duplicated);
151 EXPORT_SYMBOL_GPL(nf_skb_duplicated);
152
153 -int nf_register_afinfo(const struct nf_afinfo *afinfo)
154 -{
155 - mutex_lock(&afinfo_mutex);
156 - RCU_INIT_POINTER(nf_afinfo[afinfo->family], afinfo);
157 - mutex_unlock(&afinfo_mutex);
158 - return 0;
159 -}
160 -EXPORT_SYMBOL_GPL(nf_register_afinfo);
161 -
162 -void nf_unregister_afinfo(const struct nf_afinfo *afinfo)
163 -{
164 - mutex_lock(&afinfo_mutex);
165 - RCU_INIT_POINTER(nf_afinfo[afinfo->family], NULL);
166 - mutex_unlock(&afinfo_mutex);
167 - synchronize_rcu();
168 -}
169 -EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
170 -
171 #ifdef HAVE_JUMP_LABEL
172 struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
173 EXPORT_SYMBOL(nf_hooks_needed);