* [RFC] netlink: do not alter set element width
@ 2020-05-05 9:41 Michael Braun
0 siblings, 0 replies; only message in thread
From: Michael Braun @ 2020-05-05 9:41 UTC (permalink / raw)
To: netfilter-devel; +Cc: Michael Braun
Consider the following rulset
table bridge t {
set nodhcpvlan {
typeof vlan id
elements = { 1 }
}
chain c1 {
vlan id != @nodhcpvlan vlan type arp counter packets 0 bytes 0 jump c2
vlan id != @nodhcpvlan vlan type ip counter packets 0 bytes 0 jump c2
}
chain c2 {
}
}
This results for nft list ruleset in
nft: netlink_delinearize.c:1945: binop_adjust_one: Assertion `value->len >= binop->right->len' failed.
This is due to binop_adjust_one setting value->len to left->len, which
is shorther than right->len.
Additionally, it does not seem correct to alter set elements from parsing a rule,
so remove that part all together.
Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
src/netlink_delinearize.c | 18 ------------------
tests/shell/testcases/sets/typeof_sets_1 | 22 ++++++++++++++++++++++
2 files changed, 22 insertions(+), 18 deletions(-)
create mode 100755 tests/shell/testcases/sets/typeof_sets_1
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index f721d15c..877c0d44 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -1959,29 +1959,11 @@ static void binop_adjust_one(const struct expr *binop, struct expr *value,
static void __binop_adjust(const struct expr *binop, struct expr *right,
unsigned int shift)
{
- struct expr *i;
-
switch (right->etype) {
case EXPR_VALUE:
binop_adjust_one(binop, right, shift);
break;
case EXPR_SET_REF:
- list_for_each_entry(i, &right->set->init->expressions, list) {
- switch (i->key->etype) {
- case EXPR_VALUE:
- binop_adjust_one(binop, i->key, shift);
- break;
- case EXPR_RANGE:
- binop_adjust_one(binop, i->key->left, shift);
- binop_adjust_one(binop, i->key->right, shift);
- break;
- case EXPR_SET_ELEM:
- __binop_adjust(binop, i->key->key, shift);
- break;
- default:
- BUG("unknown expression type %s\n", expr_name(i->key));
- }
- }
break;
case EXPR_RANGE:
binop_adjust_one(binop, right->left, shift);
diff --git a/tests/shell/testcases/sets/typeof_sets_1 b/tests/shell/testcases/sets/typeof_sets_1
new file mode 100755
index 00000000..359ae109
--- /dev/null
+++ b/tests/shell/testcases/sets/typeof_sets_1
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# regression test for corner case in netlink_delinearize
+
+EXPECTED="table bridge t {
+ set nodhcpvlan {
+ typeof vlan id
+ elements = { 1 }
+ }
+
+ chain c1 {
+ vlan id != @nodhcpvlan vlan type arp counter packets 0 bytes 0 jump c2
+ vlan id != @nodhcpvlan vlan type ip counter packets 0 bytes 0 jump c2
+ }
+
+ chain c2 {
+ }
+}"
+
+set -e
+$NFT -f - <<< $EXPECTED
+
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-05 9:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-05 9:41 [RFC] netlink: do not alter set element width Michael Braun
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).