]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: Allow concatenation of rt nexthop etc.
authorAnders K. Pedersen <akp@cohaesio.com>
Sat, 29 Oct 2016 09:49:09 +0000 (09:49 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 31 Oct 2016 13:57:30 +0000 (14:57 +0100)
Concatenations of rt nexthop or ct {orignal | reply} {saddr | daddr} fail
due to

 # nft add rule ip filter postrouting flow table acct \{ ip saddr . rt nexthop counter \}
 <cmdline>:1:61-70: Error: can not use variable sized data types (invalid) in concat expressions
 add rule ip filter postrouting flow table acct { ip saddr . rt nexthop counter }
                                                  ~~~~~~~~~~~^^^^^^^^^^

Fix this by reordering the check for variable size data types in
expr_evaluate_concat() to happen after expr_evaluate() has been called (via
list_member_evaluate()) for the sub expression. This allows
expr_evaluate_[cr]t() to call [cr]t_expr_update_type() and set the data type
before the check.

Signed-off-by: Anders K. Pedersen <akp@cohaesio.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c

index 79add5ee5697ddfb9ddc1e8301101580c3005091..878efacd94bcaa09d11f7bcbcf612e84493f9331 100644 (file)
@@ -987,13 +987,6 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
                                                 "expecting %s",
                                                 dtype->desc);
 
-               if (dtype == NULL && i->dtype->size == 0)
-                       return expr_binary_error(ctx->msgs, i, *expr,
-                                                "can not use variable sized "
-                                                "data types (%s) in concat "
-                                                "expressions",
-                                                i->dtype->name);
-
                if (dtype == NULL)
                        tmp = datatype_lookup(TYPE_INVALID);
                else
@@ -1004,6 +997,13 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr)
                        return -1;
                flags &= i->flags;
 
+               if (dtype == NULL && i->dtype->size == 0)
+                       return expr_binary_error(ctx->msgs, i, *expr,
+                                                "can not use variable sized "
+                                                "data types (%s) in concat "
+                                                "expressions",
+                                                i->dtype->name);
+
                ntype = concat_subtype_add(ntype, i->dtype->type);
        }