From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/2] src: store expr, not dtype to track data in sets
Date: Wed, 31 Jul 2019 15:10:44 +0200 [thread overview]
Message-ID: <20190731131044.ntk6lzwe5uniku7p@breakpoint.cc> (raw)
In-Reply-To: <20190731130230.nc5fj437st7ejkne@salvia>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > +static struct expr *concat_expr_alloc_by_type_FIXME(uint32_t type)
> > +{
> > + struct expr *concat_expr = concat_expr_alloc(&netlink_location);
> > + unsigned int n;
> > + int size = 0;
> > +
> > + n = div_round_up(fls(type), TYPE_BITS);
> > + while (n > 0 && concat_subtype_id(type, --n)) {
> > + const struct datatype *i;
> > + struct expr *expr;
> > +
> > + i = concat_subtype_lookup(type, n);
> > + if (i == NULL)
> > + return NULL;
> > +
> > + if (i->size == 0)
> > + size = -1;
> > + else if (size >= 0)
> > + size += i->size;
> > +
> > + expr = constant_expr_alloc(&netlink_location, i, i->byteorder,
> > + i->size, NULL);
> > +
> > + compound_expr_add(concat_expr, expr);
> > + }
> > +
> > + /* can be incorrect in case of i->size being 0 (variable length). */
> > + concat_expr->len = size > 0 ? size : 0;
> > +
> > + return concat_expr;
> > +}
> > +
> > +static struct expr *
> > +data_expr_alloc_by_type_FIXME(enum nft_data_types type, enum byteorder keybyteorder)
>
> There is no support for concatenations from the right hand side of the
> mapping, so I would just calloc a constant expression itself.
Excellent. This is what I concluded when I was working on this, but at
that point i was already backed into a corner, hence the function name
:-)
> will be more simple. Same comment applies to dtype_map_from_kernel().
Oh, right.
> In general, I agree in the direction where this is going, that is,
> turn the datatype field in the set object into an expression.
Perfect.
next prev parent reply other threads:[~2019-07-31 13:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 14:37 [RFC 0/2] typeof keyword, alternate patch Florian Westphal
2019-07-30 14:37 ` [PATCH 1/2] src: store expr, not dtype to track data in sets Florian Westphal
2019-07-31 13:02 ` Pablo Neira Ayuso
2019-07-31 13:10 ` Florian Westphal [this message]
2019-07-30 14:37 ` [PATCH 2/2] typeof keyword Florian Westphal
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=20190731131044.ntk6lzwe5uniku7p@breakpoint.cc \
--to=fw@strlen.de \
--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).