netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, phil@nwl.cc
Subject: Re: [PATCH] monitor: fix printing of range elements in named sets
Date: Mon, 17 Jul 2017 18:26:59 +0200	[thread overview]
Message-ID: <20170717162659.GA1162@salvia> (raw)
In-Reply-To: <149935174634.19966.16018870027671610502.stgit@nfdev2.cica.es>

Hi Arturo,

On Thu, Jul 06, 2017 at 04:36:45PM +0200, Arturo Borrero Gonzalez wrote:
> If you add set elements to interval sets, the output is wrong.
> Fix this by caching first element of the range (first event),
> then wait for the second element of the range (second event) to
> print them both at the same time.
> 
> We also avoid printing the first null element required in the RB tree.
> 
> Before this patch:
> 
> % nft add element t s {10-20, 30-40}
> add element ip t s { 0 }
> add element ip t s { 10 }
> add element ip t s { ftp }
> add element ip t s { 30 }
> add element ip t s { 41 }
> 
> After this patch:
> 
> % nft add element t s {10-20, 30-40}
> add element ip t s { 10-20 }
> add element ip t s { 30-40 }
> 
> CC: Phil Sutter <phil@nwl.cc>
> Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
> ---
> 
> This was discussed during Netfilter Workshop 2017 in Faro, Portugal.
> I think Phil has another patch to address this issue from a different
> approach.

I like this approach, it's simple. Still you mentioned it doesn't work
for several cases. One of them are deletions.

Also Phil has found a number of corner cases that still need special
handling, problems are:

1) nft flush set gets elements in reverse order, we can probably fix
   this from the kernel (flush set support is quite recent). Or just
   use the mergesort function to get them sorted out from userspace.

2) Half-open ranges, it's just a single element with the end flag
   interval set on, in such case, we just print what we have.

Anything else?

There's a list of threads discussing this split in several patches,
it's making it a bit hard to follow you guys ;-).

>  include/rule.h |    2 ++
>  src/netlink.c  |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/include/rule.h b/include/rule.h
> index 7424b21..1b44e4c 100644
> --- a/include/rule.h
> +++ b/include/rule.h
> @@ -217,6 +217,7 @@ extern struct rule *rule_lookup(const struct chain *chain, uint64_t handle);
>   * @datalen:	mapping data len
>   * @objtype:	mapping object type
>   * @init:	initializer
> + * @rg_cache:	cached range element (left)
>   * @policy:	set mechanism policy
>   * @desc:	set mechanism desc
>   */
> @@ -234,6 +235,7 @@ struct set {
>  	unsigned int		datalen;
>  	uint32_t		objtype;
>  	struct expr		*init;
> +	struct expr		*rg_cache;

Why not just add this element to the set, instead of caching it here
in this new field? I mean, place it in set->init?

>  	uint32_t		policy;
>  	struct {
>  		uint32_t	size;

      parent reply	other threads:[~2017-07-17 16:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06 14:36 [PATCH] monitor: fix printing of range elements in named sets Arturo Borrero Gonzalez
2017-07-11 18:11 ` Phil Sutter
2017-07-12 11:24   ` Arturo Borrero Gonzalez
2017-07-12 12:13     ` Phil Sutter
2017-07-17 16:26 ` Pablo Neira Ayuso [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=20170717162659.GA1162@salvia \
    --to=pablo@netfilter.org \
    --cc=arturo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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).