netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Simon Horman <simon.horman@netronome.com>
Cc: netfilter-devel@vger.kernel.org, kaber@trash.net, netdev@vger.kernel.org
Subject: Re: [PATCH 2/3 nf-next] netfilter: nf_tables: allow to bind table to net_device
Date: Tue, 26 May 2015 11:58:24 +0200	[thread overview]
Message-ID: <20150526095824.GB3535@salvia> (raw)
In-Reply-To: <20150526004840.GB23370@vergenet.net>

On Tue, May 26, 2015 at 09:48:41AM +0900, Simon Horman wrote:
> Hi Pablo,
> 
> On Mon, May 25, 2015 at 02:46:41PM +0200, Pablo Neira Ayuso wrote:
> > This patch adds the internal NFT_AF_NEEDS_DEV flag to indicate that you must
> > attach this table to a net_device.
> > 
> > This change is required by the follow up patch that introduces the new netdev
> > table.
> > 
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> >  include/net/netfilter/nf_tables.h        |    8 ++++++
> >  include/uapi/linux/netfilter/nf_tables.h |    2 ++
> >  net/netfilter/nf_tables_api.c            |   46 ++++++++++++++++++++++++++----
> >  3 files changed, 51 insertions(+), 5 deletions(-)
> 
> [snip]
> 
> > diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
> > index 5fa1cd0..89a671e 100644
> > --- a/include/uapi/linux/netfilter/nf_tables.h
> > +++ b/include/uapi/linux/netfilter/nf_tables.h
> 
> [snip]
> 
> > @@ -423,6 +425,10 @@ static int nf_tables_fill_table_info(struct sk_buff *skb, struct net *net,
> >  	    nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use)))
> >  		goto nla_put_failure;
> >  
> > +	if (table->dev &&
> > +	    nla_put_string(skb, NFTA_TABLE_DEV, table->dev->name))
> > +		goto nla_put_failure;
> > +
> >  	nlmsg_end(skb, nlh);
> >  	return 0;
> >  
> > @@ -608,6 +614,11 @@ static int nf_tables_updtable(struct nft_ctx *ctx)
> >  	if (flags == ctx->table->flags)
> >  		return 0;
> >  
> > +	if ((ctx->afi->flags & NFT_AF_NEEDS_DEV) &&
> > +	    ctx->nla[NFTA_TABLE_DEV] &&
> > +	    nla_strcmp(ctx->nla[NFTA_TABLE_DEV], ctx->table->dev->name))
> > +		return -EOPNOTSUPP;
> > +
> >  	trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE,
> >  				sizeof(struct nft_trans_table));
> >  	if (trans == NULL)
> 
> I'm a little unsure of the above logic.
> 
> Is it ok for NFT_AF_NEEDS_DEV to be set but ctx->nla[NFTA_TABLE_DEV] to
> be absent?

This path is only run if the table already exists.

So it basically checks if we're trying to update the binding, in that
case we hit -EOPNOTSUPP.

If we don't pass any NFTA_TABLE_DEV, then we assume we stick to the
existing binding.

This allows us to update the table flags without indicating the
binding, eg.

        nft add table netdev filter { flags dormant\; }

which basically disables the entire table content.

  reply	other threads:[~2015-05-26  9:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 12:46 [PATCH 0/3 nf-next] nf_tables support at ingress Pablo Neira Ayuso
2015-05-25 12:46 ` [PATCH 1/3 nf-next] netfilter: default CONFIG_NETFILTER_INGRESS to y Pablo Neira Ayuso
2015-05-26  0:44   ` Simon Horman
2015-05-26  9:41     ` Pablo Neira Ayuso
2015-05-25 12:46 ` [PATCH 2/3 nf-next] netfilter: nf_tables: allow to bind table to net_device Pablo Neira Ayuso
2015-05-26  0:48   ` Simon Horman
2015-05-26  9:58     ` Pablo Neira Ayuso [this message]
2015-05-27  1:08       ` Simon Horman
2015-05-25 12:46 ` [PATCH 3/3 nf-next] netfilter: nf_tables: add netdev table to filter from ingress Pablo Neira Ayuso
2015-05-25 12:46 ` [PATCH libnftnl] table: add netdev family support Pablo Neira Ayuso
2015-05-25 12:46 ` [PATCH nft] src: " Pablo Neira Ayuso
2015-05-26 16:52   ` Patrick McHardy
2015-05-26 17:17     ` 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=20150526095824.GB3535@salvia \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    /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).