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