* [PATCH nft 1/2] segtree: fix get element command with open intervals
@ 2026-07-02 12:36 Pablo Neira Ayuso
2026-07-02 12:36 ` [PATCH nft 2/2] tests: shell: expand get command test " Pablo Neira Ayuso
0 siblings, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2026-07-02 12:36 UTC (permalink / raw)
To: netfilter-devel
Skip the closing end element in case this is an open interval.
Otherwise, a bogus end element max(type) + 1 is provided, eg. in
inet_service, this results as a 0x10000 with end interval flag
which is interpreted by the kernel as a matching closing element.
Fixes: a43cc8d53096 ("src: support for get element command")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/segtree.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/segtree.c b/src/segtree.c
index a12820bcf1ec..e877814505f4 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -73,12 +73,13 @@ static void set_elem_expr_add(const struct set *set, struct expr *init,
struct expr *get_set_intervals(const struct set *set, const struct expr *init)
{
enum byteorder byteorder = get_key_byteorder(set->key);
+ mpz_t low, high, mask;
struct expr *new_init;
- mpz_t low, high;
struct expr *i;
mpz_init2(low, set->key->len);
mpz_init2(high, set->key->len);
+ mpz_init2(mask, set->key->len);
new_init = set_expr_alloc(&internal_location, NULL);
@@ -105,6 +106,10 @@ struct expr *get_set_intervals(const struct set *set, const struct expr *init)
range_expr_value_low(low, i->key);
set_elem_expr_add(set, new_init, low, 0, byteorder);
range_expr_value_high(high, i->key);
+ mpz_bitmask(mask, i->len);
+ if (!mpz_cmp(mask, high))
+ break;
+
mpz_add_ui(high, high, 1);
set_elem_expr_add(set, new_init, high,
EXPR_F_INTERVAL_END, byteorder);
@@ -115,6 +120,7 @@ struct expr *get_set_intervals(const struct set *set, const struct expr *init)
}
}
+ mpz_clear(mask);
mpz_clear(low);
mpz_clear(high);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH nft 2/2] tests: shell: expand get command test with open intervals
2026-07-02 12:36 [PATCH nft 1/2] segtree: fix get element command with open intervals Pablo Neira Ayuso
@ 2026-07-02 12:36 ` Pablo Neira Ayuso
2026-07-07 13:26 ` Phil Sutter
0 siblings, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2026-07-02 12:36 UTC (permalink / raw)
To: netfilter-devel
Extend the existing test to cover get commands with open internals.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
tests/shell/testcases/sets/0034get_element_0 | 12 +++++++++++-
.../testcases/sets/dumps/0034get_element_0.json-nft | 6 ++++++
.../shell/testcases/sets/dumps/0034get_element_0.nft | 2 +-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/tests/shell/testcases/sets/0034get_element_0 b/tests/shell/testcases/sets/0034get_element_0
index 32375b9f50c2..a25769604685 100755
--- a/tests/shell/testcases/sets/0034get_element_0
+++ b/tests/shell/testcases/sets/0034get_element_0
@@ -16,7 +16,7 @@ check() { # (set, elems, expected)
RULESET="add table ip t
add set ip t s { type inet_service; flags interval; }
-add element ip t s { 10, 20-30, 40, 50-60 }
+add element ip t s { 10, 20-30, 40, 50-60, 60000-65535 }
add set ip t ips { type ipv4_addr; flags interval; }
add element ip t ips { 10.0.0.1, 10.0.0.5-10.0.0.8 }
add element ip t ips { 10.0.0.128/25, 10.0.1.0/24, 10.0.2.3-10.0.2.12 }
@@ -36,6 +36,16 @@ check s 15-18 ""
# multiple single elements, ranges smaller than present
check s "10, 40" "10, 40"
check s "22-24, 26-28" "20-30, 20-30"
+check s "60000-65535" "60000-65535"
+check s "60000-65534" "60000-65535"
+check s "60001-65535" "60000-65535"
+check s "60001-65534" "60000-65535"
+check s "22-24, 60000-65535" "20-30, 60000-65535"
+check s "22-24, 60000-65534" "20-30, 60000-65535"
+check s "22-24, 60001-65535" "20-30, 60000-65535"
+check s "22-24, 60001-65534" "20-30, 60000-65535"
+check s "60001-65534, 10" "60000-65535, 10"
+check s "20, 60001-65535, 10" "20-30, 60000-65535, 10"
check s 21-29 20-30
# mixed single elements and ranges
diff --git a/tests/shell/testcases/sets/dumps/0034get_element_0.json-nft b/tests/shell/testcases/sets/dumps/0034get_element_0.json-nft
index bfc0e4a0f588..64c7dc0c6555 100644
--- a/tests/shell/testcases/sets/dumps/0034get_element_0.json-nft
+++ b/tests/shell/testcases/sets/dumps/0034get_element_0.json-nft
@@ -38,6 +38,12 @@
50,
60
]
+ },
+ {
+ "range": [
+ 60000,
+ 65535
+ ]
}
]
}
diff --git a/tests/shell/testcases/sets/dumps/0034get_element_0.nft b/tests/shell/testcases/sets/dumps/0034get_element_0.nft
index 1c1dd9779a8a..889640389cd9 100644
--- a/tests/shell/testcases/sets/dumps/0034get_element_0.nft
+++ b/tests/shell/testcases/sets/dumps/0034get_element_0.nft
@@ -2,7 +2,7 @@ table ip t {
set s {
type inet_service
flags interval
- elements = { 10, 20-30, 40, 50-60 }
+ elements = { 10, 20-30, 40, 50-60, 60000-65535 }
}
set ips {
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH nft 2/2] tests: shell: expand get command test with open intervals
2026-07-02 12:36 ` [PATCH nft 2/2] tests: shell: expand get command test " Pablo Neira Ayuso
@ 2026-07-07 13:26 ` Phil Sutter
2026-07-07 14:16 ` Pablo Neira Ayuso
0 siblings, 1 reply; 6+ messages in thread
From: Phil Sutter @ 2026-07-07 13:26 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
Hi Pablo,
On Thu, Jul 02, 2026 at 02:36:34PM +0200, Pablo Neira Ayuso wrote:
> Extend the existing test to cover get commands with open internals.
This test fails on a Big Endian testing machine running Fedora Rawhide
running 7.2.0-0.rc2.21.fc45. Does this perhaps test a recent kernel fix
or something?
Here's the test output for reference:
| W: [FAILED] 1/1 testcases/sets/0034get_element_0
| Command: testcases/sets/0034get_element_0
| Error: Could not process rule: No such file or directory
| get element ip t s { 11 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t s { 15-18 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: Too many open files
| get element ip t s { 60000-65534 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ERROR: asked for '60000-65534' in set s, expecting '60000-65535' but got
| ''
| Error: Could not process rule: Too many open files
| get element ip t s { 60001-65534 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ERROR: asked for '60001-65534' in set s, expecting '60000-65535' but got
| ''
| Error: Could not process rule: Too many open files
| get element ip t s { 22-24, 60000-65534 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ERROR: asked for '22-24, 60000-65534' in set s, expecting '20-30,
| 60000-65535' but got ''
| Error: Could not process rule: Too many open files
| get element ip t s { 22-24, 60001-65534 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ERROR: asked for '22-24, 60001-65534' in set s, expecting '20-30,
| 60000-65535' but got ''
| Error: Could not process rule: Too many open files
| get element ip t s { 60001-65534, 10 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ERROR: asked for '60001-65534, 10' in set s, expecting '60000-65535, 10'
| but got ''
| Error: Could not process rule: No such file or directory
| get element ip t s { 10-40 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t s { 10-20 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t s { 10-25 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t s { 25-55 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t ips { 10.0.0.2 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t cs { 10.0.0.1 . 23 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Error: Could not process rule: No such file or directory
| get element ip t cs { 10.0.0.2 . 22 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cheers, Phil
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH nft 2/2] tests: shell: expand get command test with open intervals
2026-07-07 13:26 ` Phil Sutter
@ 2026-07-07 14:16 ` Pablo Neira Ayuso
2026-07-07 14:49 ` Phil Sutter
0 siblings, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2026-07-07 14:16 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
Hi Phil,
On Tue, Jul 07, 2026 at 03:26:20PM +0200, Phil Sutter wrote:
> Hi Pablo,
> On Thu, Jul 02, 2026 at 02:36:34PM +0200, Pablo Neira Ayuso wrote:
> > Extend the existing test to cover get commands with open internals.
>
> This test fails on a Big Endian testing machine running Fedora Rawhide
> running 7.2.0-0.rc2.21.fc45. Does this perhaps test a recent kernel fix
> or something?
Does this kernel contain this kernel fix?
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git/commit/?id=d63611cbe8af99dd61b118ee6e5b5e3e518250b2
as well as this userspace fix:
https://git.netfilter.org/nftables/commit/?id=4eafc1a2a9ef5a827b1b4e58cb3b2832d2eb1650
> Here's the test output for reference:
>
> | W: [FAILED] 1/1 testcases/sets/0034get_element_0
> | Command: testcases/sets/0034get_element_0
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 11 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 15-18 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: Too many open files
> | get element ip t s { 60000-65534 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | ERROR: asked for '60000-65534' in set s, expecting '60000-65535' but got
> | ''
> | Error: Could not process rule: Too many open files
> | get element ip t s { 60001-65534 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | ERROR: asked for '60001-65534' in set s, expecting '60000-65535' but got
> | ''
> | Error: Could not process rule: Too many open files
> | get element ip t s { 22-24, 60000-65534 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | ERROR: asked for '22-24, 60000-65534' in set s, expecting '20-30,
> | 60000-65535' but got ''
> | Error: Could not process rule: Too many open files
> | get element ip t s { 22-24, 60001-65534 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | ERROR: asked for '22-24, 60001-65534' in set s, expecting '20-30,
> | 60000-65535' but got ''
> | Error: Could not process rule: Too many open files
> | get element ip t s { 60001-65534, 10 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | ERROR: asked for '60001-65534, 10' in set s, expecting '60000-65535, 10'
> | but got ''
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 10-40 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 10-20 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 10-25 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t s { 25-55 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t ips { 10.0.0.2 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t cs { 10.0.0.1 . 23 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> | Error: Could not process rule: No such file or directory
> | get element ip t cs { 10.0.0.2 . 22 }
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Cheers, Phil
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH nft 2/2] tests: shell: expand get command test with open intervals
2026-07-07 14:16 ` Pablo Neira Ayuso
@ 2026-07-07 14:49 ` Phil Sutter
2026-07-07 14:52 ` Pablo Neira Ayuso
0 siblings, 1 reply; 6+ messages in thread
From: Phil Sutter @ 2026-07-07 14:49 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Tue, Jul 07, 2026 at 04:16:01PM +0200, Pablo Neira Ayuso wrote:
> Hi Phil,
>
> On Tue, Jul 07, 2026 at 03:26:20PM +0200, Phil Sutter wrote:
> > Hi Pablo,
> > On Thu, Jul 02, 2026 at 02:36:34PM +0200, Pablo Neira Ayuso wrote:
> > > Extend the existing test to cover get commands with open internals.
> >
> > This test fails on a Big Endian testing machine running Fedora Rawhide
> > running 7.2.0-0.rc2.21.fc45. Does this perhaps test a recent kernel fix
> > or something?
>
> Does this kernel contain this kernel fix?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git/commit/?id=d63611cbe8af99dd61b118ee6e5b5e3e518250b2
Ah, thanks for the pointer. Rawhide kernels are "best effort" by early
rebase vs. excessive backporting, so a fix in nf.git must be rather
critical to hit it before linus.git.
> as well as this userspace fix:
>
> https://git.netfilter.org/nftables/commit/?id=4eafc1a2a9ef5a827b1b4e58cb3b2832d2eb1650
Yes, this is present. To give you a bit of context: I have a script
which builds current upstream HEAD of iptables, nftables and
dependencies on a fresh Rawhide for running the test suites. I reserve a
RH-internal Big Endian machine (s390x VM) for it. The goal is to detect
Big Endian breakers early.
Thanks for clarifying!
Cheers, Phil
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH nft 2/2] tests: shell: expand get command test with open intervals
2026-07-07 14:49 ` Phil Sutter
@ 2026-07-07 14:52 ` Pablo Neira Ayuso
0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2026-07-07 14:52 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Tue, Jul 07, 2026 at 04:49:55PM +0200, Phil Sutter wrote:
> On Tue, Jul 07, 2026 at 04:16:01PM +0200, Pablo Neira Ayuso wrote:
> > Hi Phil,
> >
> > On Tue, Jul 07, 2026 at 03:26:20PM +0200, Phil Sutter wrote:
> > > Hi Pablo,
> > > On Thu, Jul 02, 2026 at 02:36:34PM +0200, Pablo Neira Ayuso wrote:
> > > > Extend the existing test to cover get commands with open internals.
> > >
> > > This test fails on a Big Endian testing machine running Fedora Rawhide
> > > running 7.2.0-0.rc2.21.fc45. Does this perhaps test a recent kernel fix
> > > or something?
> >
> > Does this kernel contain this kernel fix?
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git/commit/?id=d63611cbe8af99dd61b118ee6e5b5e3e518250b2
>
> Ah, thanks for the pointer. Rawhide kernels are "best effort" by early
> rebase vs. excessive backporting, so a fix in nf.git must be rather
> critical to hit it before linus.git.
>
> > as well as this userspace fix:
> >
> > https://git.netfilter.org/nftables/commit/?id=4eafc1a2a9ef5a827b1b4e58cb3b2832d2eb1650
>
> Yes, this is present. To give you a bit of context: I have a script
> which builds current upstream HEAD of iptables, nftables and
> dependencies on a fresh Rawhide for running the test suites. I reserve a
> RH-internal Big Endian machine (s390x VM) for it. The goal is to detect
> Big Endian breakers early.
Thanks for explaining.
> Thanks for clarifying!
OK, then, all good, it is a matter of waiting for the kernel fix to
propagate to the rawhide kernel tree.
Ping back if problem persists by then, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-07 14:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 12:36 [PATCH nft 1/2] segtree: fix get element command with open intervals Pablo Neira Ayuso
2026-07-02 12:36 ` [PATCH nft 2/2] tests: shell: expand get command test " Pablo Neira Ayuso
2026-07-07 13:26 ` Phil Sutter
2026-07-07 14:16 ` Pablo Neira Ayuso
2026-07-07 14:49 ` Phil Sutter
2026-07-07 14:52 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.