payload: only assert if l2 header base has no length
Florian Westphal
maintainerPATCH 1/1 payload: only assert if l2 header base has no length
nftables will assert in some cases because the sanity check is done even for network and transport header bases.
However, stacked headers are only supported for the link layer. Move the assertion around and add a test case for this.
Signed-off-by Florian Westphal <[email protected]>
--- src/payload.c | 3 +-- .../testcases/bogons/nft-f/payload_expr_pctx_update_assert | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 tests/shell/testcases/bogons/nft-f/payload_expr_pctx_update_assert
src/payload.c +1 -2
@@ -118,11 +118,10 @@ static void payload_expr_pctx_update(struct proto_ctx *ctx,assert (desc->base <=PROTO_BASE_MAX );if (desc->base == base->base) { -assert (base->length >0 ); -if (!left->payload.is_raw) {if (desc->base ==PROTO_BASE_LL_HDR && ctx->stacked_ll_count <PROTO_CTX_NUM_PROTOS ) { +assert (base->length >0 ); ctx->stacked_ll[ctx->stacked_ll_count] = base; ctx->stacked_ll_count++; }
tests/shell/testcases/bogons/nft-f/payload_expr_pctx_update_assert new file +1 -0
@@ -0,0 +1 @@ +x x comp nexthdr comp
Signature · 1 line
2.41.0