Skip to content

Commit 67a8fc2

Browse files
kaberummakynes
authored andcommitted
netfilter: nf_tables: add nft_dereference() macro
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 0eb5db7 commit 67a8fc2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/list.h>
55
#include <linux/netfilter.h>
6+
#include <linux/netfilter/nfnetlink.h>
67
#include <linux/netfilter/x_tables.h>
78
#include <linux/netfilter/nf_tables.h>
89
#include <net/netlink.h>
@@ -521,6 +522,9 @@ void nft_unregister_chain_type(const struct nf_chain_type *);
521522
int nft_register_expr(struct nft_expr_type *);
522523
void nft_unregister_expr(struct nft_expr_type *);
523524

525+
#define nft_dereference(p) \
526+
nfnl_dereference(p, NFNL_SUBSYS_NFTABLES)
527+
524528
#define MODULE_ALIAS_NFT_FAMILY(family) \
525529
MODULE_ALIAS("nft-afinfo-" __stringify(family))
526530

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,8 @@ nf_tables_counters(struct nft_base_chain *chain, const struct nlattr *attr)
794794
stats->pkts = be64_to_cpu(nla_get_be64(tb[NFTA_COUNTER_PACKETS]));
795795

796796
if (chain->stats) {
797-
/* nfnl_lock is held, add some nfnl function for this, later */
798797
struct nft_stats __percpu *oldstats =
799-
rcu_dereference_protected(chain->stats, 1);
798+
nft_dereference(chain->stats);
800799

801800
rcu_assign_pointer(chain->stats, newstats);
802801
synchronize_rcu();

0 commit comments

Comments
 (0)