aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/netfilter/nf_tables.h4
-rw-r--r--net/netfilter/nf_tables_api.c2
-rw-r--r--net/netfilter/nf_tables_core.c3
3 files changed, 5 insertions, 4 deletions
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index d756af559977..ace67a549b30 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -449,7 +449,6 @@ enum nft_chain_flags {
449 * 449 *
450 * @rules: list of rules in the chain 450 * @rules: list of rules in the chain
451 * @list: used internally 451 * @list: used internally
452 * @net: net namespace that this chain belongs to
453 * @table: table that this chain belongs to 452 * @table: table that this chain belongs to
454 * @handle: chain handle 453 * @handle: chain handle
455 * @use: number of jump references to this chain 454 * @use: number of jump references to this chain
@@ -460,7 +459,6 @@ enum nft_chain_flags {
460struct nft_chain { 459struct nft_chain {
461 struct list_head rules; 460 struct list_head rules;
462 struct list_head list; 461 struct list_head list;
463 struct net *net;
464 struct nft_table *table; 462 struct nft_table *table;
465 u64 handle; 463 u64 handle;
466 u32 use; 464 u32 use;
@@ -512,6 +510,7 @@ struct nft_stats {
512 * struct nft_base_chain - nf_tables base chain 510 * struct nft_base_chain - nf_tables base chain
513 * 511 *
514 * @ops: netfilter hook ops 512 * @ops: netfilter hook ops
513 * @pnet: net namespace that this chain belongs to
515 * @type: chain type 514 * @type: chain type
516 * @policy: default policy 515 * @policy: default policy
517 * @stats: per-cpu chain stats 516 * @stats: per-cpu chain stats
@@ -519,6 +518,7 @@ struct nft_stats {
519 */ 518 */
520struct nft_base_chain { 519struct nft_base_chain {
521 struct nf_hook_ops ops[NFT_HOOK_OPS_MAX]; 520 struct nf_hook_ops ops[NFT_HOOK_OPS_MAX];
521 possible_net_t pnet;
522 const struct nf_chain_type *type; 522 const struct nf_chain_type *type;
523 u8 policy; 523 u8 policy;
524 struct nft_stats __percpu *stats; 524 struct nft_stats __percpu *stats;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 363a39a6c286..0b969b66cb77 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1354,6 +1354,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
1354 rcu_assign_pointer(basechain->stats, stats); 1354 rcu_assign_pointer(basechain->stats, stats);
1355 } 1355 }
1356 1356
1357 write_pnet(&basechain->pnet, net);
1357 basechain->type = type; 1358 basechain->type = type;
1358 chain = &basechain->chain; 1359 chain = &basechain->chain;
1359 1360
@@ -1381,7 +1382,6 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
1381 1382
1382 INIT_LIST_HEAD(&chain->rules); 1383 INIT_LIST_HEAD(&chain->rules);
1383 chain->handle = nf_tables_alloc_handle(table); 1384 chain->handle = nf_tables_alloc_handle(table);
1384 chain->net = net;
1385 chain->table = table; 1385 chain->table = table;
1386 nla_strlcpy(chain->name, name, NFT_CHAIN_MAXNAMELEN); 1386 nla_strlcpy(chain->name, name, NFT_CHAIN_MAXNAMELEN);
1387 1387
diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index 77165bf023f3..4c921a302cfd 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -112,6 +112,7 @@ unsigned int
112nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops) 112nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops)
113{ 113{
114 const struct nft_chain *chain = ops->priv, *basechain = chain; 114 const struct nft_chain *chain = ops->priv, *basechain = chain;
115 const struct net *net = read_pnet(&nft_base_chain(basechain)->pnet);
115 const struct nft_rule *rule; 116 const struct nft_rule *rule;
116 const struct nft_expr *expr, *last; 117 const struct nft_expr *expr, *last;
117 struct nft_data data[NFT_REG_MAX + 1]; 118 struct nft_data data[NFT_REG_MAX + 1];
@@ -123,7 +124,7 @@ nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops)
123 * Cache cursor to avoid problems in case that the cursor is updated 124 * Cache cursor to avoid problems in case that the cursor is updated
124 * while traversing the ruleset. 125 * while traversing the ruleset.
125 */ 126 */
126 unsigned int gencursor = ACCESS_ONCE(chain->net->nft.gencursor); 127 unsigned int gencursor = ACCESS_ONCE(net->nft.gencursor);
127 128
128do_chain: 129do_chain:
129 rulenum = 0; 130 rulenum = 0;