All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
@ 2013-03-28 13:27 Balakumaran Kannan
  2013-03-28 13:44 ` Eric Dumazet
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-03-28 13:27 UTC (permalink / raw)
  To: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	eric.dumazet
  Cc: Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
interface. After down-up, routes of other interface's IPv6 addresses through
'lo' are lost.

IPv6 addresses assigned to all interfaces are routed through 'lo' for internal
communication. Once 'lo' is down, those routing entries are removed from
routing table. But those removed entries are not being re-created properly when
'lo' is brought up. So IPv6 addresses of other interfaces becomes unreachable
from the same machine. Also this breaks communication with other machines
because of NDISC packet processing failure.

This patch fixes this issue by reading all interface's IPv6 addresses and
adding them to IPv6 routing table while bringing up 'lo'.

Patch is prepared for Linux-3.9.rc4 kernel.

Signed-off-by: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
Signed-off-by: Maruthi Thotad <Maruthi.Thotad@ap.sm.sony.com>
---
This is version-2 of the patch sent earlier.
[Ref: http://marc.info/?l=linux-netdev&m=136437848103355&w=2]

Change Log:
 1. Used 'for_each_netdev_rcu' instead of while loop.
 2. Added required locks.
 3. Skipping IPv6 addresses with 'IFA_F_DADFAILED' or 'IFA_F_TENTATIVE' flags

==Testing==
Before applying the patch:
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$

After applying the patch:
$ route -A inet6
Kernel IPv6 routing
table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$
---
--- linux-3.9-rc4/net/ipv6/addrconf.c.orig	2013-03-27 10:40:26.382569527 +0530
+++ linux-3.9-rc4/net/ipv6/addrconf.c	2013-03-28 18:29:00.492241840 +0530
@@ -2529,6 +2529,9 @@ static void sit_add_v4_addrs(struct inet
 static void init_loopback(struct net_device *dev)
 {
 	struct inet6_dev  *idev;
+	struct net_device *sp_dev;
+	struct inet6_ifaddr *sp_ifa;
+	struct rt6_info *sp_rt;

 	/* ::1 */

@@ -2540,6 +2543,33 @@ static void init_loopback(struct net_dev
 	}

 	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
+
+	/* Add routes to other interface's IPv6 addresses */
+	rcu_read_lock();
+	for_each_netdev_rcu(dev_net(dev), sp_dev) {
+
+		if (!strcmp(sp_dev->name, dev->name))
+			continue;
+
+		idev = ipv6_find_idev(sp_dev);
+		if (NULL == idev)
+			continue;
+
+		read_lock_bh(&idev->lock);
+		list_for_each_entry(sp_ifa, &idev->addr_list, if_list) {
+
+			if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
+				continue;
+
+			sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0);
+
+			/* Failure cases are ignored */
+			if (!IS_ERR(sp_rt))
+				ip6_ins_rt(sp_rt);
+		}
+		read_unlock_bh(&idev->lock);
+	}
+	rcu_read_unlock();
 }

 static void addrconf_add_linklocal(struct inet6_dev *idev, const
struct in6_addr *addr)

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 13:27 [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up Balakumaran Kannan
@ 2013-03-28 13:44 ` Eric Dumazet
  2013-03-28 13:45   ` Eric Dumazet
  2013-03-28 18:23   ` Paul E. McKenney
  0 siblings, 2 replies; 15+ messages in thread
From: Eric Dumazet @ 2013-03-28 13:44 UTC (permalink / raw)
  To: Balakumaran Kannan
  Cc: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, 2013-03-28 at 18:57 +0530, Balakumaran Kannan wrote:
> IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
> interface. After down-up, routes of other interface's IPv6 addresses through
> 'lo' are lost.
> 

>  	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
> +
> +	/* Add routes to other interface's IPv6 addresses */
> +	rcu_read_lock();
> +	for_each_netdev_rcu(dev_net(dev), sp_dev) {
> +

We hold RTNL at this point, so why use RCU at all, and adding potential
long latencies ?

Just use for_each_netdev()

This way, a preemption is still allowed.

Also, I am not sure we need ipv6_find_idev()

__in6_dev_get() should be OK.

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 13:44 ` Eric Dumazet
@ 2013-03-28 13:45   ` Eric Dumazet
  2013-03-28 14:04     ` Balakumaran Kannan
  2013-03-28 18:23   ` Paul E. McKenney
  1 sibling, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2013-03-28 13:45 UTC (permalink / raw)
  To: Balakumaran Kannan
  Cc: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, 2013-03-28 at 06:44 -0700, Eric Dumazet wrote:

> __in6_dev_get() should be OK.

more exactly : __in_dev_get_rtnl()

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 13:45   ` Eric Dumazet
@ 2013-03-28 14:04     ` Balakumaran Kannan
  2013-03-28 14:47       ` Balakumaran Kannan
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-03-28 14:04 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, Mar 28, 2013 at 7:15 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Thu, 2013-03-28 at 06:44 -0700, Eric Dumazet wrote:
>
>> __in6_dev_get() should be OK.
>
> more exactly : __in_dev_get_rtnl()
>
>
>

Thank you for your comments. I'll update the patch and send it.

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 14:04     ` Balakumaran Kannan
@ 2013-03-28 14:47       ` Balakumaran Kannan
  2013-03-28 15:14         ` Balakumaran Kannan
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-03-28 14:47 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, Mar 28, 2013 at 7:34 PM, Balakumaran Kannan
<kumaran.4353@gmail.com> wrote:
> On Thu, Mar 28, 2013 at 7:15 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> On Thu, 2013-03-28 at 06:44 -0700, Eric Dumazet wrote:
>>
>>> __in6_dev_get() should be OK.
>>
>> more exactly : __in_dev_get_rtnl()
>>
>>
>>
>
> Thank you for your comments. I'll update the patch and send it.

As __in_dev_get_rtnl returns IPv4 specific data (ip_ptr), we have to
use __in6_dev_get to get IPv6 specific data (ip6_ptr).

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 14:47       ` Balakumaran Kannan
@ 2013-03-28 15:14         ` Balakumaran Kannan
  2013-03-29 19:17           ` David Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-03-28 15:14 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: yoshfuji, davem, Patrick McHardy, Alexey Kuznetsov, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
interface. After down-up, routes of other interface's IPv6 addresses through
'lo' are lost.

IPv6 addresses assigned to all interfaces are routed through 'lo' for internal
communication. Once 'lo' is down, those routing entries are removed from
routing table. But those removed entries are not being re-created properly when
'lo' is brought up. So IPv6 addresses of other interfaces becomes unreachable
from the same machine. Also this breaks communication with other machines
because of NDISC packet processing failure.

This patch fixes this issue by reading all interface's IPv6 addresses and
adding them to IPv6 routing table while bringing up 'lo'.

Patch is prepared for Linux-3.9.rc4 kernel.

Signed-off-by: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
Signed-off-by: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>
---
==Testing==
Before applying the patch:
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$

After applying the patch:
$ route -A inet6
Kernel IPv6 routing
table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$
---
--- linux-3.9-rc4/net/ipv6/addrconf.c.orig	2013-03-27 10:40:26.382569527 +0530
+++ linux-3.9-rc4/net/ipv6/addrconf.c	2013-03-28 20:33:59.908228232 +0530
@@ -2529,6 +2529,9 @@ static void sit_add_v4_addrs(struct inet
 static void init_loopback(struct net_device *dev)
 {
 	struct inet6_dev  *idev;
+	struct net_device *sp_dev;
+	struct inet6_ifaddr *sp_ifa;
+	struct rt6_info *sp_rt;

 	/* ::1 */

@@ -2540,6 +2543,31 @@ static void init_loopback(struct net_dev
 	}

 	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
+
+	/* Add routes to other interface's IPv6 addresses */
+	for_each_netdev(dev_net(dev), sp_dev) {
+
+		if (!strcmp(sp_dev->name, dev->name))
+			continue;
+
+		idev = __in6_dev_get(sp_dev);
+		if (NULL == idev)
+			continue;
+
+		read_lock_bh(&idev->lock);
+		list_for_each_entry(sp_ifa, &idev->addr_list, if_list) {
+
+			if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
+				continue;
+
+			sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0);
+
+			/* Failure cases are ignored */
+			if (!IS_ERR(sp_rt))
+				ip6_ins_rt(sp_rt);
+		}
+		read_unlock_bh(&idev->lock);
+	}
 }

 static void addrconf_add_linklocal(struct inet6_dev *idev, const
struct in6_addr *addr)

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 13:44 ` Eric Dumazet
  2013-03-28 13:45   ` Eric Dumazet
@ 2013-03-28 18:23   ` Paul E. McKenney
  2013-03-28 18:49     ` Eric Dumazet
  1 sibling, 1 reply; 15+ messages in thread
From: Paul E. McKenney @ 2013-03-28 18:23 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Balakumaran Kannan, yoshfuji, davem, Patrick McHardy,
	Alexey Kuznetsov, jmorris, Balakumaran.Kannan, maruthi.thotad,
	netdev, jamshed.a, amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, Mar 28, 2013 at 06:44:25AM -0700, Eric Dumazet wrote:
> On Thu, 2013-03-28 at 18:57 +0530, Balakumaran Kannan wrote:
> > IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
> > interface. After down-up, routes of other interface's IPv6 addresses through
> > 'lo' are lost.
> > 
> 
> >  	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
> > +
> > +	/* Add routes to other interface's IPv6 addresses */
> > +	rcu_read_lock();
> > +	for_each_netdev_rcu(dev_net(dev), sp_dev) {
> > +
> 
> We hold RTNL at this point, so why use RCU at all, and adding potential
> long latencies ?
> 
> Just use for_each_netdev()
> 
> This way, a preemption is still allowed.

Agreed, there is no point in using RCU when it is not needed.

That said...

Since v3.1, in CONFIG_PREEMPT=y kernels, rcu_read_lock() does not
disable preemption.  In CONFIG_PREEMPT=n kernels, rcu_read_lock() does
disable preemption, but to no effect because preemption is already
disabled anyway.

The net effect is that rcu_read_lock() has no effect on preemption.

							Thanx, Paul

> Also, I am not sure we need ipv6_find_idev()
> 
> __in6_dev_get() should be OK.
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 18:23   ` Paul E. McKenney
@ 2013-03-28 18:49     ` Eric Dumazet
  2013-03-28 19:39       ` Paul E. McKenney
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2013-03-28 18:49 UTC (permalink / raw)
  To: paulmck
  Cc: Balakumaran Kannan, yoshfuji, davem, Patrick McHardy,
	Alexey Kuznetsov, jmorris, Balakumaran.Kannan, maruthi.thotad,
	netdev, jamshed.a, amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, 2013-03-28 at 11:23 -0700, Paul E. McKenney wrote:

> 
> Agreed, there is no point in using RCU when it is not needed.
> 
> That said...
> 
> Since v3.1, in CONFIG_PREEMPT=y kernels, rcu_read_lock() does not
> disable preemption.  In CONFIG_PREEMPT=n kernels, rcu_read_lock() does
> disable preemption, but to no effect because preemption is already
> disabled anyway.
> 
> The net effect is that rcu_read_lock() has no effect on preemption.
> 

Good point, but this patch might be a stable candidate.

Rule of thumb for networking is 

1) Control path : RTNL mutex

2) Data path : RTNL cant be taken (from softirq), so use RCU if
possible.

Thanks !

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 18:49     ` Eric Dumazet
@ 2013-03-28 19:39       ` Paul E. McKenney
  0 siblings, 0 replies; 15+ messages in thread
From: Paul E. McKenney @ 2013-03-28 19:39 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Balakumaran Kannan, yoshfuji, davem, Patrick McHardy,
	Alexey Kuznetsov, jmorris, Balakumaran.Kannan, maruthi.thotad,
	netdev, jamshed.a, amit.agarwal, takuzo.ohara, aaditya.kumar

On Thu, Mar 28, 2013 at 11:49:37AM -0700, Eric Dumazet wrote:
> On Thu, 2013-03-28 at 11:23 -0700, Paul E. McKenney wrote:
> 
> > 
> > Agreed, there is no point in using RCU when it is not needed.
> > 
> > That said...
> > 
> > Since v3.1, in CONFIG_PREEMPT=y kernels, rcu_read_lock() does not
> > disable preemption.  In CONFIG_PREEMPT=n kernels, rcu_read_lock() does
> > disable preemption, but to no effect because preemption is already
> > disabled anyway.
> > 
> > The net effect is that rcu_read_lock() has no effect on preemption.
> > 
> 
> Good point, but this patch might be a stable candidate.
> 
> Rule of thumb for networking is 
> 
> 1) Control path : RTNL mutex
> 
> 2) Data path : RTNL cant be taken (from softirq), so use RCU if
> possible.

Stable candidate and rules of thumb sound good to me!

							Thanx, Paul

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-28 15:14         ` Balakumaran Kannan
@ 2013-03-29 19:17           ` David Miller
  2013-03-31  6:38             ` Balakumaran Kannan
  0 siblings, 1 reply; 15+ messages in thread
From: David Miller @ 2013-03-29 19:17 UTC (permalink / raw)
  To: kumaran.4353
  Cc: eric.dumazet, yoshfuji, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

From: Balakumaran Kannan <kumaran.4353@gmail.com>
Date: Thu, 28 Mar 2013 20:44:36 +0530

>  static void addrconf_add_linklocal(struct inet6_dev *idev, const
> struct in6_addr *addr)

Your email client corrupted this patch, please resubmit but only after
you have emailed the patch to yourself and successfully applied the
patch you receive in that test email.

Thanks.

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-29 19:17           ` David Miller
@ 2013-03-31  6:38             ` Balakumaran Kannan
  2013-04-01 11:59               ` Balakumaran Kannan
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-03-31  6:38 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet, yoshfuji, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

>>  static void addrconf_add_linklocal(struct inet6_dev *idev, const
>> struct in6_addr *addr)
>
> Your email client corrupted this patch, please resubmit but only after
> you have emailed the patch to yourself and successfully applied the
> patch you receive in that test email.
>
> Thanks.

I'll send working patch after verifying it.

Thank you.
K.Balakumaran

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-03-31  6:38             ` Balakumaran Kannan
@ 2013-04-01 11:59               ` Balakumaran Kannan
  2013-04-01 14:16                 ` YOSHIFUJI Hideaki
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-04-01 11:59 UTC (permalink / raw)
  To: David Miller
  Cc: eric.dumazet, yoshfuji, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
interface. After down-up, routes of other interface's IPv6 addresses through
'lo' are lost.

IPv6 addresses assigned to all interfaces are routed through 'lo' for internal
communication. Once 'lo' is down, those routing entries are removed from routing
table. But those removed entries are not being re-created properly when 'lo' is
brought up. So IPv6 addresses of other interfaces becomes unreachable from the
same machine. Also this breaks communication with other machines because of
NDISC packet processing failure.

This patch fixes this issue by reading all interface's IPv6 addresses and adding
them to IPv6 routing table while bringing up 'lo'.

Patch is prepared for Linux-3.9.rc4 kernel.

Signed-off-by: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
Signed-off-by: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>
---
==Testing==
Before applying the patch:
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$

After applying the patch:
$ route -A inet6
Kernel IPv6 routing
table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$
---
--- linux-3.9-rc4/net/ipv6/addrconf.c.orig	2013-03-27 10:40:26.382569527 +0530
+++ linux-3.9-rc4/net/ipv6/addrconf.c	2013-03-28 20:33:59.908228232 +0530
@@ -2529,6 +2529,9 @@ static void sit_add_v4_addrs(struct inet  static void init_loopback(struct net_device *dev)  {
 	struct inet6_dev  *idev;
+	struct net_device *sp_dev;
+	struct inet6_ifaddr *sp_ifa;
+	struct rt6_info *sp_rt;

 	/* ::1 */

@@ -2540,6 +2543,31 @@ static void init_loopback(struct net_dev
 	}

 	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
+
+	/* Add routes to other interface's IPv6 addresses */
+	for_each_netdev(dev_net(dev), sp_dev) {
+
+		if (!strcmp(sp_dev->name, dev->name))
+			continue;
+
+		idev = __in6_dev_get(sp_dev);
+		if (NULL == idev)
+			continue;
+
+		read_lock_bh(&idev->lock);
+		list_for_each_entry(sp_ifa, &idev->addr_list, if_list) {
+
+			if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
+				continue;
+
+			sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0);
+
+			/* Failure cases are ignored */
+			if (!IS_ERR(sp_rt))
+				ip6_ins_rt(sp_rt);
+		}
+		read_unlock_bh(&idev->lock);
+	}
 }

 static void addrconf_add_linklocal(struct inet6_dev *idev, const struct in6_addr *addr)

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-04-01 11:59               ` Balakumaran Kannan
@ 2013-04-01 14:16                 ` YOSHIFUJI Hideaki
  2013-04-02 10:45                   ` Balakumaran Kannan
  0 siblings, 1 reply; 15+ messages in thread
From: YOSHIFUJI Hideaki @ 2013-04-01 14:16 UTC (permalink / raw)
  To: Balakumaran Kannan
  Cc: David Miller, eric.dumazet, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar, YOSHIFUJI Hideaki

Balakumaran Kannan wrote:

> @@ -2540,6 +2543,31 @@ static void init_loopback(struct net_dev
>  	}
> 
>  	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
> +
> +	/* Add routes to other interface's IPv6 addresses */
> +	for_each_netdev(dev_net(dev), sp_dev) {
> +
> +		if (!strcmp(sp_dev->name, dev->name))
> +			continue;
> +
> +		idev = __in6_dev_get(sp_dev);
> +		if (NULL == idev)
> +			continue;

idev == NULL or !idev.

--yoshfuji

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-04-01 14:16                 ` YOSHIFUJI Hideaki
@ 2013-04-02 10:45                   ` Balakumaran Kannan
  2013-04-02 18:37                     ` David Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Balakumaran Kannan @ 2013-04-02 10:45 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki
  Cc: David Miller, eric.dumazet, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
interface. After down-up, routes of other interface's IPv6 addresses through
'lo' are lost.

IPv6 addresses assigned to all interfaces are routed through 'lo' for internal
communication. Once 'lo' is down, those routing entries are removed from routing
table. But those removed entries are not being re-created properly when 'lo' is
brought up. So IPv6 addresses of other interfaces becomes unreachable from the
same machine. Also this breaks communication with other machines because of
NDISC packet processing failure.

This patch fixes this issue by reading all interface's IPv6 addresses and adding
them to IPv6 routing table while bringing up 'lo'.

Patch is prepared for Linux-3.9.rc5 kernel.

Signed-off-by: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
Signed-off-by: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>
---
==Testing==
Before applying the patch:
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$

After applying the patch:
$ route -A inet6
Kernel IPv6 routing
table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$ sudo ifdown lo
$ sudo ifup lo
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
2000::20/128                   ::                         U    256 0     0 eth0
fe80::/64                      ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
::1/128                        ::                         Un   0   1     0 lo
2000::20/128                   ::                         Un   0   1     0 lo
fe80::xxxx:xxxx:xxxx:xxxx/128  ::                         Un   0   1     0 lo
ff00::/8                       ::                         U    256 0     0 eth0
::/0                           ::                         !n   -1  1     1 lo
$
---
--- linux-3.9-rc5/net/ipv6/addrconf.c.orig	2013-04-02 15:53:44.401743369 +0530
+++ linux-3.9-rc5/net/ipv6/addrconf.c	2013-04-02 15:53:54.921794799 +0530
@@ -2529,6 +2529,9 @@ static void sit_add_v4_addrs(struct inet
 static void init_loopback(struct net_device *dev)
 {
 	struct inet6_dev  *idev;
+	struct net_device *sp_dev;
+	struct inet6_ifaddr *sp_ifa;
+	struct rt6_info *sp_rt;
 
 	/* ::1 */
 
@@ -2540,6 +2543,31 @@ static void init_loopback(struct net_dev
 	}
 
 	add_addr(idev, &in6addr_loopback, 128, IFA_HOST);
+
+	/* Add routes to other interface's IPv6 addresses */
+	for_each_netdev(dev_net(dev), sp_dev) {
+
+		if (!strcmp(sp_dev->name, dev->name))
+			continue;
+
+		idev = __in6_dev_get(sp_dev);
+		if (!idev)
+			continue;
+
+		read_lock_bh(&idev->lock);
+		list_for_each_entry(sp_ifa, &idev->addr_list, if_list) {
+
+			if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
+				continue;
+
+			sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0);
+
+			/* Failure cases are ignored */
+			if (!IS_ERR(sp_rt))
+				ip6_ins_rt(sp_rt);
+		}
+		read_unlock_bh(&idev->lock);
+	}
 }
 
 static void addrconf_add_linklocal(struct inet6_dev *idev, const struct in6_addr *addr)

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

* Re: [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up
  2013-04-02 10:45                   ` Balakumaran Kannan
@ 2013-04-02 18:37                     ` David Miller
  0 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2013-04-02 18:37 UTC (permalink / raw)
  To: kumaran.4353
  Cc: yoshfuji, eric.dumazet, kaber, kuznet, jmorris,
	Balakumaran.Kannan, maruthi.thotad, netdev, jamshed.a,
	amit.agarwal, takuzo.ohara, aaditya.kumar

From: Balakumaran Kannan <kumaran.4353@gmail.com>
Date: Tue, 02 Apr 2013 16:15:05 +0530

> IPv6 Routing table becomes broken once we do ifdown, ifup of the loopback(lo)
> interface. After down-up, routes of other interface's IPv6 addresses through
> 'lo' are lost.
> 
> IPv6 addresses assigned to all interfaces are routed through 'lo' for internal
> communication. Once 'lo' is down, those routing entries are removed from routing
> table. But those removed entries are not being re-created properly when 'lo' is
> brought up. So IPv6 addresses of other interfaces becomes unreachable from the
> same machine. Also this breaks communication with other machines because of
> NDISC packet processing failure.
> 
> This patch fixes this issue by reading all interface's IPv6 addresses and adding
> them to IPv6 routing table while bringing up 'lo'.
> 
> Patch is prepared for Linux-3.9.rc5 kernel.
> 
> Signed-off-by: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
> Signed-off-by: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>

Applied, thanks.

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

end of thread, other threads:[~2013-04-02 18:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 13:27 [PATCH v2] net IPv6 : Fix broken IPv6 routing table after loopback down-up Balakumaran Kannan
2013-03-28 13:44 ` Eric Dumazet
2013-03-28 13:45   ` Eric Dumazet
2013-03-28 14:04     ` Balakumaran Kannan
2013-03-28 14:47       ` Balakumaran Kannan
2013-03-28 15:14         ` Balakumaran Kannan
2013-03-29 19:17           ` David Miller
2013-03-31  6:38             ` Balakumaran Kannan
2013-04-01 11:59               ` Balakumaran Kannan
2013-04-01 14:16                 ` YOSHIFUJI Hideaki
2013-04-02 10:45                   ` Balakumaran Kannan
2013-04-02 18:37                     ` David Miller
2013-03-28 18:23   ` Paul E. McKenney
2013-03-28 18:49     ` Eric Dumazet
2013-03-28 19:39       ` Paul E. McKenney

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.