Skip to content

Commit c63cbc4

Browse files
committed
netfilter: use switch() to handle verdict cases from nf_hook_slow()
Use switch() for verdict handling and add explicit handling for NF_STOLEN and other non-conventional verdicts. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 0e5a1c7 commit c63cbc4

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎net/netfilter/core.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,22 +328,32 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state)
328328
{
329329
struct nf_hook_entry *entry;
330330
unsigned int verdict;
331-
int ret = 0;
331+
int ret;
332332

333333
entry = rcu_dereference(state->hook_entries);
334334
next_hook:
335335
verdict = nf_iterate(skb, state, &entry);
336-
if (verdict == NF_ACCEPT) {
336+
switch (verdict & NF_VERDICT_MASK) {
337+
case NF_ACCEPT:
337338
ret = 1;
338-
} else if ((verdict & NF_VERDICT_MASK) == NF_DROP) {
339+
break;
340+
case NF_DROP:
339341
kfree_skb(skb);
340342
ret = NF_DROP_GETERR(verdict);
341343
if (ret == 0)
342344
ret = -EPERM;
343-
} else if ((verdict & NF_VERDICT_MASK) == NF_QUEUE) {
345+
break;
346+
case NF_QUEUE:
344347
ret = nf_queue(skb, state, &entry, verdict);
345348
if (ret == 1 && entry)
346349
goto next_hook;
350+
/* Fall through. */
351+
default:
352+
/* Implicit handling for NF_STOLEN, as well as any other non
353+
* conventional verdicts.
354+
*/
355+
ret = 0;
356+
break;
347357
}
348358
return ret;
349359
}

0 commit comments

Comments
 (0)