All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nftables] src: Optimize prefix match only if is big-endian
@ 2021-08-20 16:12 Xiao Liang
  2021-08-23 14:36 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Xiao Liang @ 2021-08-20 16:12 UTC (permalink / raw)
  To: netfilter-devel; +Cc: 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.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
---
 src/netlink_linearize.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nftables] src: Optimize prefix match only if is big-endian
  2021-08-20 16:12 [PATCH nftables] src: Optimize prefix match only if is big-endian Xiao Liang
@ 2021-08-23 14:36 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2021-08-23 14:36 UTC (permalink / raw)
  To: Xiao Liang; +Cc: netfilter-devel, phil

On Sat, Aug 21, 2021 at 12:12:37AM +0800, Xiao Liang wrote:
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-23 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 16:12 [PATCH nftables] src: Optimize prefix match only if is big-endian Xiao Liang
2021-08-23 14:36 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.