From: Patrick McHardy Date: Sat, 8 Dec 2012 19:42:16 +0000 (+0100) Subject: seqtree: update mapping data when keeping the base X-Git-Tag: v0.099~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e33068da715323768bbee39a17cdad8642451ae;p=thirdparty%2Fnftables.git seqtree: update mapping data when keeping the base 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 --- diff --git a/src/segtree.c b/src/segtree.c index c3206199..356a8b76 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -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); }