netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] segtree: fix map listing with interface wildcard
Date: Mon, 27 Jun 2022 13:03:21 +0200	[thread overview]
Message-ID: <20220627110321.227867-1-pablo@netfilter.org> (raw)

 # nft -f - <<'EOF'
 table inet filter {
    chain INPUT {
        iifname vmap {
            "eth0" : jump input_lan,
            "wg*" : jump input_vpn
        }
    }
    chain input_lan {}
    chain input_vpn {}
 }
 EOF
 # nft list ruleset
 nft: segtree.c:578: interval_map_decompose: Assertion `low->len / 8 > 0' failed.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1617
Fixes: 5e393ea1fc0a ("segtree: add string "range" reversal support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/segtree.c                                         |  2 +-
 .../shell/testcases/sets/dumps/sets_with_ifnames.nft  | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/segtree.c b/src/segtree.c
index f9cac373a5f0..c36497ce6253 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -575,7 +575,7 @@ void interval_map_decompose(struct expr *set)
 
 		if (!mpz_cmp_ui(range, 0)) {
 			if (expr_basetype(low)->type == TYPE_STRING)
-				mpz_switch_byteorder(expr_value(low)->value, low->len / BITS_PER_BYTE);
+				mpz_switch_byteorder(expr_value(low)->value, expr_value(low)->len / BITS_PER_BYTE);
 			low->flags |= EXPR_F_KERNEL;
 			compound_expr_add(set, expr_get(low));
 		} else if (range_is_prefix(range) && !mpz_cmp_ui(p, 0)) {
diff --git a/tests/shell/testcases/sets/dumps/sets_with_ifnames.nft b/tests/shell/testcases/sets/dumps/sets_with_ifnames.nft
index 6b073ae2d090..77a8baf58cef 100644
--- a/tests/shell/testcases/sets/dumps/sets_with_ifnames.nft
+++ b/tests/shell/testcases/sets/dumps/sets_with_ifnames.nft
@@ -29,11 +29,19 @@ table inet testifsets {
 			     12.2.2.0/24 . "abcdef*" }
 	}
 
+	map map_wild {
+		type ifname : verdict
+		flags interval
+		elements = { "abcdef*" : jump do_nothing,
+			     "eth0" : jump do_nothing }
+	}
+
 	chain v4icmp {
 		iifname @simple counter packets 0 bytes 0
 		iifname @simple_wild counter packets 0 bytes 0
 		iifname { "eth0", "abcdef0" } counter packets 0 bytes 0
 		iifname { "abcdef*", "eth0" } counter packets 0 bytes 0
+		iifname vmap @map_wild
 	}
 
 	chain v4icmpc {
@@ -48,4 +56,7 @@ table inet testifsets {
 		ip protocol icmp jump v4icmp
 		ip protocol icmp goto v4icmpc
 	}
+
+	chain do_nothing {
+	}
 }
-- 
2.30.2


                 reply	other threads:[~2022-06-27 11:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220627110321.227867-1-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).