netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: netdev@vger.kernel.org
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Subject: [PATCH/RFC] Adding IP(v6) address with scope link creates global address
Date: Mon, 7 Dec 2009 14:41:08 +0100	[thread overview]
Message-ID: <20091207134108.GA23087@amd64.fatal.se> (raw)
In-Reply-To: <20091125135945.GA7195@amd64.fatal.se>

Hello again!

Replying to myself (see http://www.spinics.net/lists/netdev/msg113943.html)
and attaching an untested patch to see if this sparks more interest.

On Wed, Nov 25, 2009 at 02:59:45PM +0100, Andreas Henriksson wrote:
> "Jedasothi" reported problems setting scope with iproute on newly added
> ipv6 addresses in:
> https://bugs.launchpad.net/ubuntu/+source/iproute/+bug/487745
> 
> > To reproduce bug run
> > ip addr add '::4/64' scope link dev eth0
> >
> > This results in a line seen with
> > ip addr show eth0
> > inet6 ::4/64 scope global tentative
> >
> > The label "global" is seen instead of "link".

I'd appreciate if someone could review and test this:


diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1fd0a3d..64d6d35 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2083,13 +2083,12 @@ err_exit:
  *	Manual configuration of address on an interface
  */
 static int inet6_addr_add(struct net *net, int ifindex, struct in6_addr *pfx,
-			  unsigned int plen, __u8 ifa_flags, __u32 prefered_lft,
-			  __u32 valid_lft)
+			  unsigned int plen, __u8 ifa_flags, int scope,
+			  __u32 prefered_lft, __u32 valid_lft)
 {
 	struct inet6_ifaddr *ifp;
 	struct inet6_dev *idev;
 	struct net_device *dev;
-	int scope;
 	u32 flags;
 	clock_t expires;
 	unsigned long timeout;
@@ -2110,7 +2109,8 @@ static int inet6_addr_add(struct net *net, int ifindex, struct in6_addr *pfx,
 	if ((idev = addrconf_add_dev(dev)) == NULL)
 		return -ENOBUFS;
 
-	scope = ipv6_addr_scope(pfx);
+	if (scope == 0)
+		scope = ipv6_addr_scope(pfx);
 
 	timeout = addrconf_timeout_fixup(valid_lft, HZ);
 	if (addrconf_finite_timeout(timeout)) {
@@ -2207,7 +2207,7 @@ int addrconf_add_ifaddr(struct net *net, void __user *arg)
 
 	rtnl_lock();
 	err = inet6_addr_add(net, ireq.ifr6_ifindex, &ireq.ifr6_addr,
-			     ireq.ifr6_prefixlen, IFA_F_PERMANENT,
+			     ireq.ifr6_prefixlen, IFA_F_PERMANENT, 0,
 			     INFINITY_LIFE_TIME, INFINITY_LIFE_TIME);
 	rtnl_unlock();
 	return err;
@@ -3328,6 +3328,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 		 */
 		return inet6_addr_add(net, ifm->ifa_index, pfx,
 				      ifm->ifa_prefixlen, ifa_flags,
+				      ifm->ifa_scope,
 				      preferred_lft, valid_lft);
 	}
 

  reply	other threads:[~2009-12-07 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 13:59 Adding IP(v6) address with scope link creates global address Andreas Henriksson
2009-12-07 13:41 ` Andreas Henriksson [this message]
2009-12-07 17:18   ` [PATCH/RFC] " Brian Haley
2009-12-07 19:30     ` Andreas Henriksson

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=20091207134108.GA23087@amd64.fatal.se \
    --to=andreas@fatal.se \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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).