netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: nft typeof keywork patch
Date: Wed, 13 Sep 2017 17:43:18 +0200	[thread overview]
Message-ID: <20170913154318.GA4681@salvia> (raw)
In-Reply-To: <20170913152728.GB2453@breakpoint.cc>

On Wed, Sep 13, 2017 at 05:27:28PM +0200, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Tue, Sep 12, 2017 at 07:25:27PM +0200, Florian Westphal wrote:
> > > I am looking into adding 'string' type for sets.
> > > To do this I'd need to add the typeof command that you mentioned
> > > last year:
> > > https://marc.info/?l=netfilter-devel&m=145683813130409&w=2
> 
> [..]
> 
> > Missing part is to add a UDATA_SET_TYPEOF to store the original
> > datatype. So, we dumping back the ruleset, we get same listing.
> 
> Wait, so
>     nft add set ip filter set1 { typeof ip saddr;}
> 
> then it should not list
>     nft add set ip filter set1 { type ipv4_addr;}
> 
> but the exact input using the typeof()?
> 
> I wonder how to encode this, especially given we also need to support
> concatenation, e.g.
> 
> nft add set ip f s { type ipv4_addr .  typeof meta iifname . typeof tcp dport ;}
> 
> > See UDATA_SET_KEYBYTEORDER and UDATA_SET_DATABYTEORDER for instance.
> 
> They don't need to store a vector.

These UDATA_SET_KEYBYTEORDER and UDATA_SET_DATABYTEORDER should be
split not to store a vector anymore. We should have one
UDATA_SET_KEYBYTEORDERX for each component of the tuple.

> For the above we'd need to store the exact text input string to rebuild
> cmdline.
> 
> I think this needs to store something like this in the kernel:
> ":4-meta iifname:16-tcp dport:2'.
> 
> and nft needs to chew through this to learn the typeof and the size of
> the datatype.
> 
> Alternatively we need infra in nft to obtain the template that
> was used to derive the size from the input string ("meta iifname").
> 
> I guess the latter should also be doable.  If we do this then we'd
> only need to store something like "-meta iifname-tcp dport" to help
> with splitting the key into its components.
> 
> > > meta mark set typeof(meta mark) ip saddr
> > 
> > Casting is something we should definitely explore, yes. Question here
> > is that we would need to annotate somewhere that the user has
> > specified typeof(), or any cast, so we dump back exactly what the user
> > is asking for. Probably this needs userdata area for expressions.
> 
> Yes, seems like above needs to annotate payload expression (ip saddr)
> with the typecast info.  Alternatively however this MIGHT be able to
> be detectable on userspace side, e.g.
> 
> meta mark set ip saddr
> 
> We know that meta mark wants the packet mark, so we could infer
> that user forced an override of the type mismatch, and that can
> be determined by looking at the expressions' data type.

That's another possibility, yes.

I would start with typeof() support for set, then we look at casting.

  reply	other threads:[~2017-09-13 15:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170912172527.GC25977@breakpoint.cc>
     [not found] ` <20170913115823.GA2297@salvia>
2017-09-13 15:27   ` nft typeof keywork patch Florian Westphal
2017-09-13 15:43     ` Pablo Neira Ayuso [this message]
2017-09-15 11:02       ` Florian Westphal
2017-09-15 11:26         ` 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=20170913154318.GA4681@salvia \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.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).