All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: Laura Garcia <nevola@gmail.com>,
	netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: What is 'dynamic' set flag supposed to mean?
Date: Thu, 19 Sep 2019 15:28:28 +0200	[thread overview]
Message-ID: <20190919132828.nydpzdt3qqupgtg5@salvia> (raw)
In-Reply-To: <20190919115636.GQ6961@breakpoint.cc>

On Thu, Sep 19, 2019 at 01:56:36PM +0200, Florian Westphal wrote:
[...]
> My conclusion is that meters are anon sets with expressions attached to them.
> So, I don't think they should be deprecated.

At least, meters with names should be I think. There is now a way to
represent them 

> I would propose to:
> 
> 1. add this kernel patch:
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3562,8 +3562,11 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,
>  			      NFT_SET_OBJECT))
>  			return -EINVAL;
>  		/* Only one of these operations is supported */
> -		if ((flags & (NFT_SET_MAP | NFT_SET_EVAL | NFT_SET_OBJECT)) ==
> -			     (NFT_SET_MAP | NFT_SET_EVAL | NFT_SET_OBJECT))
> +		if ((flags & (NFT_SET_MAP | NFT_SET_OBJECT)) ==
> +			     (NFT_SET_MAP | NFT_SET_OBJECT))

That's fine by now. But look, combining map and objects should be fine
in the future. A user might want to combine this by specifying an IP
address as the right hand side of a mapping and a stateful counter
(with a name) to be updated when matching on that element. This is not
supported yet though.

> +			return -EOPNOTSUPP;
> +		if ((flags & (NFT_SET_EVAL | NFT_SET_OBJECT)) ==
> +			     (NFT_SET_EVAL | NFT_SET_OBJECT))

This looks fine.

>  			return -EOPNOTSUPP;
>  	}
>  
> diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
> --- a/net/netfilter/nft_lookup.c
> +++ b/net/netfilter/nft_lookup.c
> @@ -73,9 +73,6 @@ static int nft_lookup_init(const struct nft_ctx *ctx,
>  	if (IS_ERR(set))
>  		return PTR_ERR(set);
>  
> -	if (set->flags & NFT_SET_EVAL)
> -		return -EOPNOTSUPP;
> -
>  	priv->sreg = nft_parse_register(tb[NFTA_LOOKUP_SREG]);
>  	err = nft_validate_register_load(priv->sreg, set->klen);
>  	if (err < 0)
> 
> 2. avoid depreaction of 'meter', since thats what is documented everywhere
>    and appears to work fine

OK, but only for anonymous meters.

We have a better way, more aligned to set/map definitions, to represent
updates to dynamic named sets from the packet path now.

We can probably introduce a syntax more aligned to the existing
set/map syntax for the _anonymous_ dynamic set/map case, so we don't
need this 'meter' keyword syntactic sugar.

> 3. patch nft to hide normal sets from 'nft list meters' output

This makes no sense for anonymous meters. Since the kernel picks the
name, I don't think nft should expose them to the user.

> What to do with dynamic, I fear we have to remove it, i.e. just ignore
> the "dynamic" flag when talking to the kernel.  Otherwise sets using dynamic flag
> will only work on future/very recent kernels.

I would not go that path.

You are just hitting a limitation on the existing implementation.
People cannot make lookups on a dynamic set on existing kernels,
that's all.

There is no NFT_SET_EXPR support for nft_lookup either, is this a bug?
This infrastructure is just incomplete and just need to be finished.

There is no way to combine NFT_SET_MAP with NFT_SET_OBJ, but that is
also artificial, this is just happening again because the code is
incomplete and needs an extension.

  reply	other threads:[~2019-09-19 13:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 11:53 What is 'dynamic' set flag supposed to mean? Florian Westphal
2019-09-18 14:10 ` Laura Garcia
2019-09-18 14:42   ` Florian Westphal
2019-09-19  8:43     ` Pablo Neira Ayuso
2019-09-19  9:24       ` Florian Westphal
2019-09-19  9:40         ` Pablo Neira Ayuso
2019-09-19 10:03           ` Florian Westphal
2019-09-19 11:52             ` Pablo Neira Ayuso
2019-09-19 11:56             ` Florian Westphal
2019-09-19 13:28               ` Pablo Neira Ayuso [this message]
2019-09-19 14:01                 ` Florian Westphal
2019-09-19 14:22                   ` Pablo Neira Ayuso
2019-09-19 14:34                     ` Florian Westphal
2019-09-19 14:55                       ` 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=20190919132828.nydpzdt3qqupgtg5@salvia \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nevola@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.