kernel can only deal with byte-sized and byte-aligned payload
expressions.
If the payload expression doesn't fit this requirement userspace
has to add explicit binop masks to remove the unwanted part(s).
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
return 0;
}
+static bool payload_needs_adjustment(const struct expr *expr)
+{
+ return expr->payload.offset % BITS_PER_BYTE != 0 ||
+ expr->len % BITS_PER_BYTE != 0;
+}
+
static int expr_evaluate_payload(struct eval_ctx *ctx, struct expr **exprp)
{
struct expr *expr = *exprp;
if (expr_evaluate_primary(ctx, exprp) < 0)
return -1;
- if (expr->payload.offset % BITS_PER_BYTE != 0 ||
- expr->len % BITS_PER_BYTE != 0)
+ if (payload_needs_adjustment(expr))
expr_evaluate_bits(ctx, exprp);
return 0;