netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH v3 3/4] Implement --echo option
Date: Wed, 2 Aug 2017 15:45:56 +0200	[thread overview]
Message-ID: <20170802134556.GH16375@orbyte.nwl.cc> (raw)
In-Reply-To: <20170802131804.GA15462@salvia>

On Wed, Aug 02, 2017 at 03:18:04PM +0200, Pablo Neira Ayuso wrote:
> On Wed, Aug 02, 2017 at 02:37:44PM +0200, Pablo Neira Ayuso wrote:
> > On Fri, Jul 28, 2017 at 01:55:47PM +0200, Phil Sutter wrote:
> > [...]
> > > diff --git a/src/netlink.c b/src/netlink.c
> > > index f13dfd3f9a021..35b52a3344f87 100644
> > > --- a/src/netlink.c
> > > +++ b/src/netlink.c
> > > @@ -465,11 +465,11 @@ int netlink_replace_rule_batch(struct netlink_ctx *ctx, const struct handle *h,
> > >  			       const struct location *loc)
> > >  {
> > >  	struct nftnl_rule *nlr;
> > > -	int err;
> > > +	int err, flags = ctx->octx->echo ? NLM_F_ECHO : 0;
> > >  
> > >  	nlr = alloc_nftnl_rule(&rule->handle);
> > >  	netlink_linearize_rule(ctx, nlr, rule);
> > > -	err = mnl_nft_rule_batch_replace(nlr, ctx->batch, 0, ctx->seqnum);
> > > +	err = mnl_nft_rule_batch_replace(nlr, ctx->batch, flags, ctx->seqnum);
> > >  	nftnl_rule_free(nlr);
> > >  
> > >  	if (err < 0)
> > > @@ -2087,6 +2087,8 @@ static int netlink_events_table_cb(const struct nlmsghdr *nlh, int type,
> > >  				printf("update table ");
> > >  			else
> > >  				printf("add table ");
> > > +		} else if (type == -1) {
> > > +			printf("table ");
> > 
> > Why do we need this '-1' case? Same question for other objects.
> 
> This is there just to skip the "add ..." part of the string, right?
> 
> I think this is relevant information. Semantically, this is just
> exposing the netlink NLM_F_ECHO flag, so it should be possible to use
> this flag in the future with 'delete' commands.
> 
> So if this -1 type is there just to skip the "add ...", I would simply
> remove it.

Yes, exactly. This is what I had in mind when I started with this
series, back when it was merely about atomic handle retrieval by
supporting '-a' flag in add/insert/replace commands for rules. Changing
the whole concept into this generic --echo option was your idea. :)

But OK, since most of the original idea is lost now anyway, I can get
rid of this last bit as well.

Cheers, Phil

  reply	other threads:[~2017-08-02 13:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 11:55 [nft PATCH v3 0/4] Implement --echo option Phil Sutter
2017-07-28 11:55 ` [nft PATCH v3 1/4] mnl: Consolidate mnl_batch_talk() parameters Phil Sutter
2017-08-02 12:36   ` Pablo Neira Ayuso
2017-07-28 11:55 ` [nft PATCH v3 2/4] netlink: Pass nlmsg flags from rule.c Phil Sutter
2017-08-02 12:36   ` Pablo Neira Ayuso
2017-08-02 12:58     ` Pablo Neira Ayuso
2017-08-02 13:38       ` Phil Sutter
2017-07-28 11:55 ` [nft PATCH v3 3/4] Implement --echo option Phil Sutter
2017-08-02 12:37   ` Pablo Neira Ayuso
2017-08-02 13:18     ` Pablo Neira Ayuso
2017-08-02 13:45       ` Phil Sutter [this message]
2017-07-28 11:55 ` [nft PATCH v3 4/4] tests: Add a simple test suite for " Phil Sutter

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=20170802134556.GH16375@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).