* [PATCH -next] nftables: byteorder: provide 64bit le/be conversion
@ 2016-01-08 9:29 Florian Westphal
2016-01-08 12:37 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2016-01-08 9:29 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Needed to convert the (64bit) conntrack counters to BE ordering.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
Also needs a small nft change, will submit it soon as part of
ct counter support series.
net/netfilter/nft_byteorder.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/net/netfilter/nft_byteorder.c b/net/netfilter/nft_byteorder.c
index fde5145..383c171 100644
--- a/net/netfilter/nft_byteorder.c
+++ b/net/netfilter/nft_byteorder.c
@@ -8,6 +8,7 @@
* Development of this code funded by Astaro AG (http://www.astaro.com/)
*/
+#include <asm/unaligned.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
@@ -39,6 +40,27 @@ static void nft_byteorder_eval(const struct nft_expr *expr,
d = (void *)dst;
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;
+ }
case 4:
switch (priv->op) {
case NFT_BYTEORDER_NTOH:
@@ -101,6 +123,7 @@ static int nft_byteorder_init(const struct nft_ctx *ctx,
switch (priv->size) {
case 2:
case 4:
+ case 8:
break;
default:
return -EINVAL;
--
2.4.10
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] nftables: byteorder: provide 64bit le/be conversion
2016-01-08 9:29 [PATCH -next] nftables: byteorder: provide 64bit le/be conversion Florian Westphal
@ 2016-01-08 12:37 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-01-08 12:37 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Fri, Jan 08, 2016 at 10:29:12AM +0100, Florian Westphal wrote:
> Needed to convert the (64bit) conntrack counters to BE ordering.
Applied, thanks Florian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-08 12:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08 9:29 [PATCH -next] nftables: byteorder: provide 64bit le/be conversion Florian Westphal
2016-01-08 12:37 ` 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.