netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH RFC 1/2] netfilter: nf_tables: move set netlink messages into the batch
Date: Wed, 26 Mar 2014 14:03:38 +0100	[thread overview]
Message-ID: <20140326130338.GA31813@localhost> (raw)
In-Reply-To: <20140326112554.GC452@macbook.localnet>

On Wed, Mar 26, 2014 at 11:25:54AM +0000, Patrick McHardy wrote:
> On Tue, Mar 25, 2014 at 09:39:41PM +0100, Pablo Neira Ayuso wrote:
> > diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
> > index e6bc14d..b749e4d 100644
> > --- a/include/net/netfilter/nf_tables.h
> > +++ b/include/net/netfilter/nf_tables.h
> > @@ -222,6 +222,8 @@ static inline void *nft_set_priv(const struct nft_set *set)
> >  
> >  struct nft_set *nf_tables_set_lookup(const struct nft_table *table,
> >  				     const struct nlattr *nla);
> > +struct nft_set *nf_tables_set_lookup2(const struct net *net,
> > +				      const struct nlattr *nla);
> 
> nf_tables_set_lookup_byid?

That looks better.

> > diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
> > index c88ccbf..3776beb 100644
> > --- a/include/uapi/linux/netfilter/nf_tables.h
> > +++ b/include/uapi/linux/netfilter/nf_tables.h
> > @@ -221,6 +221,7 @@ enum nft_set_flags {
> >   * @NFTA_SET_KEY_LEN: key data length (NLA_U32)
> >   * @NFTA_SET_DATA_TYPE: mapping data type (NLA_U32)
> >   * @NFTA_SET_DATA_LEN: mapping data length (NLA_U32)
> > + * @NFTA_SET_ID: set ID (NLA_U64)
> 
> I think a U32 should be perfectly fine. These are not permanent IDs but just to
> identify new sets contained within a batch, so we can always start at 0.

Yes, I was considering using this also to output the set identifier
for anonymous sets, but the dynamically allocated name should be fine
so I'll stick to u32.

Going back to the idea of using u64 to allocate the set/map names, I
think we have to extend the set name, currently IFNAMSIZ is limited
when mapping the name to set%lld, assuming a large u64 number.

> > +static int nf_tables_set_trans_add(struct list_head *list, struct nft_ctx *ctx,
> > +				   struct nft_set *set)
> > +{
> > +	struct nft_set_trans *strans;
> > +
> > +	strans = kmalloc(sizeof(struct nft_set_trans), GFP_ATOMIC);
> 
> Do we need GFP_ATOMIC?

not really, will swap that to GFP_KERNEL.

> > +	if (strans == NULL)
> > +		return -ENOMEM;
> > +
> > +	strans->set = set;
> > +	strans->ctx = *ctx;
> > +	if (ctx->nla[NFTA_SET_ID])
> > +		strans->id = be64_to_cpu(nla_get_be64(ctx->nla[NFTA_SET_ID]));
> > +
> > +	set->flags |= __NFT_SET_INACTIVE;
> > +	list_add_tail(&strans->list, list);
> > +	return 0;
> > +}
> > +
> >  static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb,
> >  			    const struct nlmsghdr *nlh,
> >  			    const struct nlattr * const nla[])
> >  static int nf_tables_bind_check_setelem(const struct nft_ctx *ctx,
> > @@ -2534,7 +2619,8 @@ void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
> >  {
> >  	list_del(&binding->list);
> >  
> > -	if (list_empty(&set->bindings) && set->flags & NFT_SET_ANONYMOUS)
> > +	if (list_empty(&set->bindings) && set->flags & NFT_SET_ANONYMOUS &&
> > +	    !(set->flags & __NFT_SET_INACTIVE))
> 
> Why are we not destroying anonymous inactive sets when unbinding? This means we're
> either aborting or replaying the entire transaction, so it seems we should remove
> them, no?

The set may be already bound to the rule, we skip this here, so the
set is released from the transaction. This is just to avoid a double
free case.

> >  		nf_tables_set_destroy(ctx, set);
> >  }
> >  

  reply	other threads:[~2014-03-26 13:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 20:39 [PATCH RFC 1/2] netfilter: nf_tables: move set netlink messages into the batch Pablo Neira Ayuso
2014-03-25 20:39 ` [PATCH RFC nft 2/2] src: add set netlink message to " Pablo Neira Ayuso
2014-03-26 11:25 ` [PATCH RFC 1/2] netfilter: nf_tables: move set netlink messages into " Patrick McHardy
2014-03-26 13:03   ` Pablo Neira Ayuso [this message]
2014-03-26 13:18     ` Patrick McHardy
2014-03-26 13:40       ` Pablo Neira Ayuso
2014-03-26 14:00         ` Patrick McHardy
2014-03-26 15:53           ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140326130338.GA31813@localhost \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).