[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CCC043B@AcuExch.aculab.com>
Date: Fri, 8 Jan 2016 14:26:31 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Pablo Neira Ayuso' <pablo@...filter.org>,
"netfilter-devel@...r.kernel.org" <netfilter-devel@...r.kernel.org>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH 16/17] netfilter: nft_byteorder: provide 64bit le/be
conversion
From: Pablo Neira Ayuso
> Sent: 08 January 2016 14:02
> From: Florian Westphal <fw@...len.de>
>
> Needed to convert the (64bit) conntrack counters to BE ordering.
>
...
> switch (priv->size) {
> + case 8: {
> + u64 src64;
> +
> + 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);
> + 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]);
> + }
> + break;
> + }
> + break;
That is horrid.
On a little-endian system you are byteswapping the data 3 times.
Image the code on a cpu that doesn't support misaligned transfers
and doesn't have a byteswap instruction.
David
Powered by blists - more mailing lists