netfilter: nf_tables: consolidate tracing invocations
authorPatrick McHardy <kaber@trash.net>
Tue, 3 Mar 2015 20:10:05 +0000 (20:10 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 6 Mar 2015 00:21:12 +0000 (01:21 +0100)
* JUMP and GOTO are equivalent except for JUMP pushing the current
  context to the stack

* RETURN and implicit RETURN (CONTINUE) are equivalent except that
  the logged rule number differs

Result:

  nft_do_chain              | -112
 1 function changed, 112 bytes removed, diff: -112

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_core.c

index 074067d4fc1eb16b048454f43e8b0f37a83e52a7..77165bf023f36754ea717603ea5a28ca51c272ca 100644 (file)
@@ -170,26 +170,23 @@ next_rule:
 
        switch (data[NFT_REG_VERDICT].verdict) {
        case NFT_JUMP:
-               nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RULE);
-
                BUG_ON(stackptr >= NFT_JUMP_STACK_SIZE);
                jumpstack[stackptr].chain = chain;
                jumpstack[stackptr].rule  = rule;
                jumpstack[stackptr].rulenum = rulenum;
                stackptr++;
-               chain = data[NFT_REG_VERDICT].chain;
-               goto do_chain;
+               /* fall through */
        case NFT_GOTO:
                nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RULE);
 
                chain = data[NFT_REG_VERDICT].chain;
                goto do_chain;
+       case NFT_CONTINUE:
+               rulenum++;
+               /* fall through */
        case NFT_RETURN:
                nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RETURN);
                break;
-       case NFT_CONTINUE:
-               nft_trace_packet(pkt, chain, ++rulenum, NFT_TRACE_RETURN);
-               break;
        default:
                WARN_ON(1);
        }