netlink: do not alter set element width
RFC 1/1 netlink: do not alter set element width
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 <[email protected]>
--- 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
src/netlink_delinearize.c +0 -18
@@ -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);
tests/shell/testcases/sets/typeof_sets_1 new file +22 -0
@@ -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 +
Signature · 1 line
2.20.1