Skip to content

Commit d4f6f39

Browse files
Florian Westphalummakynes
Florian Westphal
authored andcommitted
netfilter: nf_tables: avoid usage of embedded nft_ctx
nft_ctx is stored in nft_trans object, but nft_ctx is large (48 bytes on 64-bit platforms), it should not be embedded in the transaction structures. Reduce its usage so we can remove it eventually. This replaces trans->ctx.chain with the chain pointer already available in nft_trans_chain structure. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0c2e0ee commit d4f6f39

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9682,10 +9682,10 @@ static void nf_tables_commit_chain_prepare_cancel(struct net *net)
96829682
struct nft_trans *trans, *next;
96839683

96849684
list_for_each_entry_safe(trans, next, &nft_net->commit_list, list) {
9685-
struct nft_chain *chain = trans->ctx.chain;
9686-
96879685
if (trans->msg_type == NFT_MSG_NEWRULE ||
96889686
trans->msg_type == NFT_MSG_DELRULE) {
9687+
struct nft_chain *chain = trans->ctx.chain;
9688+
96899689
kvfree(chain->blob_next);
96909690
chain->blob_next = NULL;
96919691
}
@@ -10318,7 +10318,7 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
1031810318
/* trans destroyed after rcu grace period */
1031910319
} else {
1032010320
nft_chain_commit_drop_policy(nft_trans_container_chain(trans));
10321-
nft_clear(net, trans->ctx.chain);
10321+
nft_clear(net, nft_trans_chain(trans));
1032210322
nf_tables_chain_notify(&trans->ctx, NFT_MSG_NEWCHAIN, NULL);
1032310323
nft_trans_destroy(trans);
1032410324
}
@@ -10334,11 +10334,11 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
1033410334
true);
1033510335
}
1033610336
} else {
10337-
nft_chain_del(trans->ctx.chain);
10337+
nft_chain_del(nft_trans_chain(trans));
1033810338
nf_tables_chain_notify(&trans->ctx, NFT_MSG_DELCHAIN,
1033910339
NULL);
1034010340
nf_tables_unregister_hook(trans->ctx.net, table,
10341-
trans->ctx.chain);
10341+
nft_trans_chain(trans));
1034210342
}
1034310343
break;
1034410344
case NFT_MSG_NEWRULE:

net/netfilter/nf_tables_offload.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,18 +518,18 @@ static void nft_flow_rule_offload_abort(struct net *net,
518518

519519
switch (trans->msg_type) {
520520
case NFT_MSG_NEWCHAIN:
521-
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD) ||
521+
if (!(nft_trans_chain(trans)->flags & NFT_CHAIN_HW_OFFLOAD) ||
522522
nft_trans_chain_update(trans))
523523
continue;
524524

525-
err = nft_flow_offload_chain(trans->ctx.chain, NULL,
525+
err = nft_flow_offload_chain(nft_trans_chain(trans), NULL,
526526
FLOW_BLOCK_UNBIND);
527527
break;
528528
case NFT_MSG_DELCHAIN:
529-
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
529+
if (!(nft_trans_chain(trans)->flags & NFT_CHAIN_HW_OFFLOAD))
530530
continue;
531531

532-
err = nft_flow_offload_chain(trans->ctx.chain, NULL,
532+
err = nft_flow_offload_chain(nft_trans_chain(trans), NULL,
533533
FLOW_BLOCK_BIND);
534534
break;
535535
case NFT_MSG_NEWRULE:
@@ -569,20 +569,20 @@ int nft_flow_rule_offload_commit(struct net *net)
569569

570570
switch (trans->msg_type) {
571571
case NFT_MSG_NEWCHAIN:
572-
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD) ||
572+
if (!(nft_trans_chain(trans)->flags & NFT_CHAIN_HW_OFFLOAD) ||
573573
nft_trans_chain_update(trans))
574574
continue;
575575

576576
policy = nft_trans_chain_policy(trans);
577-
err = nft_flow_offload_chain(trans->ctx.chain, &policy,
577+
err = nft_flow_offload_chain(nft_trans_chain(trans), &policy,
578578
FLOW_BLOCK_BIND);
579579
break;
580580
case NFT_MSG_DELCHAIN:
581-
if (!(trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD))
581+
if (!(nft_trans_chain(trans)->flags & NFT_CHAIN_HW_OFFLOAD))
582582
continue;
583583

584584
policy = nft_trans_chain_policy(trans);
585-
err = nft_flow_offload_chain(trans->ctx.chain, &policy,
585+
err = nft_flow_offload_chain(nft_trans_chain(trans), &policy,
586586
FLOW_BLOCK_UNBIND);
587587
break;
588588
case NFT_MSG_NEWRULE:

0 commit comments

Comments
 (0)