All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
	werner@almesberger.net
Subject: Re: [PATCH] nfs: fix dead code of ipv6_addr_scope
Date: Sun, 22 Dec 2013 13:30:14 +0100	[thread overview]
Message-ID: <20131222123011.GA10241@omega> (raw)
In-Reply-To: <20131222023054.GH14073@order.stressinduktion.org>

Hi Hannes,

On Sun, Dec 22, 2013 at 03:30:54AM +0100, Hannes Frederic Sowa wrote:
> On Sat, Dec 21, 2013 at 02:32:54PM +0100, Alexander Aring wrote:
> > Hi Hannes,
> > 
> > On Sat, Dec 21, 2013 at 01:44:40PM +0100, Hannes Frederic Sowa wrote:
> > > On Sat, Dec 21, 2013 at 05:39:04AM +0100, Alexander Aring wrote:
> > > > The correct way to check on IPV6_ADDR_SCOPE_LINKLOCAL is to check with
> > > > the ipv6_addr_src_scope function.
> > > > 
> > > > Currently this can't be work, because ipv6_addr_scope returns a int with
> > > > a mask of IPV6_ADDR_SCOPE_MASK (0x00f0U) and IPV6_ADDR_SCOPE_LINKLOCAL
> > > > is 0x02. So the condition is always false.
> > > > 
> > > > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > > > ---
> > > > I think ipv6_addr_src_scope should be correct, can somebody from netdev ml
> > > > confirm this please?
> > > > I stumple over that and I did not compile and test it. Maybe this is something
> > > > for stable?
> > > > 
> > > >  fs/nfs/nfs4filelayoutdev.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
> > > > index c7c295e5..efac602 100644
> > > > --- a/fs/nfs/nfs4filelayoutdev.c
> > > > +++ b/fs/nfs/nfs4filelayoutdev.c
> > > > @@ -95,7 +95,7 @@ same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2)
> > > >  		b6 = (struct sockaddr_in6 *)addr2;
> > > >  
> > > >  		/* LINKLOCAL addresses must have matching scope_id */
> > > > -		if (ipv6_addr_scope(&a6->sin6_addr) ==
> > > > +		if (ipv6_addr_src_scope(&a6->sin6_addr) ==
> > > >  		    IPV6_ADDR_SCOPE_LINKLOCAL &&
> > > >  		    a6->sin6_scope_id != b6->sin6_scope_id)
> > > >  			return false;
> > > 
> > > Good catch!
> > > 
> > thanks.
> > 
> > I am still unsure if sctp is correct or not, I think it isn't correct.
> > Because we compare and don't check if any bit is set.
> > 
> > We don't use IPV6_ADDR_SCOPE_TYPE here. We use IPV6_ADDR_TYPE. But we can't
> > compare it.
> 
> Actually, this is fine, too. ipv6_addr_scope does mask the addr_type with
> IPV6_ADDR_SCOPE_MASK (which is 0x00f0U). If you look at addrconf_core.c you
> see that the 4 bits stand by itself each time.
> 
> Actually it seems ipv6_addr_src_scope is better suitable for multicast scope
> handling and ipv6_addr_scope with IFA_{HOST,LINK,SITE} is fine for
> non-multicast. In this case there is no difference.
> 
ah thanks, now I understand it!

so an alternative would be:

if (ipv6_addr_scope(&a6->sin6_addr) & IPV6_ADDR_LINKLOCAL &&
	a6->sin6_scope_id != b6->sin6_scope_id)
	...

maybe this is a little bit faster instead of ipv6_addr_src_scope.
Should I resend a v2 with the faster solution?

> Maybe an int ipv6_cmp_sockaddr(struct in6_addr *a1, int scope1,
> 			  struct in6_addr *a2, int scope2)
> or
> int ipv6_cmp_sockaddr(struct sockaddr_in6 *s1,
> 		      struct sockaddr_in6 *s2)
> 

I don't understand why we need such a function here. We only check if
"a6" is linklocal and has a different sin6_scope_id than "b6" sin6_scope_id
and we don't compare "a6" and "b6" here (then "b6" should be a
linklocal, too). I think it's too abstract for me what exactly "compare"
means in this case. :-)

- Alex

WARNING: multiple messages have this Message-ID (diff)
From: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	werner-SEdMjqphH88wryQfseakQg@public.gmane.org
Subject: Re: [PATCH] nfs: fix dead code of ipv6_addr_scope
Date: Sun, 22 Dec 2013 13:30:14 +0100	[thread overview]
Message-ID: <20131222123011.GA10241@omega> (raw)
In-Reply-To: <20131222023054.GH14073-5j1vdhnGyZutBveJljeh2VPnkB77EeZ12LY78lusg7I@public.gmane.org>

Hi Hannes,

On Sun, Dec 22, 2013 at 03:30:54AM +0100, Hannes Frederic Sowa wrote:
> On Sat, Dec 21, 2013 at 02:32:54PM +0100, Alexander Aring wrote:
> > Hi Hannes,
> > 
> > On Sat, Dec 21, 2013 at 01:44:40PM +0100, Hannes Frederic Sowa wrote:
> > > On Sat, Dec 21, 2013 at 05:39:04AM +0100, Alexander Aring wrote:
> > > > The correct way to check on IPV6_ADDR_SCOPE_LINKLOCAL is to check with
> > > > the ipv6_addr_src_scope function.
> > > > 
> > > > Currently this can't be work, because ipv6_addr_scope returns a int with
> > > > a mask of IPV6_ADDR_SCOPE_MASK (0x00f0U) and IPV6_ADDR_SCOPE_LINKLOCAL
> > > > is 0x02. So the condition is always false.
> > > > 
> > > > Signed-off-by: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > > ---
> > > > I think ipv6_addr_src_scope should be correct, can somebody from netdev ml
> > > > confirm this please?
> > > > I stumple over that and I did not compile and test it. Maybe this is something
> > > > for stable?
> > > > 
> > > >  fs/nfs/nfs4filelayoutdev.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
> > > > index c7c295e5..efac602 100644
> > > > --- a/fs/nfs/nfs4filelayoutdev.c
> > > > +++ b/fs/nfs/nfs4filelayoutdev.c
> > > > @@ -95,7 +95,7 @@ same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2)
> > > >  		b6 = (struct sockaddr_in6 *)addr2;
> > > >  
> > > >  		/* LINKLOCAL addresses must have matching scope_id */
> > > > -		if (ipv6_addr_scope(&a6->sin6_addr) ==
> > > > +		if (ipv6_addr_src_scope(&a6->sin6_addr) ==
> > > >  		    IPV6_ADDR_SCOPE_LINKLOCAL &&
> > > >  		    a6->sin6_scope_id != b6->sin6_scope_id)
> > > >  			return false;
> > > 
> > > Good catch!
> > > 
> > thanks.
> > 
> > I am still unsure if sctp is correct or not, I think it isn't correct.
> > Because we compare and don't check if any bit is set.
> > 
> > We don't use IPV6_ADDR_SCOPE_TYPE here. We use IPV6_ADDR_TYPE. But we can't
> > compare it.
> 
> Actually, this is fine, too. ipv6_addr_scope does mask the addr_type with
> IPV6_ADDR_SCOPE_MASK (which is 0x00f0U). If you look at addrconf_core.c you
> see that the 4 bits stand by itself each time.
> 
> Actually it seems ipv6_addr_src_scope is better suitable for multicast scope
> handling and ipv6_addr_scope with IFA_{HOST,LINK,SITE} is fine for
> non-multicast. In this case there is no difference.
> 
ah thanks, now I understand it!

so an alternative would be:

if (ipv6_addr_scope(&a6->sin6_addr) & IPV6_ADDR_LINKLOCAL &&
	a6->sin6_scope_id != b6->sin6_scope_id)
	...

maybe this is a little bit faster instead of ipv6_addr_src_scope.
Should I resend a v2 with the faster solution?

> Maybe an int ipv6_cmp_sockaddr(struct in6_addr *a1, int scope1,
> 			  struct in6_addr *a2, int scope2)
> or
> int ipv6_cmp_sockaddr(struct sockaddr_in6 *s1,
> 		      struct sockaddr_in6 *s2)
> 

I don't understand why we need such a function here. We only check if
"a6" is linklocal and has a different sin6_scope_id than "b6" sin6_scope_id
and we don't compare "a6" and "b6" here (then "b6" should be a
linklocal, too). I think it's too abstract for me what exactly "compare"
means in this case. :-)

- Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-12-22 12:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-21  4:39 [PATCH] nfs: fix dead code of ipv6_addr_scope Alexander Aring
2013-12-21  4:39 ` Alexander Aring
2013-12-21  8:17 ` Alexander Aring
2013-12-21 12:44 ` Hannes Frederic Sowa
2013-12-21 12:44   ` Hannes Frederic Sowa
2013-12-21 13:32   ` Alexander Aring
2013-12-21 13:32     ` Alexander Aring
2013-12-22  2:30     ` Hannes Frederic Sowa
2013-12-22  2:30       ` Hannes Frederic Sowa
2013-12-22 12:30       ` Alexander Aring [this message]
2013-12-22 12:30         ` Alexander Aring
2013-12-22 12:38         ` Hannes Frederic Sowa
2013-12-22 12:38           ` Hannes Frederic Sowa

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=20131222123011.GA10241@omega \
    --to=alex.aring@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=werner@almesberger.net \
    /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 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.