* [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
@ 2009-10-11 13:45 YOSHIFUJI Hideaki
2009-10-12 7:32 ` Eric Dumazet
2009-10-12 9:08 ` David Miller
0 siblings, 2 replies; 7+ messages in thread
From: YOSHIFUJI Hideaki @ 2009-10-11 13:45 UTC (permalink / raw)
To: davem; +Cc: netdev, yoshfuji
ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
Do not use bit-shift if relay_prefixlen == 0;
relay_prefix << 32 does not result in 0.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
net/ipv6/sit.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 193d0c6..510d31f 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1014,9 +1014,12 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
ip6rd.prefixlen);
if (!ipv6_addr_equal(&prefix, &ip6rd.prefix))
goto done;
- relay_prefix = ip6rd.relay_prefix &
- htonl(0xffffffffUL <<
- (32 - ip6rd.relay_prefixlen));
+ if (ip6rd.relay_prefixlen)
+ relay_prefix = ip6rd.relay_prefix &
+ htonl(0xffffffffUL <<
+ (32 - ip6rd.relay_prefixlen));
+ else
+ relay_prefix = 0;
if (relay_prefix != ip6rd.relay_prefix)
goto done;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-11 13:45 [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0 YOSHIFUJI Hideaki
@ 2009-10-12 7:32 ` Eric Dumazet
2009-10-12 8:18 ` David Miller
2009-10-12 8:50 ` YOSHIFUJI Hideaki
2009-10-12 9:08 ` David Miller
1 sibling, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2009-10-12 7:32 UTC (permalink / raw)
To: YOSHIFUJI Hideaki; +Cc: davem, netdev
YOSHIFUJI Hideaki a écrit :
> ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
>
> Do not use bit-shift if relay_prefixlen == 0;
> relay_prefix << 32 does not result in 0.
>
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> ---
> net/ipv6/sit.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index 193d0c6..510d31f 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -1014,9 +1014,12 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
> ip6rd.prefixlen);
> if (!ipv6_addr_equal(&prefix, &ip6rd.prefix))
> goto done;
> - relay_prefix = ip6rd.relay_prefix &
> - htonl(0xffffffffUL <<
> - (32 - ip6rd.relay_prefixlen));
> + if (ip6rd.relay_prefixlen)
> + relay_prefix = ip6rd.relay_prefix &
> + htonl(0xffffffffUL <<
> + (32 - ip6rd.relay_prefixlen));
> + else
> + relay_prefix = 0;
> if (relay_prefix != ip6rd.relay_prefix)
> goto done;
>
Sorry I dont get it
u32 val = any_value ;
u32 relay_prefix = val & htonl(0xffffffffUL << 32) should give 0
If not, something is broken and should be fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-12 7:32 ` Eric Dumazet
@ 2009-10-12 8:18 ` David Miller
2009-10-12 9:03 ` YOSHIFUJI Hideaki
2009-10-12 8:50 ` YOSHIFUJI Hideaki
1 sibling, 1 reply; 7+ messages in thread
From: David Miller @ 2009-10-12 8:18 UTC (permalink / raw)
To: eric.dumazet; +Cc: yoshfuji, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 12 Oct 2009 09:32:41 +0200
> Sorry I dont get it
>
> u32 val = any_value ;
> u32 relay_prefix = val & htonl(0xffffffffUL << 32) should give 0
>
> If not, something is broken and should be fixed.
Indeed, it's "x >> 32" which is undefined and has to be done as
something like "(x >> 31) >> 1" when performed on a u32 object.
Yoshfuji is this patch really necessary?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-12 8:18 ` David Miller
@ 2009-10-12 9:03 ` YOSHIFUJI Hideaki
0 siblings, 0 replies; 7+ messages in thread
From: YOSHIFUJI Hideaki @ 2009-10-12 9:03 UTC (permalink / raw)
To: David Miller; +Cc: eric.dumazet, netdev
David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Mon, 12 Oct 2009 09:32:41 +0200
>
> > Sorry I dont get it
> >
> > u32 val = any_value ;
> > u32 relay_prefix = val & htonl(0xffffffffUL << 32) should give 0
> >
> > If not, something is broken and should be fixed.
>
> Indeed, it's "x >> 32" which is undefined and has to be done as
> something like "(x >> 31) >> 1" when performed on a u32 object.
>
> Yoshfuji is this patch really necessary?
Well, yes.
6rd allows 32 bit suffix (0 bit prefix).
--yoshfuji
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-12 7:32 ` Eric Dumazet
2009-10-12 8:18 ` David Miller
@ 2009-10-12 8:50 ` YOSHIFUJI Hideaki
2009-10-12 9:08 ` David Miller
1 sibling, 1 reply; 7+ messages in thread
From: YOSHIFUJI Hideaki @ 2009-10-12 8:50 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, netdev
Eric Dumazet wrote:
> YOSHIFUJI Hideaki a écrit :
> > ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
> >
> > Do not use bit-shift if relay_prefixlen == 0;
> > relay_prefix << 32 does not result in 0.
> >
> > Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> > ---
> > net/ipv6/sit.c | 9 ++++++---
> > 1 files changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> > index 193d0c6..510d31f 100644
> > --- a/net/ipv6/sit.c
> > +++ b/net/ipv6/sit.c
> > @@ -1014,9 +1014,12 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
> > ip6rd.prefixlen);
> > if (!ipv6_addr_equal(&prefix, &ip6rd.prefix))
> > goto done;
> > - relay_prefix = ip6rd.relay_prefix &
> > - htonl(0xffffffffUL <<
> > - (32 - ip6rd.relay_prefixlen));
> > + if (ip6rd.relay_prefixlen)
> > + relay_prefix = ip6rd.relay_prefix &
> > + htonl(0xffffffffUL <<
> > + (32 - ip6rd.relay_prefixlen));
> > + else
> > + relay_prefix = 0;
> > if (relay_prefix != ip6rd.relay_prefix)
> > goto done;
> >
>
>
> Sorry I dont get it
>
> u32 val = any_value ;
> u32 relay_prefix = val & htonl(0xffffffffUL << 32) should give 0
>
> If not, something is broken and should be fixed.
Unfortunately, on x86 architecture (80286 and later at least),
lower 5 bits (& 0x1f) are used for shift operation.
Thus, 0xffffffffUL << 32 gives 0xffffffffUL.
--yoshfuji
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-12 8:50 ` YOSHIFUJI Hideaki
@ 2009-10-12 9:08 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2009-10-12 9:08 UTC (permalink / raw)
To: yoshfuji; +Cc: eric.dumazet, netdev
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Mon, 12 Oct 2009 17:50:54 +0900
> Unfortunately, on x86 architecture (80286 and later at least),
> lower 5 bits (& 0x1f) are used for shift operation.
> Thus, 0xffffffffUL << 32 gives 0xffffffffUL.
Indeed, thanks for the explanation, I thought only right
shift mattered for this case of "shift count larger than
type".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
2009-10-11 13:45 [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0 YOSHIFUJI Hideaki
2009-10-12 7:32 ` Eric Dumazet
@ 2009-10-12 9:08 ` David Miller
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2009-10-12 9:08 UTC (permalink / raw)
To: yoshfuji; +Cc: netdev
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Sun, 11 Oct 2009 22:45:13 +0900
> ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0.
>
> Do not use bit-shift if relay_prefixlen == 0;
> relay_prefix << 32 does not result in 0.
>
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-10-12 9:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-11 13:45 [RESEND PATCH net-next-2.6 3/3] ipv6 sit: Set relay to 0.0.0.0 directly if relay_prefixlen == 0 YOSHIFUJI Hideaki
2009-10-12 7:32 ` Eric Dumazet
2009-10-12 8:18 ` David Miller
2009-10-12 9:03 ` YOSHIFUJI Hideaki
2009-10-12 8:50 ` YOSHIFUJI Hideaki
2009-10-12 9:08 ` David Miller
2009-10-12 9:08 ` David Miller
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).