]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
segtree: handle adjacent interval nodes from expr_value_cmp()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 18 Apr 2016 10:08:18 +0000 (12:08 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 25 Apr 2016 13:48:23 +0000 (15:48 +0200)
Named sets may contain adjacent interval nodes, when equal in key, look
at the flags. Those with EXPR_F_INTERVAL_END should come in first place.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/segtree.c

index 75f02b9438fe02755b7ae5cd8f619c927c601e9a..d8f98faac6b26bc7c8a97729c78e1e6db70f4ddf 100644 (file)
@@ -487,8 +487,15 @@ static int expr_value_cmp(const void *p1, const void *p2)
 {
        struct expr *e1 = *(void * const *)p1;
        struct expr *e2 = *(void * const *)p2;
+       int ret;
 
-       return mpz_cmp(expr_value(e1)->value, expr_value(e2)->value);
+       ret = mpz_cmp(expr_value(e1)->value, expr_value(e2)->value);
+       if (ret == 0 && (e1->flags & EXPR_F_INTERVAL_END))
+               return -1;
+       else
+               return 1;
+
+       return ret;
 }
 
 void interval_map_decompose(struct expr *set)