aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-03-07 13:08:30 -0500
committerPablo Neira Ayuso <pablo@netfilter.org>2014-03-08 06:35:17 -0500
commit62472bcefb56ae9c3a6be3284949ce758656cdec (patch)
tree647c311d780fef18e125005b7eb833002ca599f9 /net/netfilter
parenta36e901cf60d4e9a1882d2a98b1a9c60e84aff2c (diff)
netfilter: nf_tables: restore context for expression destructors
In order to fix set destruction notifications and get rid of unnecessary members in private data structures, pass the context to expressions' destructor functions again. In order to do so, replace various members in the nft_rule_trans structure by the full context. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_tables_api.c34
-rw-r--r--net/netfilter/nft_compat.c4
-rw-r--r--net/netfilter/nft_ct.c3
-rw-r--r--net/netfilter/nft_immediate.c3
-rw-r--r--net/netfilter/nft_log.c3
-rw-r--r--net/netfilter/nft_lookup.c3
6 files changed, 27 insertions, 23 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 611afc0cf2d5..2c10c3fe78c3 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1253,10 +1253,11 @@ err1:
1253 return err; 1253 return err;
1254} 1254}
1255 1255
1256static void nf_tables_expr_destroy(struct nft_expr *expr) 1256static void nf_tables_expr_destroy(const struct nft_ctx *ctx,
1257 struct nft_expr *expr)
1257{ 1258{
1258 if (expr->ops->destroy) 1259 if (expr->ops->destroy)
1259 expr->ops->destroy(expr); 1260 expr->ops->destroy(ctx, expr);
1260 module_put(expr->ops->type->owner); 1261 module_put(expr->ops->type->owner);
1261} 1262}
1262 1263
@@ -1536,7 +1537,8 @@ err:
1536 return err; 1537 return err;
1537} 1538}
1538 1539
1539static void nf_tables_rule_destroy(struct nft_rule *rule) 1540static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
1541 struct nft_rule *rule)
1540{ 1542{
1541 struct nft_expr *expr; 1543 struct nft_expr *expr;
1542 1544
@@ -1546,7 +1548,7 @@ static void nf_tables_rule_destroy(struct nft_rule *rule)
1546 */ 1548 */
1547 expr = nft_expr_first(rule); 1549 expr = nft_expr_first(rule);
1548 while (expr->ops && expr != nft_expr_last(rule)) { 1550 while (expr->ops && expr != nft_expr_last(rule)) {
1549 nf_tables_expr_destroy(expr); 1551 nf_tables_expr_destroy(ctx, expr);
1550 expr = nft_expr_next(expr); 1552 expr = nft_expr_next(expr);
1551 } 1553 }
1552 kfree(rule); 1554 kfree(rule);
@@ -1565,11 +1567,8 @@ nf_tables_trans_add(struct nft_ctx *ctx, struct nft_rule *rule)
1565 if (rupd == NULL) 1567 if (rupd == NULL)
1566 return NULL; 1568 return NULL;
1567 1569
1568 rupd->chain = ctx->chain; 1570 rupd->ctx = *ctx;
1569 rupd->table = ctx->table;
1570 rupd->rule = rule; 1571 rupd->rule = rule;
1571 rupd->family = ctx->afi->family;
1572 rupd->nlh = ctx->nlh;
1573 list_add_tail(&rupd->list, &ctx->net->nft.commit_list); 1572 list_add_tail(&rupd->list, &ctx->net->nft.commit_list);
1574 1573
1575 return rupd; 1574 return rupd;
@@ -1721,7 +1720,7 @@ err3:
1721 kfree(repl); 1720 kfree(repl);
1722 } 1721 }
1723err2: 1722err2:
1724 nf_tables_rule_destroy(rule); 1723 nf_tables_rule_destroy(&ctx, rule);
1725err1: 1724err1:
1726 for (i = 0; i < n; i++) { 1725 for (i = 0; i < n; i++) {
1727 if (info[i].ops != NULL) 1726 if (info[i].ops != NULL)
@@ -1831,10 +1830,10 @@ static int nf_tables_commit(struct sk_buff *skb)
1831 */ 1830 */
1832 if (nft_rule_is_active(net, rupd->rule)) { 1831 if (nft_rule_is_active(net, rupd->rule)) {
1833 nft_rule_clear(net, rupd->rule); 1832 nft_rule_clear(net, rupd->rule);
1834 nf_tables_rule_notify(skb, rupd->nlh, rupd->table, 1833 nf_tables_rule_notify(skb, rupd->ctx.nlh,
1835 rupd->chain, rupd->rule, 1834 rupd->ctx.table, rupd->ctx.chain,
1836 NFT_MSG_NEWRULE, 0, 1835 rupd->rule, NFT_MSG_NEWRULE, 0,
1837 rupd->family); 1836 rupd->ctx.afi->family);
1838 list_del(&rupd->list); 1837 list_del(&rupd->list);
1839 kfree(rupd); 1838 kfree(rupd);
1840 continue; 1839 continue;
@@ -1842,9 +1841,10 @@ static int nf_tables_commit(struct sk_buff *skb)
1842 1841
1843 /* This rule is in the past, get rid of it */ 1842 /* This rule is in the past, get rid of it */
1844 list_del_rcu(&rupd->rule->list); 1843 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,
1846 rupd->rule, NFT_MSG_DELRULE, 0, 1846 rupd->rule, NFT_MSG_DELRULE, 0,
1847 rupd->family); 1847 rupd->ctx.afi->family);
1848 } 1848 }
1849 1849
1850 /* Make sure we don't see any packet traversing old rules */ 1850 /* Make sure we don't see any packet traversing old rules */
@@ -1852,7 +1852,7 @@ static int nf_tables_commit(struct sk_buff *skb)
1852 1852
1853 /* Now we can safely release unused old rules */ 1853 /* Now we can safely release unused old rules */
1854 list_for_each_entry_safe(rupd, tmp, &net->nft.commit_list, list) { 1854 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);
1856 list_del(&rupd->list); 1856 list_del(&rupd->list);
1857 kfree(rupd); 1857 kfree(rupd);
1858 } 1858 }
@@ -1881,7 +1881,7 @@ static int nf_tables_abort(struct sk_buff *skb)
1881 synchronize_rcu(); 1881 synchronize_rcu();
1882 1882
1883 list_for_each_entry_safe(rupd, tmp, &net->nft.commit_list, list) { 1883 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);
1885 list_del(&rupd->list); 1885 list_del(&rupd->list);
1886 kfree(rupd); 1886 kfree(rupd);
1887 } 1887 }
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 82cb8236f8a1..8a779be832fb 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -192,7 +192,7 @@ err:
192} 192}
193 193
194static void 194static void
195nft_target_destroy(const struct nft_expr *expr) 195nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
196{ 196{
197 struct xt_target *target = expr->ops->data; 197 struct xt_target *target = expr->ops->data;
198 198
@@ -379,7 +379,7 @@ err:
379} 379}
380 380
381static void 381static void
382nft_match_destroy(const struct nft_expr *expr) 382nft_match_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
383{ 383{
384 struct xt_match *match = expr->ops->data; 384 struct xt_match *match = expr->ops->data;
385 385
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index e59b08f9ccbd..65a2c7b6a7a0 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -321,7 +321,8 @@ static int nft_ct_init(const struct nft_ctx *ctx,
321 return 0; 321 return 0;
322} 322}
323 323
324static void nft_ct_destroy(const struct nft_expr *expr) 324static void nft_ct_destroy(const struct nft_ctx *ctx,
325 const struct nft_expr *expr)
325{ 326{
326 struct nft_ct *priv = nft_expr_priv(expr); 327 struct nft_ct *priv = nft_expr_priv(expr);
327 328
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index f169501f1ad4..810385eb7249 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.c
@@ -70,7 +70,8 @@ err1:
70 return err; 70 return err;
71} 71}
72 72
73static void nft_immediate_destroy(const struct nft_expr *expr) 73static void nft_immediate_destroy(const struct nft_ctx *ctx,
74 const struct nft_expr *expr)
74{ 75{
75 const struct nft_immediate_expr *priv = nft_expr_priv(expr); 76 const struct nft_immediate_expr *priv = nft_expr_priv(expr);
76 return nft_data_uninit(&priv->data, nft_dreg_to_type(priv->dreg)); 77 return nft_data_uninit(&priv->data, nft_dreg_to_type(priv->dreg));
diff --git a/net/netfilter/nft_log.c b/net/netfilter/nft_log.c
index 26c5154e05f3..10cfb156cdf4 100644
--- a/net/netfilter/nft_log.c
+++ b/net/netfilter/nft_log.c
@@ -74,7 +74,8 @@ static int nft_log_init(const struct nft_ctx *ctx,
74 return 0; 74 return 0;
75} 75}
76 76
77static void nft_log_destroy(const struct nft_expr *expr) 77static void nft_log_destroy(const struct nft_ctx *ctx,
78 const struct nft_expr *expr)
78{ 79{
79 struct nft_log *priv = nft_expr_priv(expr); 80 struct nft_log *priv = nft_expr_priv(expr);
80 81
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index bb4ef4cccb6e..953978e8f0ba 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -89,7 +89,8 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
89 return 0; 89 return 0;
90} 90}
91 91
92static void nft_lookup_destroy(const struct nft_expr *expr) 92static void nft_lookup_destroy(const struct nft_ctx *ctx,
93 const struct nft_expr *expr)
93{ 94{
94 struct nft_lookup *priv = nft_expr_priv(expr); 95 struct nft_lookup *priv = nft_expr_priv(expr);
95 96