Adjust the expression size to 1B so cmp expression value is correct.
Without this, the rule 'fib saddr . iif check exists' generates
following byte code on BE:
| [ fib saddr . iif oif present => reg 1 ]
| [ cmp eq reg 1 0x00000001 ]
Though with NFTA_FIB_F_PRESENT flag set, nft_fib.ko writes to the first
byte of reg 1 only (using nft_reg_store8()). With this patch in place,
byte code is correct:
| [ fib saddr . iif oif present => reg 1 ]
| [ cmp eq reg 1 0x01000000 ]
Fixes: f686a17eafa0b ("fib: Support existence check")
Cc: Yi Chen <yiche@redhat.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
if (expr->flags & EXPR_F_BOOLEAN) {
expr->fib.flags |= NFTA_FIB_F_PRESENT;
datatype_set(expr, &boolean_type);
+ expr->len = BITS_PER_BYTE;
}
return expr_evaluate_primary(ctx, exprp);
}
BUG("Unknown result %d\n", result);
}
- if (flags & NFTA_FIB_F_PRESENT)
+ if (flags & NFTA_FIB_F_PRESENT) {
type = &boolean_type;
+ len = BITS_PER_BYTE;
+ }
expr = expr_alloc(loc, EXPR_FIB, type,
BYTEORDER_HOST_ENDIAN, len);