]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink: fix concat range expansion in map case
authorFlorian Westphal <fw@strlen.de>
Wed, 22 Jul 2020 11:51:25 +0000 (13:51 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 23 Jul 2020 13:08:40 +0000 (15:08 +0200)
Maps with range + concatenation do not work:

Input to nft -f:
        map map_test_concat_interval {
                type ipv4_addr . ipv4_addr : mark
                flags interval
                elements = { 192.168.0.0/24 . 192.168.0.0/24 : 1,
                     192.168.0.0/24 . 10.0.0.1 : 2,
                             192.168.1.0/24 . 10.0.0.1 : 3,
                             192.168.0.0/24 . 192.168.1.10 : 4,
                }
        }

nft list:
        map map_test_concat_interval {
                type ipv4_addr . ipv4_addr : mark
                flags interval
                elements = { 192.168.0.0 . 192.168.0.0-10.0.0.1 : 0x00000002,
                             192.168.1.0-192.168.0.0 . 10.0.0.1-192.168.1.10 : 0x00000004 }
        }

This is not a display bug, nft sends broken information
to kernel.  Use the correct key expression to fix this.

Fixes: 8ac2f3b2fca3 ("src: Add support for concatenated set ranges")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
src/netlink.c

index f752c3c932aabb8f721cd7a5000772047a94f368..b57e1c55850173949e08dacc96de6ba0af9147da 100644 (file)
@@ -123,7 +123,7 @@ static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
        netlink_gen_data(key, &nld);
        nftnl_set_elem_set(nlse, NFTNL_SET_ELEM_KEY, &nld.value, nld.len);
 
-       if (set->set_flags & NFT_SET_INTERVAL && expr->key->field_count > 1) {
+       if (set->set_flags & NFT_SET_INTERVAL && key->field_count > 1) {
                key->flags |= EXPR_F_INTERVAL_END;
                netlink_gen_data(key, &nld);
                key->flags &= ~EXPR_F_INTERVAL_END;