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: [PATCH nft] src: restore --echo with anonymous sets
Date: Thu, 17 Oct 2019 18:53:20 +0200	[thread overview]
Message-ID: <20191017165320.GM12661@orbyte.nwl.cc> (raw)
In-Reply-To: <20191017133455.17560-1-pablo@netfilter.org>

Hi Pablo,

On Thu, Oct 17, 2019 at 03:34:55PM +0200, Pablo Neira Ayuso wrote:
> If --echo is passed, then the cache already contains the commands that
> have been sent to the kernel. However, anonymous sets are an exception
> since the cache needs to be updated in this case.
> 
> Remove the old cache logic from the monitor code that has been replaced
> by 01e5c6f0ed03 ("src: add cache level flags").
> 
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

This is a nice solution, thanks! A few nits below:

[...]
> diff --git a/src/monitor.c b/src/monitor.c
> index 40c381149cda..b7b00d7b1343 100644
> --- a/src/monitor.c
> +++ b/src/monitor.c
> @@ -609,6 +609,12 @@ static void netlink_events_cache_addset(struct netlink_mon_handler *monh,
>  		goto out;
>  	}
>  
> +	if (nft_output_echo(&monh->ctx->nft->output) &&
> +	    !(s->flags & NFT_SET_ANONYMOUS)) {

There is set_is_anonymous(), set and element printing callbacks use it
as well.

[...]
> @@ -636,6 +642,10 @@ static void netlink_events_cache_addsetelem(struct netlink_mon_handler *monh,
>  		goto out;
>  	}
>  
> +	if (nft_output_echo(&monh->ctx->nft->output) &&
> +	    !(set->flags & NFT_SET_ANONYMOUS))

Same here.

[...]
> @@ -744,7 +754,8 @@ out:
>  static void netlink_events_cache_update(struct netlink_mon_handler *monh,
>  					const struct nlmsghdr *nlh, int type)
>  {
> -	if (!monh->cache_needed)
> +	if (nft_output_echo(&monh->ctx->nft->output) &&
> +	    type != NFT_MSG_NEWSET && type != NFT_MSG_NEWSETELEM)
>  		return;

I would use switch() here, like so:

|	if (nft_output_echo(&monh->ctx->nft->output)) {
|		switch (type) {
|		case NFT_MSG_NEWSET:
|		case NFT_MSG_NEWSETELEM:
|			break;
|		default:
|			return;
|		}
|	}

it emphasises that code is filtering for certain event types. Up to you,
I'm fine with both.

Thanks, Phil

      reply	other threads:[~2019-10-17 16:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 13:34 [PATCH nft] src: restore --echo with anonymous sets Pablo Neira Ayuso
2019-10-17 16:53 ` Phil Sutter [this message]

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=20191017165320.GM12661@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).