]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
seqtree: update mapping data when keeping the base
authorPatrick McHardy <kaber@trash.net>
Sat, 8 Dec 2012 19:42:16 +0000 (20:42 +0100)
committerPatrick McHardy <kaber@trash.net>
Sat, 8 Dec 2012 19:42:16 +0000 (20:42 +0100)
When a prefix expression is followed by another prefix expression using the
same base but a wider prefix, we need to update the mapping data to that of
the second expression.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/segtree.c

index c3206199f3ace470b247928ee6e7b00c8ffbfc03..356a8b7646f47f475ac20c0b9ef84e28f63975aa 100644 (file)
@@ -540,9 +540,11 @@ void interval_map_decompose(struct expr *set)
                        mpz_set(tmp->value, range);
 
                        tmp = range_expr_alloc(&low->location, expr_value(low), tmp);
+                       if (low->ops->type == EXPR_MAPPING)
+                               tmp = mapping_expr_alloc(&tmp->location, tmp, low->right);
+
                        compound_expr_add(set, tmp);
 
-                       printf("!prefix: "); expr_print(tmp); printf("\n");
                        low = expr_get(tmp->right);
                } else {
                        struct expr *prefix;
@@ -552,9 +554,12 @@ void interval_map_decompose(struct expr *set)
                        prefix = prefix_expr_alloc(&low->location, expr_value(low),
                                                   prefix_len);
 
-                       if (low->ops->type == EXPR_MAPPING)
+                       if (low->ops->type == EXPR_MAPPING) {
                                prefix = mapping_expr_alloc(&low->location, prefix,
-                                                           expr_get(low->right));
+                                                           low->right);
+                               /* Update mapping of "low" to the current mapping */
+                               low->right = expr_get(i->right);
+                       }
 
                        compound_expr_add(set, prefix);
                }