netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv6: del unreachable route when an addr is deleted on lo
@ 2012-09-25 10:24 Nicolas Dichtel
  2012-09-25 13:43 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2012-09-25 10:24 UTC (permalink / raw)
  To: netdev, yoshfuji, davem; +Cc: Nicolas Dichtel

When an address is added on loopback (ip -6 a a 2002::1/128 dev lo), two routes
are added:
 - one in the local table:
    local 2002::1 via :: dev lo  proto none  metric 0
 - one the in main table (for the prefix):
    unreachable 2002::1 dev lo  proto kernel  metric 256  error -101

When the address is deleted, the route inserted in the main table remains
because we use rt6_lookup(), which returns NULL when dst->error is set, which
is the case here! Thus, it is better to use ip6_route_lookup() to avoid this
kind of filter.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/addrconf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6bc85f7..b6b2f9f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -788,8 +788,12 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		struct in6_addr prefix;
 		struct rt6_info *rt;
 		struct net *net = dev_net(ifp->idev->dev);
+		struct flowi6 fl6 = {};
 		ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
-		rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
+		fl6.flowi6_oif = ifp->idev->dev->ifindex;
+		fl6.daddr = prefix;
+		rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
+							 RT6_LOOKUP_F_IFACE);
 
 		if (rt && addrconf_is_prefix_route(rt)) {
 			if (onlink == 0) {
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ipv6: del unreachable route when an addr is deleted on lo
  2012-09-25 10:24 [PATCH] ipv6: del unreachable route when an addr is deleted on lo Nicolas Dichtel
@ 2012-09-25 13:43 ` Eric Dumazet
  2012-09-26 10:04   ` [PATCH v2] " Nicolas Dichtel
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2012-09-25 13:43 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: netdev, yoshfuji, davem

On Tue, 2012-09-25 at 12:24 +0200, Nicolas Dichtel wrote:
> When an address is added on loopback (ip -6 a a 2002::1/128 dev lo), two routes
> are added:
>  - one in the local table:
>     local 2002::1 via :: dev lo  proto none  metric 0
>  - one the in main table (for the prefix):
>     unreachable 2002::1 dev lo  proto kernel  metric 256  error -101
> 
> When the address is deleted, the route inserted in the main table remains
> because we use rt6_lookup(), which returns NULL when dst->error is set, which
> is the case here! Thus, it is better to use ip6_route_lookup() to avoid this
> kind of filter.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  net/ipv6/addrconf.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 6bc85f7..b6b2f9f 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -788,8 +788,12 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
>  		struct in6_addr prefix;
>  		struct rt6_info *rt;
>  		struct net *net = dev_net(ifp->idev->dev);
> +		struct flowi6 fl6 = {};
>  		ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
> -		rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
> +		fl6.flowi6_oif = ifp->idev->dev->ifindex;
> +		fl6.daddr = prefix;
> +		rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
> +							 RT6_LOOKUP_F_IFACE);
>  

rt cant be NULL here ( but can be ip6_null_entry )

>  		if (rt && addrconf_is_prefix_route(rt)) {

So this condition is obsolete...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] ipv6: del unreachable route when an addr is deleted on lo
  2012-09-25 13:43 ` Eric Dumazet
@ 2012-09-26 10:04   ` Nicolas Dichtel
  2012-10-01 20:49     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2012-09-26 10:04 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, yoshfuji, davem, Nicolas Dichtel

When an address is added on loopback (ip -6 a a 2002::1/128 dev lo), two routes
are added:
 - one in the local table:
    local 2002::1 via :: dev lo  proto none  metric 0
 - one the in main table (for the prefix):
    unreachable 2002::1 dev lo  proto kernel  metric 256  error -101

When the address is deleted, the route inserted in the main table remains
because we use rt6_lookup(), which returns NULL when dst->error is set, which
is the case here! Thus, it is better to use ip6_route_lookup() to avoid this
kind of filter.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
v2: rt cannot be NULL, so adjust the test after ip6_route_lookup()

 net/ipv6/addrconf.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6bc85f7..ea3e9af 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -788,10 +788,16 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		struct in6_addr prefix;
 		struct rt6_info *rt;
 		struct net *net = dev_net(ifp->idev->dev);
+		struct flowi6 fl6 = {};
+
 		ipv6_addr_prefix(&prefix, &ifp->addr, ifp->prefix_len);
-		rt = rt6_lookup(net, &prefix, NULL, ifp->idev->dev->ifindex, 1);
+		fl6.flowi6_oif = ifp->idev->dev->ifindex;
+		fl6.daddr = prefix;
+		rt = (struct rt6_info *)ip6_route_lookup(net, &fl6,
+							 RT6_LOOKUP_F_IFACE);
 
-		if (rt && addrconf_is_prefix_route(rt)) {
+		if (rt != net->ipv6.ip6_null_entry &&
+		    addrconf_is_prefix_route(rt)) {
 			if (onlink == 0) {
 				ip6_del_rt(rt);
 				rt = NULL;
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ipv6: del unreachable route when an addr is deleted on lo
  2012-09-26 10:04   ` [PATCH v2] " Nicolas Dichtel
@ 2012-10-01 20:49     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-10-01 20:49 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: eric.dumazet, netdev, yoshfuji

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Wed, 26 Sep 2012 12:04:55 +0200

> When an address is added on loopback (ip -6 a a 2002::1/128 dev lo), two routes
> are added:
>  - one in the local table:
>     local 2002::1 via :: dev lo  proto none  metric 0
>  - one the in main table (for the prefix):
>     unreachable 2002::1 dev lo  proto kernel  metric 256  error -101
> 
> When the address is deleted, the route inserted in the main table remains
> because we use rt6_lookup(), which returns NULL when dst->error is set, which
> is the case here! Thus, it is better to use ip6_route_lookup() to avoid this
> kind of filter.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
> v2: rt cannot be NULL, so adjust the test after ip6_route_lookup()

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-01 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-25 10:24 [PATCH] ipv6: del unreachable route when an addr is deleted on lo Nicolas Dichtel
2012-09-25 13:43 ` Eric Dumazet
2012-09-26 10:04   ` [PATCH v2] " Nicolas Dichtel
2012-10-01 20:49     ` 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).