kernel: Copy patches from kernel 4.14 to 4.19
[openwrt/staging/wigyori.git] / target / linux / generic / backport-4.19 / 298-v4.16-netfilter-core-pass-family-as-parameter-to-nf_remove.patch
1 From 30259408118f550f5969fda19c0d67020d21eda8 Mon Sep 17 00:00:00 2001
2 From: Pablo Neira Ayuso <pablo@netfilter.org>
3 Date: Sat, 9 Dec 2017 15:26:37 +0100
4 Subject: [PATCH 10/11] netfilter: core: pass family as parameter to
5 nf_remove_net_hook()
6
7 So static_key_slow_dec applies to the family behind NFPROTO_INET.
8
9 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 ---
11 net/netfilter/core.c | 10 +++++-----
12 1 file changed, 5 insertions(+), 5 deletions(-)
13
14 --- a/net/netfilter/core.c
15 +++ b/net/netfilter/core.c
16 @@ -365,7 +365,7 @@ EXPORT_SYMBOL(nf_register_net_hook);
17 * Therefore replace the to-be-removed hook with a dummy hook.
18 */
19 static void nf_remove_net_hook(struct nf_hook_entries *old,
20 - const struct nf_hook_ops *unreg)
21 + const struct nf_hook_ops *unreg, int pf)
22 {
23 struct nf_hook_ops **orig_ops;
24 bool found = false;
25 @@ -383,14 +383,14 @@ static void nf_remove_net_hook(struct nf
26
27 if (found) {
28 #ifdef CONFIG_NETFILTER_INGRESS
29 - if (unreg->pf == NFPROTO_NETDEV && unreg->hooknum == NF_NETDEV_INGRESS)
30 + if (pf == NFPROTO_NETDEV && unreg->hooknum == NF_NETDEV_INGRESS)
31 net_dec_ingress_queue();
32 #endif
33 #ifdef HAVE_JUMP_LABEL
34 - static_key_slow_dec(&nf_hooks_needed[unreg->pf][unreg->hooknum]);
35 + static_key_slow_dec(&nf_hooks_needed[pf][unreg->hooknum]);
36 #endif
37 } else {
38 - WARN_ONCE(1, "hook not found, pf %d num %d", unreg->pf, unreg->hooknum);
39 + WARN_ONCE(1, "hook not found, pf %d num %d", pf, unreg->hooknum);
40 }
41 }
42
43 @@ -411,7 +411,7 @@ void nf_unregister_net_hook(struct net *
44 return;
45 }
46
47 - nf_remove_net_hook(p, reg);
48 + nf_remove_net_hook(p, reg, reg->pf);
49
50 p = __nf_hook_entries_try_shrink(pp);
51 mutex_unlock(&nf_hook_mutex);