* [PATCH] ipv6: order addresses by scope
@ 2006-06-09 18:14 Brian Haley
2006-07-10 22:00 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Brian Haley @ 2006-06-09 18:14 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 250 bytes --]
If IPv6 addresses are ordered by scope, then ipv6_dev_get_saddr() can
break-out of the device addr_list for() loop when the candidate source
address scope is less than the destination address scope.
Signed-off-by: Brian Haley <brian.haley@hp.com>
[-- Attachment #2: ip6order.patch --]
[-- Type: text/x-patch, Size: 1287 bytes --]
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 445006e..e1d6a6f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -509,6 +509,25 @@ void inet6_ifa_finish_destroy(struct ine
kfree(ifp);
}
+static void
+ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
+{
+ struct inet6_ifaddr *ifa, **ifap;
+
+ /*
+ * Each device address list is sorted in order of scope -
+ * global before linklocal.
+ */
+ for (ifap = &idev->addr_list; (ifa = *ifap) != NULL;
+ ifap = &ifa->if_next) {
+ if (ifp->scope > ifa->scope)
+ break;
+ }
+
+ ifp->if_next = *ifap;
+ *ifap = ifp;
+}
+
/* On success it returns ifp with increased reference count */
static struct inet6_ifaddr *
@@ -574,8 +593,7 @@ ipv6_add_addr(struct inet6_dev *idev, co
write_lock(&idev->lock);
/* Add to inet6_dev unicast addr list. */
- ifa->if_next = idev->addr_list;
- idev->addr_list = ifa;
+ ipv6_link_dev_addr(idev, ifa);
#ifdef CONFIG_IPV6_PRIVACY
if (ifa->flags&IFA_F_TEMPORARY) {
@@ -982,7 +1000,7 @@ int ipv6_dev_get_saddr(struct net_device
continue;
} else if (score.scope < hiscore.scope) {
if (score.scope < daddr_scope)
- continue;
+ break; /* addresses sorted by scope */
else {
score.rule = 2;
goto record_it;
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ipv6: order addresses by scope
2006-06-09 18:14 [PATCH] ipv6: order addresses by scope Brian Haley
@ 2006-07-10 22:00 ` David Miller
2006-07-10 22:18 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2006-07-10 22:00 UTC (permalink / raw)
To: brian.haley; +Cc: netdev, yoshfuji
From: Brian Haley <brian.haley@hp.com>
Date: Fri, 09 Jun 2006 14:14:50 -0400
> If IPv6 addresses are ordered by scope, then ipv6_dev_get_saddr() can
> break-out of the device addr_list for() loop when the candidate source
> address scope is less than the destination address scope.
>
> Signed-off-by: Brian Haley <brian.haley@hp.com>
This patch looks fine to me, it's an optimization and not a
correctness issue.
But I'd like an ACK from an ipv6 developer, such as Yoshifuji, before
adding this patch.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: order addresses by scope
2006-07-10 22:00 ` David Miller
@ 2006-07-10 22:18 ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-10 22:26 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2006-07-10 22:18 UTC (permalink / raw)
To: davem; +Cc: brian.haley, netdev, yoshfuji
In article <20060710.150045.128593827.davem@davemloft.net> (at Mon, 10 Jul 2006 15:00:45 -0700 (PDT)), David Miller <davem@davemloft.net> says:
> > If IPv6 addresses are ordered by scope, then ipv6_dev_get_saddr() can
> > break-out of the device addr_list for() loop when the candidate source
> > address scope is less than the destination address scope.
> >
> > Signed-off-by: Brian Haley <brian.haley@hp.com>
>
> This patch looks fine to me, it's an optimization and not a
> correctness issue.
>
> But I'd like an ACK from an ipv6 developer, such as Yoshifuji, before
> adding this patch.
I agree, too.
Note: People should not depend on the order of addresses.
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
--yoshfuji
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: order addresses by scope
2006-07-10 22:18 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2006-07-10 22:26 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2006-07-10 22:26 UTC (permalink / raw)
To: yoshfuji; +Cc: brian.haley, netdev
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Date: Mon, 10 Jul 2006 18:18:16 -0400 (EDT)
> In article <20060710.150045.128593827.davem@davemloft.net> (at Mon, 10 Jul 2006 15:00:45 -0700 (PDT)), David Miller <davem@davemloft.net> says:
>
> > > If IPv6 addresses are ordered by scope, then ipv6_dev_get_saddr() can
> > > break-out of the device addr_list for() loop when the candidate source
> > > address scope is less than the destination address scope.
> > >
> > > Signed-off-by: Brian Haley <brian.haley@hp.com>
> >
> > This patch looks fine to me, it's an optimization and not a
> > correctness issue.
> >
> > But I'd like an ACK from an ipv6 developer, such as Yoshifuji, before
> > adding this patch.
>
> I agree, too.
> Note: People should not depend on the order of addresses.
>
> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Thank you for reviewing, patch applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-07-10 22:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-09 18:14 [PATCH] ipv6: order addresses by scope Brian Haley
2006-07-10 22:00 ` David Miller
2006-07-10 22:18 ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-10 22:26 ` 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).