Commit 00924094 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nf_tables: don't assume chain stats are set when jumplabel is set

nft_chain_stats_replace() and all other spots assume ->stats can be
NULL, but nft_update_chain_stats does not.  It must do this check,
just because the jump label is set doesn't mean all basechains have stats
assigned.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent a44f6d82
...@@ -119,15 +119,22 @@ DEFINE_STATIC_KEY_FALSE(nft_counters_enabled); ...@@ -119,15 +119,22 @@ DEFINE_STATIC_KEY_FALSE(nft_counters_enabled);
static noinline void nft_update_chain_stats(const struct nft_chain *chain, static noinline void nft_update_chain_stats(const struct nft_chain *chain,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
{ {
struct nft_base_chain *base_chain;
struct nft_stats *stats; struct nft_stats *stats;
base_chain = nft_base_chain(chain);
if (!base_chain->stats)
return;
stats = this_cpu_ptr(rcu_dereference(base_chain->stats));
if (stats) {
local_bh_disable(); local_bh_disable();
stats = this_cpu_ptr(rcu_dereference(nft_base_chain(chain)->stats));
u64_stats_update_begin(&stats->syncp); u64_stats_update_begin(&stats->syncp);
stats->pkts++; stats->pkts++;
stats->bytes += pkt->skb->len; stats->bytes += pkt->skb->len;
u64_stats_update_end(&stats->syncp); u64_stats_update_end(&stats->syncp);
local_bh_enable(); local_bh_enable();
}
} }
struct nft_jumpstack { struct nft_jumpstack {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment