diff options
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r-- | net/ipv6/addrconf.c | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 1220e2c7831e..e83852ab4dc8 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -2227,10 +2227,24 @@ int addrconf_del_ifaddr(struct net *net, void __user *arg) | |||
2227 | return err; | 2227 | return err; |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr, | ||
2231 | int plen, int scope) | ||
2232 | { | ||
2233 | struct inet6_ifaddr *ifp; | ||
2234 | |||
2235 | ifp = ipv6_add_addr(idev, addr, plen, scope, IFA_F_PERMANENT); | ||
2236 | if (!IS_ERR(ifp)) { | ||
2237 | spin_lock_bh(&ifp->lock); | ||
2238 | ifp->flags &= ~IFA_F_TENTATIVE; | ||
2239 | spin_unlock_bh(&ifp->lock); | ||
2240 | ipv6_ifa_notify(RTM_NEWADDR, ifp); | ||
2241 | in6_ifa_put(ifp); | ||
2242 | } | ||
2243 | } | ||
2244 | |||
2230 | #if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) | 2245 | #if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) |
2231 | static void sit_add_v4_addrs(struct inet6_dev *idev) | 2246 | static void sit_add_v4_addrs(struct inet6_dev *idev) |
2232 | { | 2247 | { |
2233 | struct inet6_ifaddr * ifp; | ||
2234 | struct in6_addr addr; | 2248 | struct in6_addr addr; |
2235 | struct net_device *dev; | 2249 | struct net_device *dev; |
2236 | struct net *net = dev_net(idev->dev); | 2250 | struct net *net = dev_net(idev->dev); |
@@ -2249,14 +2263,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev) | |||
2249 | } | 2263 | } |
2250 | 2264 | ||
2251 | if (addr.s6_addr32[3]) { | 2265 | if (addr.s6_addr32[3]) { |
2252 | ifp = ipv6_add_addr(idev, &addr, 128, scope, IFA_F_PERMANENT); | 2266 | add_addr(idev, &addr, 128, scope); |
2253 | if (!IS_ERR(ifp)) { | ||
2254 | spin_lock_bh(&ifp->lock); | ||
2255 | ifp->flags &= ~IFA_F_TENTATIVE; | ||
2256 | spin_unlock_bh(&ifp->lock); | ||
2257 | ipv6_ifa_notify(RTM_NEWADDR, ifp); | ||
2258 | in6_ifa_put(ifp); | ||
2259 | } | ||
2260 | return; | 2267 | return; |
2261 | } | 2268 | } |
2262 | 2269 | ||
@@ -2284,15 +2291,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev) | |||
2284 | else | 2291 | else |
2285 | plen = 96; | 2292 | plen = 96; |
2286 | 2293 | ||
2287 | ifp = ipv6_add_addr(idev, &addr, plen, flag, | 2294 | add_addr(idev, &addr, plen, flag); |
2288 | IFA_F_PERMANENT); | ||
2289 | if (!IS_ERR(ifp)) { | ||
2290 | spin_lock_bh(&ifp->lock); | ||
2291 | ifp->flags &= ~IFA_F_TENTATIVE; | ||
2292 | spin_unlock_bh(&ifp->lock); | ||
2293 | ipv6_ifa_notify(RTM_NEWADDR, ifp); | ||
2294 | in6_ifa_put(ifp); | ||
2295 | } | ||
2296 | } | 2295 | } |
2297 | } | 2296 | } |
2298 | } | 2297 | } |
@@ -2302,7 +2301,6 @@ static void sit_add_v4_addrs(struct inet6_dev *idev) | |||
2302 | static void init_loopback(struct net_device *dev) | 2301 | static void init_loopback(struct net_device *dev) |
2303 | { | 2302 | { |
2304 | struct inet6_dev *idev; | 2303 | struct inet6_dev *idev; |
2305 | struct inet6_ifaddr * ifp; | ||
2306 | 2304 | ||
2307 | /* ::1 */ | 2305 | /* ::1 */ |
2308 | 2306 | ||
@@ -2313,14 +2311,7 @@ static void init_loopback(struct net_device *dev) | |||
2313 | return; | 2311 | return; |
2314 | } | 2312 | } |
2315 | 2313 | ||
2316 | ifp = ipv6_add_addr(idev, &in6addr_loopback, 128, IFA_HOST, IFA_F_PERMANENT); | 2314 | add_addr(idev, &in6addr_loopback, 128, IFA_HOST); |
2317 | if (!IS_ERR(ifp)) { | ||
2318 | spin_lock_bh(&ifp->lock); | ||
2319 | ifp->flags &= ~IFA_F_TENTATIVE; | ||
2320 | spin_unlock_bh(&ifp->lock); | ||
2321 | ipv6_ifa_notify(RTM_NEWADDR, ifp); | ||
2322 | in6_ifa_put(ifp); | ||
2323 | } | ||
2324 | } | 2315 | } |
2325 | 2316 | ||
2326 | static void addrconf_add_linklocal(struct inet6_dev *idev, struct in6_addr *addr) | 2317 | static void addrconf_add_linklocal(struct inet6_dev *idev, struct in6_addr *addr) |
@@ -3647,7 +3638,8 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) | |||
3647 | kfree_skb(skb); | 3638 | kfree_skb(skb); |
3648 | goto errout; | 3639 | goto errout; |
3649 | } | 3640 | } |
3650 | err = rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); | 3641 | rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); |
3642 | return; | ||
3651 | errout: | 3643 | errout: |
3652 | if (err < 0) | 3644 | if (err < 0) |
3653 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); | 3645 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); |
@@ -3858,7 +3850,8 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev) | |||
3858 | kfree_skb(skb); | 3850 | kfree_skb(skb); |
3859 | goto errout; | 3851 | goto errout; |
3860 | } | 3852 | } |
3861 | err = rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); | 3853 | rtnl_notify(skb, net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); |
3854 | return; | ||
3862 | errout: | 3855 | errout: |
3863 | if (err < 0) | 3856 | if (err < 0) |
3864 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); | 3857 | rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); |
@@ -3928,7 +3921,8 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev, | |||
3928 | kfree_skb(skb); | 3921 | kfree_skb(skb); |
3929 | goto errout; | 3922 | goto errout; |
3930 | } | 3923 | } |
3931 | err = rtnl_notify(skb, net, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC); | 3924 | rtnl_notify(skb, net, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC); |
3925 | return; | ||
3932 | errout: | 3926 | errout: |
3933 | if (err < 0) | 3927 | if (err < 0) |
3934 | rtnl_set_sk_err(net, RTNLGRP_IPV6_PREFIX, err); | 3928 | rtnl_set_sk_err(net, RTNLGRP_IPV6_PREFIX, err); |