1 From 4e645b47c4f000a503b9c90163ad905786b9bc1d Mon Sep 17 00:00:00 2001
2 From: Florian Westphal <fw@strlen.de>
3 Date: Fri, 1 Dec 2017 00:21:02 +0100
4 Subject: [PATCH 02/11] netfilter: core: make nf_unregister_net_hooks simple
7 This reverts commit d3ad2c17b4047
8 ("netfilter: core: batch nf_unregister_net_hooks synchronize_net calls").
10 Nothing wrong with it. However, followup patch will delay freeing of hooks
11 with call_rcu, so all synchronize_net() calls become obsolete and there
12 is no need anymore for this batching.
14 This revert causes a temporary performance degradation when destroying
15 network namespace, but its resolved with the upcoming call_rcu conversion.
17 Signed-off-by: Florian Westphal <fw@strlen.de>
18 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
20 net/netfilter/core.c | 59 +++-------------------------------------------------
21 1 file changed, 3 insertions(+), 56 deletions(-)
23 --- a/net/netfilter/core.c
24 +++ b/net/netfilter/core.c
25 @@ -395,63 +395,10 @@ EXPORT_SYMBOL(nf_register_net_hooks);
26 void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,
27 unsigned int hookcount)
29 - struct nf_hook_entries *to_free[16], *p;
30 - struct nf_hook_entries __rcu **pp;
31 - unsigned int i, j, n;
34 - mutex_lock(&nf_hook_mutex);
35 - for (i = 0; i < hookcount; i++) {
36 - pp = nf_hook_entry_head(net, ®[i]);
40 - p = nf_entry_dereference(*pp);
41 - if (WARN_ON_ONCE(!p))
43 - __nf_unregister_net_hook(p, ®[i]);
45 - mutex_unlock(&nf_hook_mutex);
48 - n = min_t(unsigned int, hookcount, ARRAY_SIZE(to_free));
50 - mutex_lock(&nf_hook_mutex);
52 - for (i = 0, j = 0; i < hookcount && j < n; i++) {
53 - pp = nf_hook_entry_head(net, ®[i]);
57 - p = nf_entry_dereference(*pp);
61 - to_free[j] = __nf_hook_entries_try_shrink(pp);
66 - mutex_unlock(&nf_hook_mutex);
73 - /* need 2nd synchronize_net() if nfqueue is used, skb
74 - * can get reinjected right before nf_queue_hook_drop()
76 - nfq = nf_queue_nf_hook_drop(net);
80 - for (i = 0; i < j; i++)
86 - } while (hookcount > 0);
87 + for (i = 0; i < hookcount; i++)
88 + nf_unregister_net_hook(net, ®[i]);
90 EXPORT_SYMBOL(nf_unregister_net_hooks);