From 87c3041bfd244aaf39e644d33c0df4fe04079e1c Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 25 Jul 2022 20:02:28 +0200 Subject: evaluate: search stacked header list for matching payload dep "ether saddr 0:1:2:3:4:6 vlan id 2" works, but reverse fails: "vlan id 2 ether saddr 0:1:2:3:4:6" will give Error: conflicting protocols specified: vlan vs. ether After "proto: track full stack of seen l2 protocols, not just cumulative offset", we have a list of all l2 headers, so search those to see if we had this proto base in the past before rejecting this. Reported-by: Eric Garver Signed-off-by: Florian Westphal --- src/evaluate.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/evaluate.c b/src/evaluate.c index be9fcd51..919c38c5 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -659,13 +659,22 @@ static int resolve_protocol_conflict(struct eval_ctx *ctx, struct stmt *nstmt = NULL; int link, err; - if (payload->payload.base == PROTO_BASE_LL_HDR && - proto_is_dummy(desc)) { - err = meta_iiftype_gen_dependency(ctx, payload, &nstmt); - if (err < 0) - return err; + if (payload->payload.base == PROTO_BASE_LL_HDR) { + if (proto_is_dummy(desc)) { + err = meta_iiftype_gen_dependency(ctx, payload, &nstmt); + if (err < 0) + return err; - rule_stmt_insert_at(ctx->rule, nstmt, ctx->stmt); + rule_stmt_insert_at(ctx->rule, nstmt, ctx->stmt); + } else { + unsigned int i; + + /* payload desc stored in the L2 header stack? No conflict. */ + for (i = 0; i < ctx->pctx.stacked_ll_count; i++) { + if (ctx->pctx.stacked_ll[i] == payload->payload.desc) + return 0; + } + } } assert(base <= PROTO_BASE_MAX); -- cgit v1.2.3