netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] IPv6: keep permanent addresses on admin down
@ 2010-02-09  5:48 Stephen Hemminger
  2010-02-09  5:48 ` [PATCH 2/2] IPv6: remove trivial nested _bh suffix Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephen Hemminger @ 2010-02-09  5:48 UTC (permalink / raw)
  To: David Miller,
	YOSHIFUJI Hideaki / 吉藤英明; +Cc: netdev

Permanent IPV6 addresses should not be removed when the link is
set to admin down, only when device is removed. 

When link is lost permanent addresses should be marked as tentative
so that when link comes back they are subject to duplicate address
detection (if DAD was enabled for that address).

Other routing systems keep manually configured IPv6 addresses
when link is set down.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
The logic here is getting long and twisted, doing some work
to use RCU here and refactor.

--- a/net/ipv6/addrconf.c	2010-02-08 21:05:04.798785751 -0800
+++ b/net/ipv6/addrconf.c	2010-02-08 21:38:58.734340743 -0800
@@ -2646,7 +2646,8 @@ static int addrconf_ifdown(struct net_de
 
 		write_lock_bh(&addrconf_hash_lock);
 		while ((ifa = *bifa) != NULL) {
-			if (ifa->idev == idev) {
+			if (ifa->idev == idev &&
+			    (how || !(ifa->flags&IFA_F_PERMANENT))) {
 				*bifa = ifa->lst_next;
 				ifa->lst_next = NULL;
 				addrconf_del_timer(ifa);
@@ -2686,18 +2687,30 @@ static int addrconf_ifdown(struct net_de
 		write_lock_bh(&idev->lock);
 	}
 #endif
-	while ((ifa = idev->addr_list) != NULL) {
-		idev->addr_list = ifa->if_next;
-		ifa->if_next = NULL;
-		ifa->dead = 1;
-		addrconf_del_timer(ifa);
-		write_unlock_bh(&idev->lock);
-
-		__ipv6_ifa_notify(RTM_DELADDR, ifa);
-		atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
-		in6_ifa_put(ifa);
+	bifa = &idev->addr_list;
+	while ((ifa = *bifa) != NULL) {
+		if (how == 0 && (ifa->flags&IFA_F_PERMANENT)) {
+			/* Retain permanent address on admin down */
+			bifa = &ifa->if_next;
+
+			/* Restart DAD if needed when link comes back up */
+			if ( !((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
+			       idev->cnf.accept_dad <= 0 ||
+			       (ifa->flags & IFA_F_NODAD)))
+				ifa->flags |= IFA_F_TENTATIVE;
+		} else {
+			*bifa = ifa->if_next;
+			ifa->if_next = NULL;
+
+			ifa->dead = 1;
+			write_unlock_bh(&idev->lock);
+
+			__ipv6_ifa_notify(RTM_DELADDR, ifa);
+			atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
+			in6_ifa_put(ifa);
 
-		write_lock_bh(&idev->lock);
+			write_lock_bh(&idev->lock);
+		}
 	}
 	write_unlock_bh(&idev->lock);
 

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

* [PATCH 2/2] IPv6: remove trivial nested _bh suffix
  2010-02-09  5:48 [PATCH 1/2] IPv6: keep permanent addresses on admin down Stephen Hemminger
@ 2010-02-09  5:48 ` Stephen Hemminger
  2010-02-12 20:30   ` David Miller
  2010-02-09 14:40 ` [PATCH 1/2] IPv6: keep permanent addresses on admin down Brian Haley
  2010-02-12 20:30 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2010-02-09  5:48 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller,
	YOSHIFUJI Hideaki / 吉藤英明, netdev

Don't need to disable bottom half it is already down in the
previous lock. Move some blank lines to group locking in same
context.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/net/ipv6/addrconf.c	2010-02-08 21:37:31.589584963 -0800
+++ b/net/ipv6/addrconf.c	2010-02-08 21:37:41.114027790 -0800
@@ -2802,14 +2802,14 @@ static void addrconf_dad_start(struct in
 	read_lock_bh(&idev->lock);
 	if (ifp->dead)
 		goto out;
-	spin_lock_bh(&ifp->lock);
 
+	spin_lock(&ifp->lock);
 	if (dev->flags&(IFF_NOARP|IFF_LOOPBACK) ||
 	    idev->cnf.accept_dad < 1 ||
 	    !(ifp->flags&IFA_F_TENTATIVE) ||
 	    ifp->flags & IFA_F_NODAD) {
 		ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
-		spin_unlock_bh(&ifp->lock);
+		spin_unlock(&ifp->lock);
 		read_unlock_bh(&idev->lock);
 
 		addrconf_dad_completed(ifp);
@@ -2817,7 +2817,7 @@ static void addrconf_dad_start(struct in
 	}
 
 	if (!(idev->if_flags & IF_READY)) {
-		spin_unlock_bh(&ifp->lock);
+		spin_unlock(&ifp->lock);
 		read_unlock_bh(&idev->lock);
 		/*
 		 * If the device is not ready:
@@ -2837,7 +2837,7 @@ static void addrconf_dad_start(struct in
 		ip6_ins_rt(ifp->rt);
 
 	addrconf_dad_kick(ifp);
-	spin_unlock_bh(&ifp->lock);
+	spin_unlock(&ifp->lock);
 out:
 	read_unlock_bh(&idev->lock);
 }
@@ -2853,14 +2853,15 @@ static void addrconf_dad_timer(unsigned 
 		read_unlock_bh(&idev->lock);
 		goto out;
 	}
-	spin_lock_bh(&ifp->lock);
+
+	spin_lock(&ifp->lock);
 	if (ifp->probes == 0) {
 		/*
 		 * DAD was successful
 		 */
 
 		ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
-		spin_unlock_bh(&ifp->lock);
+		spin_unlock(&ifp->lock);
 		read_unlock_bh(&idev->lock);
 
 		addrconf_dad_completed(ifp);
@@ -2870,7 +2871,7 @@ static void addrconf_dad_timer(unsigned 
 
 	ifp->probes--;
 	addrconf_mod_timer(ifp, AC_DAD, ifp->idev->nd_parms->retrans_time);
-	spin_unlock_bh(&ifp->lock);
+	spin_unlock(&ifp->lock);
 	read_unlock_bh(&idev->lock);
 
 	/* send a neighbour solicitation for our addr */
@@ -2918,12 +2919,12 @@ static void addrconf_dad_run(struct inet
 
 	read_lock_bh(&idev->lock);
 	for (ifp = idev->addr_list; ifp; ifp = ifp->if_next) {
-		spin_lock_bh(&ifp->lock);
+		spin_lock(&ifp->lock);
 		if (!(ifp->flags & IFA_F_TENTATIVE)) {
-			spin_unlock_bh(&ifp->lock);
+			spin_unlock(&ifp->lock);
 			continue;
 		}
-		spin_unlock_bh(&ifp->lock);
+		spin_unlock(&ifp->lock);
 		addrconf_dad_kick(ifp);
 	}
 	read_unlock_bh(&idev->lock);


-- 

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

* Re: [PATCH 1/2] IPv6: keep permanent addresses on admin down
  2010-02-09  5:48 [PATCH 1/2] IPv6: keep permanent addresses on admin down Stephen Hemminger
  2010-02-09  5:48 ` [PATCH 2/2] IPv6: remove trivial nested _bh suffix Stephen Hemminger
@ 2010-02-09 14:40 ` Brian Haley
  2010-02-09 16:36   ` Stephen Hemminger
  2010-02-12 20:30 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Brian Haley @ 2010-02-09 14:40 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller,
	YOSHIFUJI Hideaki / 吉藤英明, netdev

Stephen Hemminger wrote:
> @@ -2686,18 +2687,30 @@ static int addrconf_ifdown(struct net_de
>  		write_lock_bh(&idev->lock);
>  	}
>  #endif
> -	while ((ifa = idev->addr_list) != NULL) {
> -		idev->addr_list = ifa->if_next;
> -		ifa->if_next = NULL;
> -		ifa->dead = 1;
> -		addrconf_del_timer(ifa);
> -		write_unlock_bh(&idev->lock);
> -
> -		__ipv6_ifa_notify(RTM_DELADDR, ifa);
> -		atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
> -		in6_ifa_put(ifa);
> +	bifa = &idev->addr_list;
> +	while ((ifa = *bifa) != NULL) {
> +		if (how == 0 && (ifa->flags&IFA_F_PERMANENT)) {
> +			/* Retain permanent address on admin down */
> +			bifa = &ifa->if_next;
> +
> +			/* Restart DAD if needed when link comes back up */
> +			if ( !((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
> +			       idev->cnf.accept_dad <= 0 ||
> +			       (ifa->flags & IFA_F_NODAD)))
> +				ifa->flags |= IFA_F_TENTATIVE;
> +		} else {
> +			*bifa = ifa->if_next;
> +			ifa->if_next = NULL;
> +
> +			ifa->dead = 1;
> +			write_unlock_bh(&idev->lock);
> +
> +			__ipv6_ifa_notify(RTM_DELADDR, ifa);
> +			atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
> +			in6_ifa_put(ifa);
>  
> -		write_lock_bh(&idev->lock);
> +			write_lock_bh(&idev->lock);
> +		}

What about addrconf_del_timer()?  It didn't seem to make it to this else{} from
the original.

-Brian

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

* Re: [PATCH 1/2] IPv6: keep permanent addresses on admin down
  2010-02-09 14:40 ` [PATCH 1/2] IPv6: keep permanent addresses on admin down Brian Haley
@ 2010-02-09 16:36   ` Stephen Hemminger
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2010-02-09 16:36 UTC (permalink / raw)
  To: Brian Haley
  Cc: David Miller,
	YOSHIFUJI Hideaki / 吉藤英明, netdev

On Tue, 09 Feb 2010 09:40:11 -0500
Brian Haley <brian.haley@hp.com> wrote:

> Stephen Hemminger wrote:
> > @@ -2686,18 +2687,30 @@ static int addrconf_ifdown(struct net_de
> >  		write_lock_bh(&idev->lock);
> >  	}
> >  #endif
> > -	while ((ifa = idev->addr_list) != NULL) {
> > -		idev->addr_list = ifa->if_next;
> > -		ifa->if_next = NULL;
> > -		ifa->dead = 1;
> > -		addrconf_del_timer(ifa);
> > -		write_unlock_bh(&idev->lock);
> > -
> > -		__ipv6_ifa_notify(RTM_DELADDR, ifa);
> > -		atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
> > -		in6_ifa_put(ifa);
> > +	bifa = &idev->addr_list;
> > +	while ((ifa = *bifa) != NULL) {
> > +		if (how == 0 && (ifa->flags&IFA_F_PERMANENT)) {
> > +			/* Retain permanent address on admin down */
> > +			bifa = &ifa->if_next;
> > +
> > +			/* Restart DAD if needed when link comes back up */
> > +			if ( !((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||
> > +			       idev->cnf.accept_dad <= 0 ||
> > +			       (ifa->flags & IFA_F_NODAD)))
> > +				ifa->flags |= IFA_F_TENTATIVE;
> > +		} else {
> > +			*bifa = ifa->if_next;
> > +			ifa->if_next = NULL;
> > +
> > +			ifa->dead = 1;
> > +			write_unlock_bh(&idev->lock);
> > +
> > +			__ipv6_ifa_notify(RTM_DELADDR, ifa);
> > +			atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
> > +			in6_ifa_put(ifa);
> >  
> > -		write_lock_bh(&idev->lock);
> > +			write_lock_bh(&idev->lock);
> > +		}
> 
> What about addrconf_del_timer()?  It didn't seem to make it to this else{} from
> the original.
> 
> -Brian

addrconf_del_timer is already being done earlier in same code
no need to do it twice.

-- 

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

* Re: [PATCH 1/2] IPv6: keep permanent addresses on admin down
  2010-02-09  5:48 [PATCH 1/2] IPv6: keep permanent addresses on admin down Stephen Hemminger
  2010-02-09  5:48 ` [PATCH 2/2] IPv6: remove trivial nested _bh suffix Stephen Hemminger
  2010-02-09 14:40 ` [PATCH 1/2] IPv6: keep permanent addresses on admin down Brian Haley
@ 2010-02-12 20:30 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-02-12 20:30 UTC (permalink / raw)
  To: shemminger; +Cc: yoshfuji, netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 8 Feb 2010 21:48:05 -0800

> Permanent IPV6 addresses should not be removed when the link is
> set to admin down, only when device is removed. 
> 
> When link is lost permanent addresses should be marked as tentative
> so that when link comes back they are subject to duplicate address
> detection (if DAD was enabled for that address).
> 
> Other routing systems keep manually configured IPv6 addresses
> when link is set down.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Applied to net-next-2.6

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

* Re: [PATCH 2/2] IPv6: remove trivial nested _bh suffix
  2010-02-09  5:48 ` [PATCH 2/2] IPv6: remove trivial nested _bh suffix Stephen Hemminger
@ 2010-02-12 20:30   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2010-02-12 20:30 UTC (permalink / raw)
  To: shemminger; +Cc: yoshfuji, netdev

From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 8 Feb 2010 21:48:52 -0800

> Don't need to disable bottom half it is already down in the
> previous lock. Move some blank lines to group locking in same
> context.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Applied to net-next-2.6

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

end of thread, other threads:[~2010-02-12 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-09  5:48 [PATCH 1/2] IPv6: keep permanent addresses on admin down Stephen Hemminger
2010-02-09  5:48 ` [PATCH 2/2] IPv6: remove trivial nested _bh suffix Stephen Hemminger
2010-02-12 20:30   ` David Miller
2010-02-09 14:40 ` [PATCH 1/2] IPv6: keep permanent addresses on admin down Brian Haley
2010-02-09 16:36   ` Stephen Hemminger
2010-02-12 20:30 ` 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).