Skip to content

Commit 4b8c4ed

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_byteorder: avoid unneeded le/be conversion steps
David points out that we to three le/be conversions instead of just one. Doesn't matter on x86_64 w. gcc, but other architectures might be less lucky. Since it also simplifies code just follow his advice. Fixes: c0f3275f5cb ("nftables: byteorder: provide le/be 64 bit conversion helper") Suggested-by: David Laight <David.Laight@aculab.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent f1640c3 commit 4b8c4ed

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/netfilter/nft_byteorder.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
4646
switch (priv->op) {
4747
case NFT_BYTEORDER_NTOH:
4848
for (i = 0; i < priv->len / 8; i++) {
49-
src64 = get_unaligned_be64(&src[i]);
50-
src64 = be64_to_cpu((__force __be64)src64);
49+
src64 = get_unaligned((u64 *)&src[i]);
5150
put_unaligned_be64(src64, &dst[i]);
5251
}
5352
break;
5453
case NFT_BYTEORDER_HTON:
5554
for (i = 0; i < priv->len / 8; i++) {
5655
src64 = get_unaligned_be64(&src[i]);
57-
src64 = (__force u64)cpu_to_be64(src64);
58-
put_unaligned_be64(src64, &dst[i]);
56+
put_unaligned(src64, (u64 *)&dst[i]);
5957
}
6058
break;
6159
}

0 commit comments

Comments
 (0)