Commit 4c0911566dec7755d15cb89239fb2db4447f7a62
Committed by
Pablo Neira Ayuso
1 parent
70aa996601
netfilter: Simply the tests for enabling and disabling the ingress queue hook
Replace an overcomplicated switch statement with a simple if statement. This also removes the ingress queue enable outside of nf_hook_mutex as the protection provided by the mutex is not necessary and the code is clearer having both of the static key increments together. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Showing 1 changed file with 6 additions and 11 deletions Side-by-side Diff
net/netfilter/core.c
... | ... | @@ -74,7 +74,6 @@ |
74 | 74 | if (reg->hooknum == NF_NETDEV_INGRESS) { |
75 | 75 | BUG_ON(reg->dev == NULL); |
76 | 76 | nf_hook_list = ®->dev->nf_hooks_ingress; |
77 | - net_inc_ingress_queue(); | |
78 | 77 | break; |
79 | 78 | } |
80 | 79 | #endif |
... | ... | @@ -90,6 +89,10 @@ |
90 | 89 | } |
91 | 90 | list_add_rcu(®->list, elem->list.prev); |
92 | 91 | mutex_unlock(&nf_hook_mutex); |
92 | +#ifdef CONFIG_NETFILTER_INGRESS | |
93 | + if (reg->pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) | |
94 | + net_inc_ingress_queue(); | |
95 | +#endif | |
93 | 96 | #ifdef HAVE_JUMP_LABEL |
94 | 97 | static_key_slow_inc(&nf_hooks_needed[reg->pf][reg->hooknum]); |
95 | 98 | #endif |
96 | 99 | |
97 | 100 | |
... | ... | @@ -102,18 +105,10 @@ |
102 | 105 | mutex_lock(&nf_hook_mutex); |
103 | 106 | list_del_rcu(®->list); |
104 | 107 | mutex_unlock(&nf_hook_mutex); |
105 | - switch (reg->pf) { | |
106 | - case NFPROTO_NETDEV: | |
107 | 108 | #ifdef CONFIG_NETFILTER_INGRESS |
108 | - if (reg->hooknum == NF_NETDEV_INGRESS) { | |
109 | - net_dec_ingress_queue(); | |
110 | - break; | |
111 | - } | |
112 | - break; | |
109 | + if (reg->pf == NFPROTO_NETDEV && reg->hooknum == NF_NETDEV_INGRESS) | |
110 | + net_dec_ingress_queue(); | |
113 | 111 | #endif |
114 | - default: | |
115 | - break; | |
116 | - } | |
117 | 112 | #ifdef HAVE_JUMP_LABEL |
118 | 113 | static_key_slow_dec(&nf_hooks_needed[reg->pf][reg->hooknum]); |
119 | 114 | #endif |