addrconf.c (2702e0a46c2d28da92b32c9b068ee1291fc0de35) | addrconf.c (1ce85fe402137824246bad03ff85f3913d565c17) |
---|---|
1/* 2 * IPv6 Address [auto]configuration 3 * Linux INET6 implementation 4 * 5 * Authors: 6 * Pedro Roque <roque@di.fc.ul.pt> 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 8 * --- 2210 unchanged lines hidden (view full) --- 2219 2220 rtnl_lock(); 2221 err = inet6_addr_del(net, ireq.ifr6_ifindex, &ireq.ifr6_addr, 2222 ireq.ifr6_prefixlen); 2223 rtnl_unlock(); 2224 return err; 2225} 2226 | 1/* 2 * IPv6 Address [auto]configuration 3 * Linux INET6 implementation 4 * 5 * Authors: 6 * Pedro Roque <roque@di.fc.ul.pt> 7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 8 * --- 2210 unchanged lines hidden (view full) --- 2219 2220 rtnl_lock(); 2221 err = inet6_addr_del(net, ireq.ifr6_ifindex, &ireq.ifr6_addr, 2222 ireq.ifr6_prefixlen); 2223 rtnl_unlock(); 2224 return err; 2225} 2226 |
2227static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr, 2228 int plen, int scope) 2229{ 2230 struct inet6_ifaddr *ifp; 2231 2232 ifp = ipv6_add_addr(idev, addr, plen, scope, IFA_F_PERMANENT); 2233 if (!IS_ERR(ifp)) { 2234 spin_lock_bh(&ifp->lock); 2235 ifp->flags &= ~IFA_F_TENTATIVE; 2236 spin_unlock_bh(&ifp->lock); 2237 ipv6_ifa_notify(RTM_NEWADDR, ifp); 2238 in6_ifa_put(ifp); 2239 } 2240} 2241 |
|
2227#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) 2228static void sit_add_v4_addrs(struct inet6_dev *idev) 2229{ | 2242#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) 2243static void sit_add_v4_addrs(struct inet6_dev *idev) 2244{ |
2230 struct inet6_ifaddr * ifp; | |
2231 struct in6_addr addr; 2232 struct net_device *dev; 2233 struct net *net = dev_net(idev->dev); 2234 int scope; 2235 2236 ASSERT_RTNL(); 2237 2238 memset(&addr, 0, sizeof(struct in6_addr)); 2239 memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4); 2240 2241 if (idev->dev->flags&IFF_POINTOPOINT) { 2242 addr.s6_addr32[0] = htonl(0xfe800000); 2243 scope = IFA_LINK; 2244 } else { 2245 scope = IPV6_ADDR_COMPATv4; 2246 } 2247 2248 if (addr.s6_addr32[3]) { | 2245 struct in6_addr addr; 2246 struct net_device *dev; 2247 struct net *net = dev_net(idev->dev); 2248 int scope; 2249 2250 ASSERT_RTNL(); 2251 2252 memset(&addr, 0, sizeof(struct in6_addr)); 2253 memcpy(&addr.s6_addr32[3], idev->dev->dev_addr, 4); 2254 2255 if (idev->dev->flags&IFF_POINTOPOINT) { 2256 addr.s6_addr32[0] = htonl(0xfe800000); 2257 scope = IFA_LINK; 2258 } else { 2259 scope = IPV6_ADDR_COMPATv4; 2260 } 2261 2262 if (addr.s6_addr32[3]) { |
2249 ifp = ipv6_add_addr(idev, &addr, 128, scope, IFA_F_PERMANENT); 2250 if (!IS_ERR(ifp)) { 2251 spin_lock_bh(&ifp->lock); 2252 ifp->flags &= ~IFA_F_TENTATIVE; 2253 spin_unlock_bh(&ifp->lock); 2254 ipv6_ifa_notify(RTM_NEWADDR, ifp); 2255 in6_ifa_put(ifp); 2256 } | 2263 add_addr(idev, &addr, 128, scope); |
2257 return; 2258 } 2259 2260 for_each_netdev(net, dev) { 2261 struct in_device * in_dev = __in_dev_get_rtnl(dev); 2262 if (in_dev && (dev->flags & IFF_UP)) { 2263 struct in_ifaddr * ifa; 2264 --- 11 unchanged lines hidden (view full) --- 2276 continue; 2277 flag |= IFA_HOST; 2278 } 2279 if (idev->dev->flags&IFF_POINTOPOINT) 2280 plen = 64; 2281 else 2282 plen = 96; 2283 | 2264 return; 2265 } 2266 2267 for_each_netdev(net, dev) { 2268 struct in_device * in_dev = __in_dev_get_rtnl(dev); 2269 if (in_dev && (dev->flags & IFF_UP)) { 2270 struct in_ifaddr * ifa; 2271 --- 11 unchanged lines hidden (view full) --- 2283 continue; 2284 flag |= IFA_HOST; 2285 } 2286 if (idev->dev->flags&IFF_POINTOPOINT) 2287 plen = 64; 2288 else 2289 plen = 96; 2290 |
2284 ifp = ipv6_add_addr(idev, &addr, plen, flag, 2285 IFA_F_PERMANENT); 2286 if (!IS_ERR(ifp)) { 2287 spin_lock_bh(&ifp->lock); 2288 ifp->flags &= ~IFA_F_TENTATIVE; 2289 spin_unlock_bh(&ifp->lock); 2290 ipv6_ifa_notify(RTM_NEWADDR, ifp); 2291 in6_ifa_put(ifp); 2292 } | 2291 add_addr(idev, &addr, plen, flag); |
2293 } 2294 } 2295 } 2296} 2297#endif 2298 2299static void init_loopback(struct net_device *dev) 2300{ 2301 struct inet6_dev *idev; | 2292 } 2293 } 2294 } 2295} 2296#endif 2297 2298static void init_loopback(struct net_device *dev) 2299{ 2300 struct inet6_dev *idev; |
2302 struct inet6_ifaddr * ifp; | |
2303 2304 /* ::1 */ 2305 2306 ASSERT_RTNL(); 2307 2308 if ((idev = ipv6_find_idev(dev)) == NULL) { 2309 printk(KERN_DEBUG "init loopback: add_dev failed\n"); 2310 return; 2311 } 2312 | 2301 2302 /* ::1 */ 2303 2304 ASSERT_RTNL(); 2305 2306 if ((idev = ipv6_find_idev(dev)) == NULL) { 2307 printk(KERN_DEBUG "init loopback: add_dev failed\n"); 2308 return; 2309 } 2310 |
2313 ifp = ipv6_add_addr(idev, &in6addr_loopback, 128, IFA_HOST, IFA_F_PERMANENT); 2314 if (!IS_ERR(ifp)) { 2315 spin_lock_bh(&ifp->lock); 2316 ifp->flags &= ~IFA_F_TENTATIVE; 2317 spin_unlock_bh(&ifp->lock); 2318 ipv6_ifa_notify(RTM_NEWADDR, ifp); 2319 in6_ifa_put(ifp); 2320 } | 2311 add_addr(idev, &in6addr_loopback, 128, IFA_HOST); |
2321} 2322 2323static void addrconf_add_linklocal(struct inet6_dev *idev, struct in6_addr *addr) 2324{ 2325 struct inet6_ifaddr * ifp; 2326 u32 addr_flags = IFA_F_PERMANENT; 2327 2328#ifdef CONFIG_IPV6_OPTIMISTIC_DAD --- 1313 unchanged lines hidden (view full) --- 3642 3643 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0); 3644 if (err < 0) { 3645 /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */ 3646 WARN_ON(err == -EMSGSIZE); 3647 kfree_skb(skb); 3648 goto errout; 3649 } | 2312} 2313 2314static void addrconf_add_linklocal(struct inet6_dev *idev, struct in6_addr *addr) 2315{ 2316 struct inet6_ifaddr * ifp; 2317 u32 addr_flags = IFA_F_PERMANENT; 2318 2319#ifdef CONFIG_IPV6_OPTIMISTIC_DAD --- 1313 unchanged lines hidden (view full) --- 3633 3634 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0); 3635 if (err < 0) { 3636 /* -EMSGSIZE implies BUG in inet6_ifaddr_msgsize() */ 3637 WARN_ON(err == -EMSGSIZE); 3638 kfree_skb(skb); 3639 goto errout; 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; |
3651errout: 3652 if (err < 0) 3653 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); 3654} 3655 3656static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, 3657 __s32 *array, int bytes) 3658{ --- 194 unchanged lines hidden (view full) --- 3853 3854 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0); 3855 if (err < 0) { 3856 /* -EMSGSIZE implies BUG in inet6_if_nlmsg_size() */ 3857 WARN_ON(err == -EMSGSIZE); 3858 kfree_skb(skb); 3859 goto errout; 3860 } | 3643errout: 3644 if (err < 0) 3645 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); 3646} 3647 3648static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, 3649 __s32 *array, int bytes) 3650{ --- 194 unchanged lines hidden (view full) --- 3845 3846 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0); 3847 if (err < 0) { 3848 /* -EMSGSIZE implies BUG in inet6_if_nlmsg_size() */ 3849 WARN_ON(err == -EMSGSIZE); 3850 kfree_skb(skb); 3851 goto errout; 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; |
3862errout: 3863 if (err < 0) 3864 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); 3865} 3866 3867static inline size_t inet6_prefix_nlmsg_size(void) 3868{ 3869 return NLMSG_ALIGN(sizeof(struct prefixmsg)) --- 53 unchanged lines hidden (view full) --- 3923 3924 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0); 3925 if (err < 0) { 3926 /* -EMSGSIZE implies BUG in inet6_prefix_nlmsg_size() */ 3927 WARN_ON(err == -EMSGSIZE); 3928 kfree_skb(skb); 3929 goto errout; 3930 } | 3855errout: 3856 if (err < 0) 3857 rtnl_set_sk_err(net, RTNLGRP_IPV6_IFADDR, err); 3858} 3859 3860static inline size_t inet6_prefix_nlmsg_size(void) 3861{ 3862 return NLMSG_ALIGN(sizeof(struct prefixmsg)) --- 53 unchanged lines hidden (view full) --- 3916 3917 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0); 3918 if (err < 0) { 3919 /* -EMSGSIZE implies BUG in inet6_prefix_nlmsg_size() */ 3920 WARN_ON(err == -EMSGSIZE); 3921 kfree_skb(skb); 3922 goto errout; 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; |
3932errout: 3933 if (err < 0) 3934 rtnl_set_sk_err(net, RTNLGRP_IPV6_PREFIX, err); 3935} 3936 3937static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) 3938{ 3939 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); --- 634 unchanged lines hidden --- | 3926errout: 3927 if (err < 0) 3928 rtnl_set_sk_err(net, RTNLGRP_IPV6_PREFIX, err); 3929} 3930 3931static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) 3932{ 3933 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); --- 634 unchanged lines hidden --- |