summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXiao Liang <shaw.leon@gmail.com>2021-08-21 00:12:37 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2021-08-23 16:34:52 +0200
commitbd6ba14bebd27181ee18cfc3aebb21a78d96d672 (patch)
tree5e88ef776bfc3e6f6b418239d51b218689f76417 /src
parentffde58ab86507755ba7049a00dde5c4df6f26fbe (diff)
src: Optimize prefix match only if is big-endian
A prefix of integer type is big-endian in nature. Prefix match can be optimized to truncated 'cmp' only if it is big-endian. [ Add one tests/py for this use-case --pablo ] Fixes: 25338cdb6c77 ("src: Optimize prefix matches on byte-boundaries") Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/netlink_linearize.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index eb53ccec..454b9ba3 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -548,7 +548,8 @@ static void netlink_gen_relational(struct netlink_linearize_ctx *ctx,
case EXPR_PREFIX:
sreg = get_register(ctx, expr->left);
if (expr_basetype(expr->left)->type != TYPE_STRING &&
- (!expr->right->prefix_len ||
+ (expr->right->byteorder != BYTEORDER_BIG_ENDIAN ||
+ !expr->right->prefix_len ||
expr->right->prefix_len % BITS_PER_BYTE)) {
len = div_round_up(expr->right->len, BITS_PER_BYTE);
netlink_gen_expr(ctx, expr->left, sreg);