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
5 This abstraction has no clients anymore, remove it.
7 This is what remains from previous authors, so correct copyright
8 statement after recent modifications and code removal.
10 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
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
17 struct nf_queue_entry;
20 - unsigned short family;
23 -extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
24 -static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
26 - return rcu_dereference(nf_afinfo[family]);
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);
36 -int nf_register_afinfo(const struct nf_afinfo *afinfo);
37 -void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
40 extern void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
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),
48 -static const struct nf_afinfo nf_br_afinfo = {
49 - .family = AF_BRIDGE,
50 - .route_key_size = 0,
53 static int __init nf_tables_bridge_init(void)
57 - nf_register_afinfo(&nf_br_afinfo);
58 ret = nft_register_chain_type(&filter_bridge);
63 ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
66 + goto err_register_subsys;
72 nft_unregister_chain_type(&filter_bridge);
74 - nf_unregister_afinfo(&nf_br_afinfo);
79 @@ -126,7 +119,6 @@ static void __exit nf_tables_bridge_exit
81 unregister_pernet_subsys(&nf_tables_bridge_net_ops);
82 nft_unregister_chain_type(&filter_bridge);
83 - nf_unregister_afinfo(&nf_br_afinfo);
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
92 EXPORT_SYMBOL_GPL(nf_ip_route);
94 -static const struct nf_afinfo nf_ip_afinfo = {
98 -static int __init ipv4_netfilter_init(void)
100 - return nf_register_afinfo(&nf_ip_afinfo);
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,
109 -static const struct nf_afinfo nf_ip6_afinfo = {
110 - .family = AF_INET6,
113 int __init ipv6_netfilter_init(void)
115 RCU_INIT_POINTER(nf_ipv6_ops, &ipv6ops);
116 - return nf_register_afinfo(&nf_ip6_afinfo);
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)
124 RCU_INIT_POINTER(nf_ipv6_ops, NULL);
125 - nf_unregister_afinfo(&nf_ip6_afinfo);
127 --- a/net/netfilter/core.c
128 +++ b/net/netfilter/core.c
130 * Thanks to Rob `CmdrTaco' Malda for not influencing this code in any
133 - * Rusty Russell (C)2000 -- This code is GPL.
134 - * Patrick McHardy (c) 2006-2012
135 + * This code is GPL.
137 #include <linux/kernel.h>
138 #include <linux/netfilter.h>
141 #include "nf_internals.h"
143 -static DEFINE_MUTEX(afinfo_mutex);
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);
150 DEFINE_PER_CPU(bool, nf_skb_duplicated);
151 EXPORT_SYMBOL_GPL(nf_skb_duplicated);
153 -int nf_register_afinfo(const struct nf_afinfo *afinfo)
155 - mutex_lock(&afinfo_mutex);
156 - RCU_INIT_POINTER(nf_afinfo[afinfo->family], afinfo);
157 - mutex_unlock(&afinfo_mutex);
160 -EXPORT_SYMBOL_GPL(nf_register_afinfo);
162 -void nf_unregister_afinfo(const struct nf_afinfo *afinfo)
164 - mutex_lock(&afinfo_mutex);
165 - RCU_INIT_POINTER(nf_afinfo[afinfo->family], NULL);
166 - mutex_unlock(&afinfo_mutex);
169 -EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
171 #ifdef HAVE_JUMP_LABEL
172 struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
173 EXPORT_SYMBOL(nf_hooks_needed);