]> git.itanic.dy.fi Git - linux-stable/commitdiff
netfilter: nf_tables: remove unneeded conditional
authorFlorian Westphal <fw@strlen.de>
Fri, 14 Apr 2023 13:01:31 +0000 (15:01 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 21 Apr 2023 23:39:41 +0000 (01:39 +0200)
This helper is inlined, so keep it as small as possible.

If the static key is true, there is only a very small chance
that info->trace is false:

1. tracing was enabled at this very moment, the static key was
   updated to active right after nft_do_table was called.

2. tracing was disabled at this very moment.
   trace->info is already false, the static key is about to
   be patched to false soon.

In both cases, no event will be sent because info->trace
is false (checked in noinline slowpath). info->nf_trace is irrelevant.

The nf_trace update is redunant in this case, but this will only
happen for short duration, when static key flips.

       text  data   bss   dec   hex filename
old:   2980   192    32  3204   c84 nf_tables_core.o
new:   2964   192    32  3188   c74i nf_tables_core.o

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_core.c

index 89c05b64c2a25e96a8f420fd58c895139196a283..bed855638050e4c4b99d88e774541d59d59c1704 100644 (file)
@@ -67,10 +67,8 @@ static inline void nft_trace_packet(const struct nft_pktinfo *pkt,
 static inline void nft_trace_copy_nftrace(const struct nft_pktinfo *pkt,
                                          struct nft_traceinfo *info)
 {
-       if (static_branch_unlikely(&nft_trace_enabled)) {
-               if (info->trace)
-                       info->nf_trace = pkt->skb->nf_trace;
-       }
+       if (static_branch_unlikely(&nft_trace_enabled))
+               info->nf_trace = pkt->skb->nf_trace;
 }
 
 static void nft_bitwise_fast_eval(const struct nft_expr *expr,