diff options
author | Hannes Frederic Sowa <hannes@stressinduktion.org> | 2015-03-23 18:36:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-23 22:12:09 -0400 |
commit | 8e8e676d0b3c7f074c719c7c05b20296b9b0b0b1 (patch) | |
tree | e847c044663490f60460ec84b3d1c37d5f5638b0 /net/ipv6 | |
parent | 64236f3f3d742469e4027b83a9515e84e9ab21b4 (diff) |
ipv6: collapse state_lock and lock
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>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/addrconf.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index c2357b6f62dd..1cc5320e510f 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -873,7 +873,6 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, | |||
873 | ifa->peer_addr = *peer_addr; | 873 | ifa->peer_addr = *peer_addr; |
874 | 874 | ||
875 | spin_lock_init(&ifa->lock); | 875 | spin_lock_init(&ifa->lock); |
876 | spin_lock_init(&ifa->state_lock); | ||
877 | INIT_DELAYED_WORK(&ifa->dad_work, addrconf_dad_work); | 876 | INIT_DELAYED_WORK(&ifa->dad_work, addrconf_dad_work); |
878 | INIT_HLIST_NODE(&ifa->addr_lst); | 877 | INIT_HLIST_NODE(&ifa->addr_lst); |
879 | ifa->scope = scope; | 878 | ifa->scope = scope; |
@@ -1016,10 +1015,10 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp) | |||
1016 | 1015 | ||
1017 | ASSERT_RTNL(); | 1016 | ASSERT_RTNL(); |
1018 | 1017 | ||
1019 | spin_lock_bh(&ifp->state_lock); | 1018 | spin_lock_bh(&ifp->lock); |
1020 | state = ifp->state; | 1019 | state = ifp->state; |
1021 | ifp->state = INET6_IFADDR_STATE_DEAD; | 1020 | ifp->state = INET6_IFADDR_STATE_DEAD; |
1022 | spin_unlock_bh(&ifp->state_lock); | 1021 | spin_unlock_bh(&ifp->lock); |
1023 | 1022 | ||
1024 | if (state == INET6_IFADDR_STATE_DEAD) | 1023 | if (state == INET6_IFADDR_STATE_DEAD) |
1025 | goto out; | 1024 | goto out; |
@@ -1699,12 +1698,12 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp) | |||
1699 | { | 1698 | { |
1700 | int err = -ENOENT; | 1699 | int err = -ENOENT; |
1701 | 1700 | ||
1702 | spin_lock_bh(&ifp->state_lock); | 1701 | spin_lock_bh(&ifp->lock); |
1703 | if (ifp->state == INET6_IFADDR_STATE_DAD) { | 1702 | if (ifp->state == INET6_IFADDR_STATE_DAD) { |
1704 | ifp->state = INET6_IFADDR_STATE_POSTDAD; | 1703 | ifp->state = INET6_IFADDR_STATE_POSTDAD; |
1705 | err = 0; | 1704 | err = 0; |
1706 | } | 1705 | } |
1707 | spin_unlock_bh(&ifp->state_lock); | 1706 | spin_unlock_bh(&ifp->lock); |
1708 | 1707 | ||
1709 | return err; | 1708 | return err; |
1710 | } | 1709 | } |
@@ -1737,10 +1736,10 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp) | |||
1737 | } | 1736 | } |
1738 | } | 1737 | } |
1739 | 1738 | ||
1740 | spin_lock_bh(&ifp->state_lock); | 1739 | spin_lock_bh(&ifp->lock); |
1741 | /* transition from _POSTDAD to _ERRDAD */ | 1740 | /* transition from _POSTDAD to _ERRDAD */ |
1742 | ifp->state = INET6_IFADDR_STATE_ERRDAD; | 1741 | ifp->state = INET6_IFADDR_STATE_ERRDAD; |
1743 | spin_unlock_bh(&ifp->state_lock); | 1742 | spin_unlock_bh(&ifp->lock); |
1744 | 1743 | ||
1745 | addrconf_mod_dad_work(ifp, 0); | 1744 | addrconf_mod_dad_work(ifp, 0); |
1746 | } | 1745 | } |
@@ -2369,7 +2368,7 @@ ok: | |||
2369 | u32 stored_lft; | 2368 | u32 stored_lft; |
2370 | 2369 | ||
2371 | /* update lifetime (RFC2462 5.5.3 e) */ | 2370 | /* update lifetime (RFC2462 5.5.3 e) */ |
2372 | spin_lock(&ifp->lock); | 2371 | spin_lock_bh(&ifp->lock); |
2373 | now = jiffies; | 2372 | now = jiffies; |
2374 | if (ifp->valid_lft > (now - ifp->tstamp) / HZ) | 2373 | if (ifp->valid_lft > (now - ifp->tstamp) / HZ) |
2375 | stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; | 2374 | stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; |
@@ -2399,12 +2398,12 @@ ok: | |||
2399 | ifp->tstamp = now; | 2398 | ifp->tstamp = now; |
2400 | flags = ifp->flags; | 2399 | flags = ifp->flags; |
2401 | ifp->flags &= ~IFA_F_DEPRECATED; | 2400 | ifp->flags &= ~IFA_F_DEPRECATED; |
2402 | spin_unlock(&ifp->lock); | 2401 | spin_unlock_bh(&ifp->lock); |
2403 | 2402 | ||
2404 | if (!(flags&IFA_F_TENTATIVE)) | 2403 | if (!(flags&IFA_F_TENTATIVE)) |
2405 | ipv6_ifa_notify(0, ifp); | 2404 | ipv6_ifa_notify(0, ifp); |
2406 | } else | 2405 | } else |
2407 | spin_unlock(&ifp->lock); | 2406 | spin_unlock_bh(&ifp->lock); |
2408 | 2407 | ||
2409 | manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft, | 2408 | manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft, |
2410 | create, now); | 2409 | create, now); |
@@ -3265,10 +3264,10 @@ restart: | |||
3265 | 3264 | ||
3266 | write_unlock_bh(&idev->lock); | 3265 | write_unlock_bh(&idev->lock); |
3267 | 3266 | ||
3268 | spin_lock_bh(&ifa->state_lock); | 3267 | spin_lock_bh(&ifa->lock); |
3269 | state = ifa->state; | 3268 | state = ifa->state; |
3270 | ifa->state = INET6_IFADDR_STATE_DEAD; | 3269 | ifa->state = INET6_IFADDR_STATE_DEAD; |
3271 | spin_unlock_bh(&ifa->state_lock); | 3270 | spin_unlock_bh(&ifa->lock); |
3272 | 3271 | ||
3273 | if (state != INET6_IFADDR_STATE_DEAD) { | 3272 | if (state != INET6_IFADDR_STATE_DEAD) { |
3274 | __ipv6_ifa_notify(RTM_DELADDR, ifa); | 3273 | __ipv6_ifa_notify(RTM_DELADDR, ifa); |
@@ -3426,12 +3425,12 @@ static void addrconf_dad_start(struct inet6_ifaddr *ifp) | |||
3426 | { | 3425 | { |
3427 | bool begin_dad = false; | 3426 | bool begin_dad = false; |
3428 | 3427 | ||
3429 | spin_lock_bh(&ifp->state_lock); | 3428 | spin_lock_bh(&ifp->lock); |
3430 | if (ifp->state != INET6_IFADDR_STATE_DEAD) { | 3429 | if (ifp->state != INET6_IFADDR_STATE_DEAD) { |
3431 | ifp->state = INET6_IFADDR_STATE_PREDAD; | 3430 | ifp->state = INET6_IFADDR_STATE_PREDAD; |
3432 | begin_dad = true; | 3431 | begin_dad = true; |
3433 | } | 3432 | } |
3434 | spin_unlock_bh(&ifp->state_lock); | 3433 | spin_unlock_bh(&ifp->lock); |
3435 | 3434 | ||
3436 | if (begin_dad) | 3435 | if (begin_dad) |
3437 | addrconf_mod_dad_work(ifp, 0); | 3436 | addrconf_mod_dad_work(ifp, 0); |
@@ -3453,7 +3452,7 @@ static void addrconf_dad_work(struct work_struct *w) | |||
3453 | 3452 | ||
3454 | rtnl_lock(); | 3453 | rtnl_lock(); |
3455 | 3454 | ||
3456 | spin_lock_bh(&ifp->state_lock); | 3455 | spin_lock_bh(&ifp->lock); |
3457 | if (ifp->state == INET6_IFADDR_STATE_PREDAD) { | 3456 | if (ifp->state == INET6_IFADDR_STATE_PREDAD) { |
3458 | action = DAD_BEGIN; | 3457 | action = DAD_BEGIN; |
3459 | ifp->state = INET6_IFADDR_STATE_DAD; | 3458 | ifp->state = INET6_IFADDR_STATE_DAD; |
@@ -3461,7 +3460,7 @@ static void addrconf_dad_work(struct work_struct *w) | |||
3461 | action = DAD_ABORT; | 3460 | action = DAD_ABORT; |
3462 | ifp->state = INET6_IFADDR_STATE_POSTDAD; | 3461 | ifp->state = INET6_IFADDR_STATE_POSTDAD; |
3463 | } | 3462 | } |
3464 | spin_unlock_bh(&ifp->state_lock); | 3463 | spin_unlock_bh(&ifp->lock); |
3465 | 3464 | ||
3466 | if (action == DAD_BEGIN) { | 3465 | if (action == DAD_BEGIN) { |
3467 | addrconf_dad_begin(ifp); | 3466 | addrconf_dad_begin(ifp); |