Pablo Neira Ayuso <[email protected]> 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.

Reply via email to