diff options
author | Florian Westphal <fw@strlen.de> | 2022-07-25 20:02:28 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2022-08-05 01:46:39 +0200 |
commit | 87c3041bfd244aaf39e644d33c0df4fe04079e1c (patch) | |
tree | 6e44cb324330023d2ffea02dc1a92bf046030ca6 /src | |
parent | b1e3ed0335d13d206a2a2698a1ba189fa396dbf3 (diff) |
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 <eric@garver.life>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/evaluate.c | 21 |
1 files changed, 15 insertions, 6 deletions
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); |