Blame SOURCES/0012-netlink_delinearize-allow-postprocessing-on-concaten.patch

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