From: Jarek Poplawski <jarkao2@o2.pl>
To: jamal <hadi@cyberus.ca>
Cc: Radu Rendec <radu.rendec@ines.ro>, netdev@vger.kernel.org
Subject: Re: Endianness problem with u32 classifier hash masks
Date: Mon, 5 Nov 2007 10:12:31 +0100 [thread overview]
Message-ID: <20071105091231.GA1933@ff.dom.local> (raw)
In-Reply-To: <1194220693.4438.75.camel@localhost>
On Sun, Nov 04, 2007 at 06:58:13PM -0500, jamal wrote:
> On Sun, 2007-04-11 at 02:17 +0100, Jarek Poplawski wrote:
>
> > So, even if not full ntohl(), some byte moving seems to be
> > necessary here.
>
> I thinking you were close. I am afraid my brain is congested, even the
> esspresso didnt help my thinking.
> It could be done with just fshift on the slow path (config time) of one
> was to think hard;-> I am not too happy with the extra conversion on the
> fast path, but how about the untested attached patch?
>
> cheers,
> jamal
>
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 9e98c6e..6dd569b 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
> @@ -93,7 +93,7 @@ static __inline__ unsigned u32_hash_fold(u32 key, struct tc_u32_sel *sel, u8 fsh
> {
> unsigned h = (key & sel->hmask)>>fshift;
>
> - return h;
> + return ntohl(h);
> }
Seems not good or I miss something:
host order:
address: xx.xx.xf.fx
hmask : 00.00.0f.f0
net order:
address: fx.xf.xx.xx
hmask : f0.0f.00.00
fshift after ntohl(s->hmask): 4
so, above:
h = (fx.xf.xx.xx & f0.0f.00.00) >> 4;
h == 0f.00.f0.00
return 00.f0.00.0f (?)
But, I hope, maybe Radu could check this better - after his analyze
it looks like his coffee is the best!
Currently I think this should be possible to get this one important
byte with 2 shifts, but it needs much more coffee on my slow path...
But, this wouldn't be very readable and I'm not sure the gain would
be really visible with current cpus, so maybe this first proposal is
quite reasonable. Then, I'd only suggest to Radu to change the '*'
style a bit in the comment and to sign this off, if you agree?
Cheers,
Jarek P.
BTW: when looking around this I think, maybe, in u32_change():
1) if (--divisor > 0x100) should be probably ">=", but is it really
needed to check this 2 times (including tc)?
2) this while() loop for n->fshift could be replaced with ffs()?
>
> static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res)
> @@ -615,7 +615,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
> n->handle = handle;
> {
> u8 i = 0;
> - u32 mask = s->hmask;
> + u32 mask = ntohl(s->hmask);
> if (mask) {
> while (!(mask & 1)) {
> i++;
next prev parent reply other threads:[~2007-11-05 9:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-01 17:55 Endianness problem with u32 classifier hash masks Radu Rendec
2007-11-02 17:31 ` Jarek Poplawski
2007-11-02 23:23 ` jamal
2007-11-03 23:39 ` Jarek Poplawski
2007-11-03 23:58 ` Jarek Poplawski
2007-11-04 0:30 ` Jarek Poplawski
2007-11-04 1:17 ` Jarek Poplawski
2007-11-04 23:58 ` jamal
2007-11-05 9:12 ` Jarek Poplawski [this message]
2007-11-05 12:59 ` Radu Rendec
2007-11-05 13:43 ` jamal
2007-11-05 14:49 ` Jarek Poplawski
2007-11-05 16:12 ` Radu Rendec
2007-11-05 13:52 ` Jarek Poplawski
2007-11-05 14:06 ` jamal
2007-11-05 17:31 ` Radu Rendec
2007-11-05 21:06 ` Jarek Poplawski
2007-11-05 21:28 ` Jarek Poplawski
2007-11-05 22:27 ` jamal
2007-11-06 0:02 ` Jarek Poplawski
2007-11-06 0:12 ` Jarek Poplawski
2007-11-06 8:09 ` Radu Rendec
2007-11-06 13:34 ` jamal
2007-11-06 14:25 ` Jarek Poplawski
2007-11-06 14:43 ` jamal
2007-11-06 17:00 ` Radu Rendec
2007-11-06 20:28 ` Jarek Poplawski
2007-11-07 9:22 ` David Miller
2007-11-07 12:56 ` Jarek Poplawski
2007-11-07 13:42 ` jamal
2007-11-07 13:55 ` Radu Rendec
2007-11-07 14:35 ` Radu Rendec
2007-11-08 11:07 ` [PATCH] [PKT_SCHED] CLS_U32: Use ffs() instead of C code on hash mask to get first set bit Radu Rendec
2007-11-08 11:37 ` Jarek Poplawski
2007-11-08 13:45 ` jamal
2007-11-11 5:55 ` David Miller
2007-11-05 13:47 ` Endianness problem with u32 classifier hash masks jamal
2007-11-05 14:35 ` Jarek Poplawski
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=20071105091231.GA1933@ff.dom.local \
--to=jarkao2@o2.pl \
--cc=hadi@cyberus.ca \
--cc=netdev@vger.kernel.org \
--cc=radu.rendec@ines.ro \
/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).