netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: netfilter-devel@vger.kernel.org,
	"Florian Westphal" <fw@strlen.de>,
	"Kadlecsik József" <kadlec@blackhole.kfki.hu>,
	"Eric Garver" <eric@garver.life>, "Phil Sutter" <phil@nwl.cc>
Subject: Re: [PATCH nft v4 3/4] src: Add support for concatenated set ranges
Date: Fri, 7 Feb 2020 11:33:06 +0100	[thread overview]
Message-ID: <20200207103306.r4xweekigdrzojy7@salvia> (raw)
In-Reply-To: <92d2e10dda6dbb8443383606bde835ca1e9da834.1580342294.git.sbrivio@redhat.com>

Applied, thanks. See comments below though.

On Thu, Jan 30, 2020 at 01:16:57AM +0100, Stefano Brivio wrote:
> After exporting field lengths via NFTNL_SET_DESC_CONCAT attributes,
> we now need to adjust parsing of user input and generation of
> netlink key data to complete support for concatenation of set
> ranges.
> 
> Instead of using separate elements for start and end of a range,
> denoting the end element by the NFT_SET_ELEM_INTERVAL_END flag,
> as it's currently done for ranges without concatenation, we'll use
> the new attribute NFTNL_SET_ELEM_KEY_END as suggested by Pablo. It
> behaves in the same way as NFTNL_SET_ELEM_KEY, but it indicates
> that the included key represents the upper bound of a range.
> 
> For example, "packets with an IPv4 address between 192.0.2.0 and
> 192.0.2.42, with destination port between 22 and 25", needs to be
> expressed as a single element with two keys:
> 
>   NFTA_SET_ELEM_KEY:		192.0.2.0 . 22
>   NFTA_SET_ELEM_KEY_END:	192.0.2.42 . 25
> 
> To achieve this, we need to:
> 
> - adjust the lexer rules to allow multiton expressions as elements
>   of a concatenation. As wildcards are not allowed (semantics would
>   be ambiguous), exclude wildcards expressions from the set of
>   possible multiton expressions, and allow them directly where
>   needed. Concatenations now admit prefixes and ranges
> 
> - generate, for each element in a range concatenation, a second key
>   attribute, that includes the upper bound for the range
> 
> - also expand prefixes and non-ranged values in the concatenation
>   to ranges: given a set with interval and concatenation support,
>   the kernel has no way to tell which elements are ranged, so they
>   all need to be. For example, 192.0.2.0 . 192.0.2.9 : 1024 is
>   sent as:
> 
>   NFTA_SET_ELEM_KEY:		192.0.2.0 . 1024
>   NFTA_SET_ELEM_KEY_END:	192.0.2.9 . 1024
> 
> - aggregate ranges when elements received by the kernel represent
>   concatenated ranges, see concat_range_aggregate()

I think concat_range_aggregate() can be remove.

NFTA_SET_ELEM_KEY and the NFTA_SET_ELEM_KEY_END are now coming in the
same element. From the set element delinearization path this could
just build the range, correct?

[...]
> diff --git a/include/rule.h b/include/rule.h
> index a7f106f715cf..c232221e541b 100644
> --- a/include/rule.h
> +++ b/include/rule.h
> @@ -372,6 +372,11 @@ static inline bool set_is_interval(uint32_t set_flags)
>  	return set_flags & NFT_SET_INTERVAL;
>  }
>  
> +static inline bool set_is_non_concat_range(struct set *s)
> +{
> +	return (s->flags & NFT_SET_INTERVAL) && s->desc.field_count <= 1;
> +}

I might make a second pass to revisit this new helper.

Probably, we can pass struct set to all set_is_*() helpers instead,
and use set_is_interval() for the legacy interval representation
that is using the segtree infrastructure.

  reply	other threads:[~2020-02-07 10:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30  0:16 [PATCH nft v4 0/4] Introduce support for concatenated ranges Stefano Brivio
2020-01-30  0:16 ` [PATCH nft v4 1/4] include: resync nf_tables.h cache copy Stefano Brivio
2020-02-07 10:25   ` Pablo Neira Ayuso
2020-01-30  0:16 ` [PATCH nft v4 2/4] src: Add support for NFTNL_SET_DESC_CONCAT Stefano Brivio
2020-02-07 10:25   ` Pablo Neira Ayuso
2020-01-30  0:16 ` [PATCH nft v4 3/4] src: Add support for concatenated set ranges Stefano Brivio
2020-02-07 10:33   ` Pablo Neira Ayuso [this message]
2020-02-10 15:08     ` Stefano Brivio
2020-02-07 11:18   ` Pablo Neira Ayuso
2020-02-10 15:09     ` Stefano Brivio
2020-01-30  0:16 ` [PATCH nft v4 4/4] tests: Introduce test for set with concatenated ranges Stefano Brivio
2020-02-06 10:14   ` Phil Sutter
2020-02-07 10:34   ` Pablo Neira Ayuso
2020-02-10 15:08     ` Stefano Brivio
2020-02-10 15:51       ` Phil Sutter
2020-02-10 16:04       ` Florian Westphal
2020-02-10 16:16         ` Stefano Brivio

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=20200207103306.r4xweekigdrzojy7@salvia \
    --to=pablo@netfilter.org \
    --cc=eric@garver.life \
    --cc=fw@strlen.de \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    --cc=sbrivio@redhat.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).