aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-03-30 08:04:53 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2014-05-19 06:06:11 -0400
commite1aaca93ee66de5b4c92c7c7f3c9722d90852729 (patch)
treea930619904026aaf484200f0081a4aae3060554b /net/netfilter
parentf75edf5e9c9773cf6d0bd9b8d50ead41b4984569 (diff)
netfilter: nf_tables: pass context to nf_tables_updtable()
So nf_tables_uptable() only takes one single parameter. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/nf_tables_api.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5f717032b2a5..d71125a0a341 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -393,36 +393,34 @@ static void nf_tables_table_disable(const struct nft_af_info *afi,
393 } 393 }
394} 394}
395 395
396static int nf_tables_updtable(struct sock *nlsk, struct sk_buff *skb, 396static int nf_tables_updtable(struct nft_ctx *ctx)
397 const struct nlmsghdr *nlh,
398 const struct nlattr * const nla[],
399 struct nft_af_info *afi, struct nft_table *table)
400{ 397{
401 const struct nfgenmsg *nfmsg = nlmsg_data(nlh); 398 const struct nfgenmsg *nfmsg = nlmsg_data(ctx->nlh);
402 int family = nfmsg->nfgen_family, ret = 0; 399 int family = nfmsg->nfgen_family, ret = 0;
400 u32 flags;
403 401
404 if (nla[NFTA_TABLE_FLAGS]) { 402 if (!ctx->nla[NFTA_TABLE_FLAGS])
405 u32 flags; 403 return 0;
406 404
407 flags = ntohl(nla_get_be32(nla[NFTA_TABLE_FLAGS])); 405 flags = ntohl(nla_get_be32(ctx->nla[NFTA_TABLE_FLAGS]));
408 if (flags & ~NFT_TABLE_F_DORMANT) 406 if (flags & ~NFT_TABLE_F_DORMANT)
409 return -EINVAL; 407 return -EINVAL;
410 408
411 if ((flags & NFT_TABLE_F_DORMANT) && 409 if ((flags & NFT_TABLE_F_DORMANT) &&
412 !(table->flags & NFT_TABLE_F_DORMANT)) { 410 !(ctx->table->flags & NFT_TABLE_F_DORMANT)) {
413 nf_tables_table_disable(afi, table); 411 nf_tables_table_disable(ctx->afi, ctx->table);
414 table->flags |= NFT_TABLE_F_DORMANT; 412 ctx->table->flags |= NFT_TABLE_F_DORMANT;
415 } else if (!(flags & NFT_TABLE_F_DORMANT) && 413 } else if (!(flags & NFT_TABLE_F_DORMANT) &&
416 table->flags & NFT_TABLE_F_DORMANT) { 414 ctx->table->flags & NFT_TABLE_F_DORMANT) {
417 ret = nf_tables_table_enable(afi, table); 415 ret = nf_tables_table_enable(ctx->afi, ctx->table);
418 if (ret >= 0) 416 if (ret >= 0)
419 table->flags &= ~NFT_TABLE_F_DORMANT; 417 ctx->table->flags &= ~NFT_TABLE_F_DORMANT;
420 } 418 }
421 if (ret < 0) 419 if (ret < 0)
422 goto err; 420 goto err;
423 }
424 421
425 nf_tables_table_notify(skb, nlh, table, NFT_MSG_NEWTABLE, family); 422 nf_tables_table_notify(ctx->skb, ctx->nlh, ctx->table,
423 NFT_MSG_NEWTABLE, family);
426err: 424err:
427 return ret; 425 return ret;
428} 426}
@@ -438,6 +436,7 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb,
438 struct net *net = sock_net(skb->sk); 436 struct net *net = sock_net(skb->sk);
439 int family = nfmsg->nfgen_family; 437 int family = nfmsg->nfgen_family;
440 u32 flags = 0; 438 u32 flags = 0;
439 struct nft_ctx ctx;
441 440
442 afi = nf_tables_afinfo_lookup(net, family, true); 441 afi = nf_tables_afinfo_lookup(net, family, true);
443 if (IS_ERR(afi)) 442 if (IS_ERR(afi))
@@ -456,7 +455,9 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb,
456 return -EEXIST; 455 return -EEXIST;
457 if (nlh->nlmsg_flags & NLM_F_REPLACE) 456 if (nlh->nlmsg_flags & NLM_F_REPLACE)
458 return -EOPNOTSUPP; 457 return -EOPNOTSUPP;
459 return nf_tables_updtable(nlsk, skb, nlh, nla, afi, table); 458
459 nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla);
460 return nf_tables_updtable(&ctx);
460 } 461 }
461 462
462 if (nla[NFTA_TABLE_FLAGS]) { 463 if (nla[NFTA_TABLE_FLAGS]) {