All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: "David S. Miller" <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH 02/12] IPv6: addrconf timer race
Date: Tue, 02 Mar 2010 15:32:45 -0800	[thread overview]
Message-ID: <20100302234002.971992509@vyatta.com> (raw)
In-Reply-To: 20100302233243.259794027@vyatta.com

[-- Attachment #1: addrconf-rstimer.patch --]
[-- Type: text/plain, Size: 1949 bytes --]

The Router Solicitation timer races with device state changes
because it doesn't lock the device. Use local variable to avoid
one repeated dereference.


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


--- a/net/ipv6/addrconf.c	2010-02-26 20:00:43.703982448 -0800
+++ b/net/ipv6/addrconf.c	2010-02-27 08:29:41.727984521 -0800
@@ -2739,28 +2739,29 @@ static int addrconf_ifdown(struct net_de
 static void addrconf_rs_timer(unsigned long data)
 {
 	struct inet6_ifaddr *ifp = (struct inet6_ifaddr *) data;
+	struct inet6_dev *idev = ifp->idev;
 
-	if (ifp->idev->cnf.forwarding)
+	read_lock(&idev->lock);
+	if (idev->dead || !(idev->if_flags & IF_READY))
 		goto out;
 
-	if (ifp->idev->if_flags & IF_RA_RCVD) {
-		/*
-		 *	Announcement received after solicitation
-		 *	was sent
-		 */
+	if (idev->cnf.forwarding)
+		goto out;
+
+	/* Announcement received after solicitation was sent */
+	if (idev->if_flags & IF_RA_RCVD)
 		goto out;
-	}
 
 	spin_lock(&ifp->lock);
-	if (ifp->probes++ < ifp->idev->cnf.rtr_solicits) {
+	if (ifp->probes++ < idev->cnf.rtr_solicits) {
 		/* The wait after the last probe can be shorter */
 		addrconf_mod_timer(ifp, AC_RS,
-				   (ifp->probes == ifp->idev->cnf.rtr_solicits) ?
-				   ifp->idev->cnf.rtr_solicit_delay :
-				   ifp->idev->cnf.rtr_solicit_interval);
+				   (ifp->probes == idev->cnf.rtr_solicits) ?
+				   idev->cnf.rtr_solicit_delay :
+				   idev->cnf.rtr_solicit_interval);
 		spin_unlock(&ifp->lock);
 
-		ndisc_send_rs(ifp->idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
+		ndisc_send_rs(idev->dev, &ifp->addr, &in6addr_linklocal_allrouters);
 	} else {
 		spin_unlock(&ifp->lock);
 		/*
@@ -2768,10 +2769,11 @@ static void addrconf_rs_timer(unsigned l
 		 * assumption any longer.
 		 */
 		printk(KERN_DEBUG "%s: no IPv6 routers present\n",
-		       ifp->idev->dev->name);
+		       idev->dev->name);
 	}
 
 out:
+	read_unlock(&idev->lock);
 	in6_ifa_put(ifp);
 }
 

-- 


  parent reply	other threads:[~2010-03-02 23:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 23:32 [PATCH 00/12] IPv6 addrconf changes Stephen Hemminger
2010-03-02 23:32 ` [PATCH 01/12] IPv6: addrconf dad timer unnecessary bh_disable Stephen Hemminger
2010-03-04  8:39   ` David Miller
2010-03-02 23:32 ` Stephen Hemminger [this message]
2010-03-04  8:40   ` [PATCH 02/12] IPv6: addrconf timer race David Miller
2010-03-02 23:32 ` [PATCH 03/12] IPv6: addrconf notify when address is unavailable Stephen Hemminger
2010-03-04  8:40   ` David Miller
2010-03-02 23:32 ` [PATCH 04/12] ipv6: convert temporary address list to list macros Stephen Hemminger
2010-03-02 23:32 ` [PATCH 05/12] ipv6: convert addrconf list to hlist Stephen Hemminger
2010-03-02 23:32 ` [PATCH 06/12] IPv6: convert addrconf hash list to RCU Stephen Hemminger
2010-03-02 23:32 ` [PATCH 07/12] ipv6: user better hash for addrconf Stephen Hemminger
2010-03-02 23:32 ` [PATCH 08/12] ipv6: convert idev_list to list macros Stephen Hemminger
2010-03-02 23:32 ` [PATCH 09/12] IPv6: addrconf cleanups Stephen Hemminger
2010-03-02 23:32 ` [PATCH 10/12] IPv6: addrconf checkpatch fixes Stephen Hemminger
2010-03-02 23:32 ` [PATCH 11/12] ipv6: addrconf timer changes Stephen Hemminger
2010-03-02 23:32 ` [PATCH 12/12] IPv6: addrconf cleanup addrconf_verify Stephen Hemminger
2010-03-03  9:16 ` [PATCH 00/12] IPv6 addrconf changes David Miller
2010-03-03 18:14   ` Stephen Hemminger
2010-03-03 18:19     ` [PATCH] IPv6: fix race between cleanup and add/delete address Stephen Hemminger
2010-03-04  8:40       ` David Miller

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=20100302234002.971992509@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --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 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.