ipv6: collapse state_lock and lock
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Mon, 23 Mar 2015 22:36:03 +0000 (23:36 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Mar 2015 02:12:09 +0000 (22:12 -0400)
Cc: Erik Kline <ek@google.com>
Cc: Fernando Gont <fgont@si6networks.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: YOSHIFUJI Hideaki/吉藤英明 <hideaki.yoshifuji@miraclelinux.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/if_inet6.h
net/ipv6/addrconf.c

index 98e5f9578f862abb894190ca729e0f4613e1a8fa..d89397a229036d77b57343a69ed14072fb02373a 100644 (file)
@@ -41,13 +41,12 @@ enum {
 struct inet6_ifaddr {
        struct in6_addr         addr;
        __u32                   prefix_len;
-       
+
        /* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
        __u32                   valid_lft;
        __u32                   prefered_lft;
        atomic_t                refcnt;
        spinlock_t              lock;
-       spinlock_t              state_lock;
 
        int                     state;
 
index c2357b6f62ddfdd13bb197fbad293e37fd3b86b8..1cc5320e510f241c532661d208679184ae1b8262 100644 (file)
@@ -873,7 +873,6 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
                ifa->peer_addr = *peer_addr;
 
        spin_lock_init(&ifa->lock);
-       spin_lock_init(&ifa->state_lock);
        INIT_DELAYED_WORK(&ifa->dad_work, addrconf_dad_work);
        INIT_HLIST_NODE(&ifa->addr_lst);
        ifa->scope = scope;
@@ -1016,10 +1015,10 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 
        ASSERT_RTNL();
 
-       spin_lock_bh(&ifp->state_lock);
+       spin_lock_bh(&ifp->lock);
        state = ifp->state;
        ifp->state = INET6_IFADDR_STATE_DEAD;
-       spin_unlock_bh(&ifp->state_lock);
+       spin_unlock_bh(&ifp->lock);
 
        if (state == INET6_IFADDR_STATE_DEAD)
                goto out;
@@ -1699,12 +1698,12 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp)
 {
        int err = -ENOENT;
 
-       spin_lock_bh(&ifp->state_lock);
+       spin_lock_bh(&ifp->lock);
        if (ifp->state == INET6_IFADDR_STATE_DAD) {
                ifp->state = INET6_IFADDR_STATE_POSTDAD;
                err = 0;
        }
-       spin_unlock_bh(&ifp->state_lock);
+       spin_unlock_bh(&ifp->lock);
 
        return err;
 }
@@ -1737,10 +1736,10 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
                }
        }
 
-       spin_lock_bh(&ifp->state_lock);
+       spin_lock_bh(&ifp->lock);
        /* transition from _POSTDAD to _ERRDAD */
        ifp->state = INET6_IFADDR_STATE_ERRDAD;
-       spin_unlock_bh(&ifp->state_lock);
+       spin_unlock_bh(&ifp->lock);
 
        addrconf_mod_dad_work(ifp, 0);
 }
@@ -2369,7 +2368,7 @@ ok:
                        u32 stored_lft;
 
                        /* update lifetime (RFC2462 5.5.3 e) */
-                       spin_lock(&ifp->lock);
+                       spin_lock_bh(&ifp->lock);
                        now = jiffies;
                        if (ifp->valid_lft > (now - ifp->tstamp) / HZ)
                                stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ;
@@ -2399,12 +2398,12 @@ ok:
                                ifp->tstamp = now;
                                flags = ifp->flags;
                                ifp->flags &= ~IFA_F_DEPRECATED;
-                               spin_unlock(&ifp->lock);
+                               spin_unlock_bh(&ifp->lock);
 
                                if (!(flags&IFA_F_TENTATIVE))
                                        ipv6_ifa_notify(0, ifp);
                        } else
-                               spin_unlock(&ifp->lock);
+                               spin_unlock_bh(&ifp->lock);
 
                        manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft,
                                         create, now);
@@ -3265,10 +3264,10 @@ restart:
 
                write_unlock_bh(&idev->lock);
 
-               spin_lock_bh(&ifa->state_lock);
+               spin_lock_bh(&ifa->lock);
                state = ifa->state;
                ifa->state = INET6_IFADDR_STATE_DEAD;
-               spin_unlock_bh(&ifa->state_lock);
+               spin_unlock_bh(&ifa->lock);
 
                if (state != INET6_IFADDR_STATE_DEAD) {
                        __ipv6_ifa_notify(RTM_DELADDR, ifa);
@@ -3426,12 +3425,12 @@ static void addrconf_dad_start(struct inet6_ifaddr *ifp)
 {
        bool begin_dad = false;
 
-       spin_lock_bh(&ifp->state_lock);
+       spin_lock_bh(&ifp->lock);
        if (ifp->state != INET6_IFADDR_STATE_DEAD) {
                ifp->state = INET6_IFADDR_STATE_PREDAD;
                begin_dad = true;
        }
-       spin_unlock_bh(&ifp->state_lock);
+       spin_unlock_bh(&ifp->lock);
 
        if (begin_dad)
                addrconf_mod_dad_work(ifp, 0);
@@ -3453,7 +3452,7 @@ static void addrconf_dad_work(struct work_struct *w)
 
        rtnl_lock();
 
-       spin_lock_bh(&ifp->state_lock);
+       spin_lock_bh(&ifp->lock);
        if (ifp->state == INET6_IFADDR_STATE_PREDAD) {
                action = DAD_BEGIN;
                ifp->state = INET6_IFADDR_STATE_DAD;
@@ -3461,7 +3460,7 @@ static void addrconf_dad_work(struct work_struct *w)
                action = DAD_ABORT;
                ifp->state = INET6_IFADDR_STATE_POSTDAD;
        }
-       spin_unlock_bh(&ifp->state_lock);
+       spin_unlock_bh(&ifp->lock);
 
        if (action == DAD_BEGIN) {
                addrconf_dad_begin(ifp);