From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Ander Juaristi <a@juaristi.eus>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] netfilter: Introduce new 64-bit helper functions
Date: Thu, 15 Aug 2019 11:56:58 +0200 [thread overview]
Message-ID: <20190815095658.rrgkaxgeqv3eccri@salvia> (raw)
In-Reply-To: <052bfb99-22c1-749f-464d-ab63ad8d0e4c@juaristi.eus>
On Thu, Aug 15, 2019 at 11:46:04AM +0200, Ander Juaristi wrote:
>
>
> On 13/8/19 20:58, Pablo Neira Ayuso wrote:
> > On Tue, Aug 13, 2019 at 08:38:19PM +0200, Ander Juaristi wrote:
> > [...]
> >> diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
> >> index 9b624566b82d..aa33ada8728a 100644
> >> --- a/include/net/netfilter/nf_tables.h
> >> +++ b/include/net/netfilter/nf_tables.h
> >> @@ -2,6 +2,7 @@
> >> #ifndef _NET_NF_TABLES_H
> >> #define _NET_NF_TABLES_H
> >>
> >> +#include <asm/unaligned.h>
> >> #include <linux/list.h>
> >> #include <linux/netfilter.h>
> >> #include <linux/netfilter/nfnetlink.h>
> >> @@ -119,6 +120,16 @@ static inline void nft_reg_store8(u32 *dreg, u8 val)
> >> *(u8 *)dreg = val;
> >> }
> >>
> >> +static inline void nft_reg_store64(u32 *dreg, u64 val)
> >> +{
> >> + put_unaligned(val, (u64 *)dreg);
> >> +}
> >> +
> >> +static inline u64 nft_reg_load64(u32 *sreg)
> >> +{
> >> + return get_unaligned((u64 *)sreg);
> >> +}
> >
> > Please, add these function definition below _load16() and _store16().
>
> You mean you'd like them ordered from smaller to larger?
>
> nft_reg_store8
> nft_reg_load8
> nft_reg_store16
> nft_reg_load16
> nft_reg_store64
> nft_reg_load64
yes please.
> >> +
> >> static inline u16 nft_reg_load16(u32 *sreg)
> >> {
> >> return *(u16 *)sreg;
> >> diff --git a/net/netfilter/nft_byteorder.c b/net/netfilter/nft_byteorder.c
> >> index e06318428ea0..a25a222d94c8 100644
> >> --- a/net/netfilter/nft_byteorder.c
> >> +++ b/net/netfilter/nft_byteorder.c
> >> @@ -43,14 +43,14 @@ void nft_byteorder_eval(const struct nft_expr *expr,
> >> switch (priv->op) {
> >> case NFT_BYTEORDER_NTOH:
> >
> > This is network-to-host byteorder.
> >
> >> for (i = 0; i < priv->len / 8; i++) {
> >> - src64 = get_unaligned((u64 *)&src[i]);
> >> - put_unaligned_be64(src64, &dst[i]);
> >> + src64 = nft_reg_load64(&src[i]);
> >> + nft_reg_store64(&dst[i], cpu_to_be64(src64));
> >
> > This looks inverted, this should be:
> >
> > nft_reg_store64(&dst[i], be64_to_cpu(src64));
> >
> > right?
> >
> >> }
> >> break;
> >> case NFT_BYTEORDER_HTON:
> >
> > Here, network-to-host byteorder:
> >
> >> for (i = 0; i < priv->len / 8; i++) {
> >> - src64 = get_unaligned_be64(&src[i]);
> >> - put_unaligned(src64, (u64 *)&dst[i]);
> >> + src64 = be64_to_cpu(nft_reg_load64(&src[i]));
> >
> > and this:
> >
> > src64 = (__force __u64)
> > cpu_to_be64(nft_reg_load64(&src[i]));
> >
>
> My bad. Yes, I've just fixed them.
Great.
prev parent reply other threads:[~2019-08-15 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 18:38 [PATCH v4 1/2] netfilter: Introduce new 64-bit helper functions Ander Juaristi
2019-08-13 18:38 ` [PATCH v4 2/2] netfilter: nft_meta: support for time matching Ander Juaristi
2019-08-13 19:10 ` Pablo Neira Ayuso
2019-08-13 19:14 ` Florian Westphal
2019-08-13 19:15 ` Florian Westphal
2019-08-13 18:58 ` [PATCH v4 1/2] netfilter: Introduce new 64-bit helper functions Pablo Neira Ayuso
2019-08-15 9:46 ` Ander Juaristi
2019-08-15 9:56 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190815095658.rrgkaxgeqv3eccri@salvia \
--to=pablo@netfilter.org \
--cc=a@juaristi.eus \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).