|
|
1d03cd |
From cff78b77d409445b0490e67bf9329e69e0bbc872 Mon Sep 17 00:00:00 2001
|
|
|
1d03cd |
From: Phil Sutter <psutter@redhat.com>
|
|
|
1d03cd |
Date: Thu, 9 Feb 2023 10:27:57 +0100
|
|
|
1d03cd |
Subject: [PATCH] netlink_delinearize: allow postprocessing on concatenated
|
|
|
1d03cd |
elements
|
|
|
1d03cd |
|
|
|
1d03cd |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094887
|
|
|
1d03cd |
Upstream Status: nftables commit 0542a431e8dcc
|
|
|
1d03cd |
|
|
|
1d03cd |
commit 0542a431e8dccfa86fa5b1744f536e61a0b204f3
|
|
|
1d03cd |
Author: Florian Westphal <fw@strlen.de>
|
|
|
1d03cd |
Date: Tue Jun 14 21:57:58 2022 +0200
|
|
|
1d03cd |
|
|
|
1d03cd |
netlink_delinearize: allow postprocessing on concatenated elements
|
|
|
1d03cd |
|
|
|
1d03cd |
Currently there is no case where the individual expressions inside a
|
|
|
1d03cd |
mapped concatenation need to be munged.
|
|
|
1d03cd |
|
|
|
1d03cd |
However, to support proper delinearization for an input like
|
|
|
1d03cd |
'rule netdev nt nc set update ether saddr . vlan id timeout 5s @macset'
|
|
|
1d03cd |
|
|
|
1d03cd |
we need to allow this.
|
|
|
1d03cd |
|
|
|
1d03cd |
Right now, this gets listed as:
|
|
|
1d03cd |
|
|
|
1d03cd |
update @macset { @ll,48,48 . @ll,112,16 & 0xfff timeout 5s }
|
|
|
1d03cd |
|
|
|
1d03cd |
because the ethernet protocol is replaced by vlan beforehand,
|
|
|
1d03cd |
so we fail to map @ll,48,48 to a vlan protocol.
|
|
|
1d03cd |
|
|
|
1d03cd |
Likewise, we can't map the vlan info either because we cannot
|
|
|
1d03cd |
cope with the 'and' operation properly, nor is it removed.
|
|
|
1d03cd |
|
|
|
1d03cd |
Prepare for this by deleting and re-adding so that we do not
|
|
|
1d03cd |
corrupt the linked list.
|
|
|
1d03cd |
|
|
|
1d03cd |
After this, the list can be safely changed and a followup patch
|
|
|
1d03cd |
can start to delete/reallocate expressions.
|
|
|
1d03cd |
|
|
|
1d03cd |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
1d03cd |
|
|
|
1d03cd |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
1d03cd |
---
|
|
|
1d03cd |
src/netlink_delinearize.c | 7 ++++++-
|
|
|
1d03cd |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
1d03cd |
|
|
|
1d03cd |
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
|
|
|
1d03cd |
index 068c3bb..2f13990 100644
|
|
|
1d03cd |
--- a/src/netlink_delinearize.c
|
|
|
1d03cd |
+++ b/src/netlink_delinearize.c
|
|
|
1d03cd |
@@ -2538,16 +2538,21 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
|
|
|
1d03cd |
unsigned int type = expr->dtype->type, ntype = 0;
|
|
|
1d03cd |
int off = expr->dtype->subtypes;
|
|
|
1d03cd |
const struct datatype *dtype;
|
|
|
1d03cd |
+ LIST_HEAD(tmp);
|
|
|
1d03cd |
+ struct expr *n;
|
|
|
1d03cd |
|
|
|
1d03cd |
- list_for_each_entry(i, &expr->expressions, list) {
|
|
|
1d03cd |
+ list_for_each_entry_safe(i, n, &expr->expressions, list) {
|
|
|
1d03cd |
if (type) {
|
|
|
1d03cd |
dtype = concat_subtype_lookup(type, --off);
|
|
|
1d03cd |
expr_set_type(i, dtype, dtype->byteorder);
|
|
|
1d03cd |
}
|
|
|
1d03cd |
+ list_del(&i->list);
|
|
|
1d03cd |
expr_postprocess(ctx, &i);
|
|
|
1d03cd |
+ list_add_tail(&i->list, &tmp);
|
|
|
1d03cd |
|
|
|
1d03cd |
ntype = concat_subtype_add(ntype, i->dtype->type);
|
|
|
1d03cd |
}
|
|
|
1d03cd |
+ list_splice(&tmp, &expr->expressions);
|
|
|
1d03cd |
datatype_set(expr, concat_type_alloc(ntype));
|
|
|
1d03cd |
break;
|
|
|
1d03cd |
}
|
|
|
1d03cd |
--
|
|
|
1d03cd |
2.39.1
|
|
|
1d03cd |
|