@@ -1253,10 +1253,11 @@ static int nf_tables_newexpr(const struct nft_ctx *ctx,
12531253 return err ;
12541254}
12551255
1256- static void nf_tables_expr_destroy (struct nft_expr * expr )
1256+ static void nf_tables_expr_destroy (const struct nft_ctx * ctx ,
1257+ struct nft_expr * expr )
12571258{
12581259 if (expr -> ops -> destroy )
1259- expr -> ops -> destroy (expr );
1260+ expr -> ops -> destroy (ctx , expr );
12601261 module_put (expr -> ops -> type -> owner );
12611262}
12621263
@@ -1536,7 +1537,8 @@ static int nf_tables_getrule(struct sock *nlsk, struct sk_buff *skb,
15361537 return err ;
15371538}
15381539
1539- static void nf_tables_rule_destroy (struct nft_rule * rule )
1540+ static void nf_tables_rule_destroy (const struct nft_ctx * ctx ,
1541+ struct nft_rule * rule )
15401542{
15411543 struct nft_expr * expr ;
15421544
@@ -1546,7 +1548,7 @@ static void nf_tables_rule_destroy(struct nft_rule *rule)
15461548 */
15471549 expr = nft_expr_first (rule );
15481550 while (expr -> ops && expr != nft_expr_last (rule )) {
1549- nf_tables_expr_destroy (expr );
1551+ nf_tables_expr_destroy (ctx , expr );
15501552 expr = nft_expr_next (expr );
15511553 }
15521554 kfree (rule );
@@ -1565,11 +1567,8 @@ nf_tables_trans_add(struct nft_ctx *ctx, struct nft_rule *rule)
15651567 if (rupd == NULL )
15661568 return NULL ;
15671569
1568- rupd -> chain = ctx -> chain ;
1569- rupd -> table = ctx -> table ;
1570+ rupd -> ctx = * ctx ;
15701571 rupd -> rule = rule ;
1571- rupd -> family = ctx -> afi -> family ;
1572- rupd -> nlh = ctx -> nlh ;
15731572 list_add_tail (& rupd -> list , & ctx -> net -> nft .commit_list );
15741573
15751574 return rupd ;
@@ -1721,7 +1720,7 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
17211720 kfree (repl );
17221721 }
17231722err2 :
1724- nf_tables_rule_destroy (rule );
1723+ nf_tables_rule_destroy (& ctx , rule );
17251724err1 :
17261725 for (i = 0 ; i < n ; i ++ ) {
17271726 if (info [i ].ops != NULL )
@@ -1831,28 +1830,29 @@ static int nf_tables_commit(struct sk_buff *skb)
18311830 */
18321831 if (nft_rule_is_active (net , rupd -> rule )) {
18331832 nft_rule_clear (net , rupd -> rule );
1834- nf_tables_rule_notify (skb , rupd -> nlh , rupd -> table ,
1835- rupd -> chain , rupd -> rule ,
1836- NFT_MSG_NEWRULE , 0 ,
1837- rupd -> family );
1833+ nf_tables_rule_notify (skb , rupd -> ctx . nlh ,
1834+ rupd -> ctx . table , rupd -> ctx . chain ,
1835+ rupd -> rule , NFT_MSG_NEWRULE , 0 ,
1836+ rupd -> ctx . afi -> family );
18381837 list_del (& rupd -> list );
18391838 kfree (rupd );
18401839 continue ;
18411840 }
18421841
18431842 /* This rule is in the past, get rid of it */
18441843 list_del_rcu (& rupd -> rule -> list );
1845- nf_tables_rule_notify (skb , rupd -> nlh , rupd -> table , rupd -> chain ,
1844+ nf_tables_rule_notify (skb , rupd -> ctx .nlh ,
1845+ rupd -> ctx .table , rupd -> ctx .chain ,
18461846 rupd -> rule , NFT_MSG_DELRULE , 0 ,
1847- rupd -> family );
1847+ rupd -> ctx . afi -> family );
18481848 }
18491849
18501850 /* Make sure we don't see any packet traversing old rules */
18511851 synchronize_rcu ();
18521852
18531853 /* Now we can safely release unused old rules */
18541854 list_for_each_entry_safe (rupd , tmp , & net -> nft .commit_list , list ) {
1855- nf_tables_rule_destroy (rupd -> rule );
1855+ nf_tables_rule_destroy (& rupd -> ctx , rupd -> rule );
18561856 list_del (& rupd -> list );
18571857 kfree (rupd );
18581858 }
@@ -1881,7 +1881,7 @@ static int nf_tables_abort(struct sk_buff *skb)
18811881 synchronize_rcu ();
18821882
18831883 list_for_each_entry_safe (rupd , tmp , & net -> nft .commit_list , list ) {
1884- nf_tables_rule_destroy (rupd -> rule );
1884+ nf_tables_rule_destroy (& rupd -> ctx , rupd -> rule );
18851885 list_del (& rupd -> list );
18861886 kfree (rupd );
18871887 }
0 commit comments