From: Hans Schillstrom <hidden> Date: 2012-05-14 13:42:26
A mix of u32 and __be32 causes endian warning.
Switch to __be32 and __be16 for addresses and ports.
Added (__force u32) at some places.
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Hans Schillstrom <redacted>
---
include/linux/netfilter/xt_HMARK.h | 4 ++--
net/netfilter/xt_HMARK.c | 35 ++++++++++++++++++-----------------
2 files changed, 20 insertions(+), 19 deletions(-)
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2012-05-14 14:40:52
On Mon, May 14, 2012 at 03:42:23PM +0200, Hans Schillstrom wrote:
quoted hunk
A mix of u32 and __be32 causes endian warning.
Switch to __be32 and __be16 for addresses and ports.
Added (__force u32) at some places.
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Hans Schillstrom <redacted>
---
include/linux/netfilter/xt_HMARK.h | 4 ++--
net/netfilter/xt_HMARK.c | 35 ++++++++++++++++++-----------------
2 files changed, 20 insertions(+), 19 deletions(-)
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Hans Schillstrom <hidden> Date: 2012-05-14 15:05:57
On Monday 14 May 2012 16:40:52 Pablo Neira Ayuso wrote:
On Mon, May 14, 2012 at 03:42:23PM +0200, Hans Schillstrom wrote:
quoted
A mix of u32 and __be32 causes endian warning.
Switch to __be32 and __be16 for addresses and ports.
Added (__force u32) at some places.
Reported-by: Dan Carpenter <redacted>
Signed-off-by: Hans Schillstrom <redacted>
---
include/linux/netfilter/xt_HMARK.h | 4 ++--
net/netfilter/xt_HMARK.c | 35 ++++++++++++++++++-----------------
2 files changed, 20 insertions(+), 19 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-05-14 15:24:39
On Mon, 2012-05-14 at 17:05 +0200, Jan Engelhardt wrote:
On Monday 2012-05-14 16:40, Pablo Neira Ayuso wrote:
quoted
quoted
- if (t->uports.p16.dst < t->uports.p16.src)
+ if (ntohs(t->uports.p16.dst) < ntohs(t->uports.p16.src))
Do we really need this to make sparse happy?
You need it to make *maths* happy.
Consider
384 < 65407
but
ntohs(384) > ntohs(65407)
<=> 32769 > 32767
--
Doesnt matter at all in this context.
Take a look at
void __skb_get_rxhash(struct sk_buff *skb)
if ((__force u16)keys.port16[1] < (__force u16)keys.port16[0])
swap(...)
From: Eric Dumazet <hidden> Date: 2012-05-14 16:24:34
On Mon, 2012-05-14 at 18:09 +0200, Hans Schillstrom wrote:
This context can contain both le & be machines,
so at least in hmark it make sense
Before jhash() and its shuffle ? What do you mean ?
Please respin your patch using (__force u16/u32) instead of
useless/expensive ntohs() / ntohl() (in _this_ context of hashing)
If you compare two 32bits values, of course they must have same
ordering, but seeding jhash() is another matter.
(Granted all calls use the same ordering of course)
sparse is great tool, but if you add useless ntohl() calls to make
sparse silent, then its probably better to not use sparse.
From: Hans Schillstrom <hidden> Date: 2012-05-14 17:51:34
On Monday 14 May 2012 18:24:34 Eric Dumazet wrote:
On Mon, 2012-05-14 at 18:09 +0200, Hans Schillstrom wrote:
quoted
This context can contain both le & be machines,
so at least in hmark it make sense
Before jhash() and its shuffle ? What do you mean ?
I want that a Big endian machine should produce the same
hash value independent of flow direction as a Little endian.
OK, I missed ntohl() before calling jhash_3words()
Correct me if I'm wrong here (have no big endian machine available for test)
jhash_3words() and __jhash_final() seems to be "endian" safe.
So by doing the expensive ntohl on addresses and ports into jhash_3words()
it will produce the same value on both be and le.
That's why I want to have the ntohs() / ntohl() when comparing.
Please respin your patch using (__force u16/u32) instead of
useless/expensive ntohs() / ntohl() (in _this_ context of hashing)
If you compare two 32bits values, of course they must have same
ordering, but seeding jhash() is another matter.
(Granted all calls use the same ordering of course)
sparse is great tool, but if you add useless ntohl() calls to make
sparse silent, then its probably better to not use sparse.
From: Eric Dumazet <hidden> Date: 2012-05-14 18:28:52
On Mon, 2012-05-14 at 19:51 +0200, Hans Schillstrom wrote:
On Monday 14 May 2012 18:24:34 Eric Dumazet wrote:
quoted
On Mon, 2012-05-14 at 18:09 +0200, Hans Schillstrom wrote:
quoted
This context can contain both le & be machines,
so at least in hmark it make sense
Before jhash() and its shuffle ? What do you mean ?
I want that a Big endian machine should produce the same
hash value independent of flow direction as a Little endian.
So one machine can be both le and be ? at the same time ?
OK, I missed ntohl() before calling jhash_3words()
Correct me if I'm wrong here (have no big endian machine available for test)
jhash_3words() and __jhash_final() seems to be "endian" safe.
So by doing the expensive ntohl on addresses and ports into jhash_3words()
it will produce the same value on both be and le.
And what is the purpose of the jhash output ? Is is sent to other
machines on the network, or only localy used ?
That's why I want to have the ntohs() / ntohl() when comparing.
If xt_HMARK depends on a particular bit ordering to jhash() input, then
something is really wrong. I mean it.
jhash() primary purpose it to shuffle input.
We use (__force u32) everywhere in network tree to avoid sparse
warnings. Please grep for them.
On Monday 14 May 2012 18:24:34 Eric Dumazet wrote:
quoted
On Mon, 2012-05-14 at 18:09 +0200, Hans Schillstrom wrote:
quoted
This context can contain both le & be machines,
so at least in hmark it make sense
Before jhash() and its shuffle ? What do you mean ?
I want that a Big endian machine should produce the same
hash value independent of flow direction as a Little endian.
OK, I missed ntohl() before calling jhash_3words()
Correct me if I'm wrong here (have no big endian machine available for test)
jhash_3words() and __jhash_final() seems to be "endian" safe.
No, but as Eric wrote: what is the point in forcing the same hash value
for the same input on big endian and little endian machines? Are you going
to transfer the hash value between machines?
Best regards,
Jozsef
-
E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2012-05-14 19:02:11
On Mon, May 14, 2012 at 08:35:26PM +0200, Jozsef Kadlecsik wrote:
On Mon, 14 May 2012, Hans Schillstrom wrote:
quoted
On Monday 14 May 2012 18:24:34 Eric Dumazet wrote:
quoted
On Mon, 2012-05-14 at 18:09 +0200, Hans Schillstrom wrote:
quoted
This context can contain both le & be machines,
so at least in hmark it make sense
Before jhash() and its shuffle ? What do you mean ?
I want that a Big endian machine should produce the same
hash value independent of flow direction as a Little endian.
OK, I missed ntohl() before calling jhash_3words()
Correct me if I'm wrong here (have no big endian machine available for test)
jhash_3words() and __jhash_final() seems to be "endian" safe.
No, but as Eric wrote: what is the point in forcing the same hash value
for the same input on big endian and little endian machines? Are you going
to transfer the hash value between machines?
IIRC, Hans wants that, in case you have a cluster composed of system
with different endianess, the hash mark calculated will be the same
in both systems. To ensure that the distribution is consistent with
independency of the endianess.
From: Eric Dumazet <hidden> Date: 2012-05-14 19:13:55
On Mon, 2012-05-14 at 21:02 +0200, Pablo Neira Ayuso wrote:
IIRC, Hans wants that, in case you have a cluster composed of system
with different endianess, the hash mark calculated will be the same
in both systems. To ensure that the distribution is consistent with
independency of the endianess.
Then jhash() must be audited to make sure its output is OK with this
requirement.
From: Hans Schillström <hidden> Date: 2012-05-15 05:57:22
On Mon, 2012-05-14 at 21:02 +0200, Pablo Neira Ayuso wrote:
quoted
IIRC, Hans wants that, in case you have a cluster composed of system
with different endianess, the hash mark calculated will be the same
in both systems. To ensure that the distribution is consistent with
independency of the endianess.
Then jhash() must be audited to make sure its output is OK with this
requirement.
Have done that, and made tests on a mips 32 running debian
It was as expected jhash3_words is endian safe, while jhash() is not
From: Hans Schillström <hidden> Date: 2012-05-15 07:33:17
On Mon, 2012-05-14 at 17:05 +0200, Jan Engelhardt wrote:
On Monday 2012-05-14 16:40, Pablo Neira Ayuso wrote:
quoted
quoted
- if (t->uports.p16.dst < t->uports.p16.src)
+ if (ntohs(t->uports.p16.dst) < ntohs(t->uports.p16.src))
Do we really need this to make sparse happy?
This looks insane to make sparse happy
static inline u32 addr_mask(const __be32 *addr32, const __be32 *mask)
{
return (__force u32)htonl((__force u32)(*addr32 & *mask));
}
with the "more logic" way to write it sparse complains on everything...
static inline u32 addr_mask(const __be32 *addr32, const __be32 *mask)
{
return htonl(*addr32 & *mask);
}
Is there a better way to do this ?