mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
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>
This commit is contained in:
parent
f1640c3dde
commit
4b8c4eddfc
@ -46,16 +46,14 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
|
||||
switch (priv->op) {
|
||||
case NFT_BYTEORDER_NTOH:
|
||||
for (i = 0; i < priv->len / 8; i++) {
|
||||
src64 = get_unaligned_be64(&src[i]);
|
||||
src64 = be64_to_cpu((__force __be64)src64);
|
||||
src64 = get_unaligned((u64 *)&src[i]);
|
||||
put_unaligned_be64(src64, &dst[i]);
|
||||
}
|
||||
break;
|
||||
case NFT_BYTEORDER_HTON:
|
||||
for (i = 0; i < priv->len / 8; i++) {
|
||||
src64 = get_unaligned_be64(&src[i]);
|
||||
src64 = (__force u64)cpu_to_be64(src64);
|
||||
put_unaligned_be64(src64, &dst[i]);
|
||||
put_unaligned(src64, (u64 *)&dst[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user