Skip to contentSkip to conversation

src: Optimize prefix match only if is big-endian

PATCH Applied Xiao Liang 2 participants 2 messages Aug 20, 2021 – Aug 23, 2021 netfilter

lore
Share & tools
lore

Xiao Liang

author
#0 lore raw

PATCH 1/1 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.

---
 src/netlink_linearize.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/netlink_linearize.c +2 -1
index eb53ccec..454b9ba3 100644
@@ -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);
Signature · 1 line
2.33.0
maintainer Applied
#1 lore raw
Quoted 2 lines · Xiao Liang

A prefix of integer type is big-endian in nature. Prefix match can be optimized to truncated 'cmp' only if it is big-endian.

Applied, thanks.