anycast.c (c4a6853d8fb2b122686bc6a7c472956e87090f4e) | anycast.c (63159f29be1df7f93563a8a0f78c5e65fc844ed6) |
---|---|
1/* 2 * Anycast support for IPv6 3 * Linux INET6 implementation 4 * 5 * Authors: 6 * David L Stevens (dlstevens@us.ibm.com) 7 * 8 * based heavily on net/ipv6/mcast.c --- 56 unchanged lines hidden (view full) --- 65 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 66 return -EPERM; 67 if (ipv6_addr_is_multicast(addr)) 68 return -EINVAL; 69 if (ipv6_chk_addr(net, addr, NULL, 0)) 70 return -EINVAL; 71 72 pac = sock_kmalloc(sk, sizeof(struct ipv6_ac_socklist), GFP_KERNEL); | 1/* 2 * Anycast support for IPv6 3 * Linux INET6 implementation 4 * 5 * Authors: 6 * David L Stevens (dlstevens@us.ibm.com) 7 * 8 * based heavily on net/ipv6/mcast.c --- 56 unchanged lines hidden (view full) --- 65 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 66 return -EPERM; 67 if (ipv6_addr_is_multicast(addr)) 68 return -EINVAL; 69 if (ipv6_chk_addr(net, addr, NULL, 0)) 70 return -EINVAL; 71 72 pac = sock_kmalloc(sk, sizeof(struct ipv6_ac_socklist), GFP_KERNEL); |
73 if (pac == NULL) | 73 if (!pac) |
74 return -ENOMEM; 75 pac->acl_next = NULL; 76 pac->acl_addr = *addr; 77 78 if (ifindex == 0) { 79 struct rt6_info *rt; 80 81 rt = rt6_lookup(net, addr, NULL, 0, 0); --- 6 unchanged lines hidden (view full) --- 88 } else { 89 /* router, no matching interface: just pick one */ 90 dev = __dev_get_by_flags(net, IFF_UP, 91 IFF_UP | IFF_LOOPBACK); 92 } 93 } else 94 dev = __dev_get_by_index(net, ifindex); 95 | 74 return -ENOMEM; 75 pac->acl_next = NULL; 76 pac->acl_addr = *addr; 77 78 if (ifindex == 0) { 79 struct rt6_info *rt; 80 81 rt = rt6_lookup(net, addr, NULL, 0, 0); --- 6 unchanged lines hidden (view full) --- 88 } else { 89 /* router, no matching interface: just pick one */ 90 dev = __dev_get_by_flags(net, IFF_UP, 91 IFF_UP | IFF_LOOPBACK); 92 } 93 } else 94 dev = __dev_get_by_index(net, ifindex); 95 |
96 if (dev == NULL) { | 96 if (!dev) { |
97 err = -ENODEV; 98 goto error; 99 } 100 101 idev = __in6_dev_get(dev); 102 if (!idev) { 103 if (ifindex) 104 err = -ENODEV; --- 112 unchanged lines hidden (view full) --- 217 218static struct ifacaddr6 *aca_alloc(struct rt6_info *rt, 219 const struct in6_addr *addr) 220{ 221 struct inet6_dev *idev = rt->rt6i_idev; 222 struct ifacaddr6 *aca; 223 224 aca = kzalloc(sizeof(*aca), GFP_ATOMIC); | 97 err = -ENODEV; 98 goto error; 99 } 100 101 idev = __in6_dev_get(dev); 102 if (!idev) { 103 if (ifindex) 104 err = -ENODEV; --- 112 unchanged lines hidden (view full) --- 217 218static struct ifacaddr6 *aca_alloc(struct rt6_info *rt, 219 const struct in6_addr *addr) 220{ 221 struct inet6_dev *idev = rt->rt6i_idev; 222 struct ifacaddr6 *aca; 223 224 aca = kzalloc(sizeof(*aca), GFP_ATOMIC); |
225 if (aca == NULL) | 225 if (!aca) |
226 return NULL; 227 228 aca->aca_addr = *addr; 229 in6_dev_hold(idev); 230 aca->aca_idev = idev; 231 aca->aca_rt = rt; 232 aca->aca_users = 1; 233 /* aca_tstamp should be updated upon changes */ --- 29 unchanged lines hidden (view full) --- 263 } 264 265 rt = addrconf_dst_alloc(idev, addr, true); 266 if (IS_ERR(rt)) { 267 err = PTR_ERR(rt); 268 goto out; 269 } 270 aca = aca_alloc(rt, addr); | 226 return NULL; 227 228 aca->aca_addr = *addr; 229 in6_dev_hold(idev); 230 aca->aca_idev = idev; 231 aca->aca_rt = rt; 232 aca->aca_users = 1; 233 /* aca_tstamp should be updated upon changes */ --- 29 unchanged lines hidden (view full) --- 263 } 264 265 rt = addrconf_dst_alloc(idev, addr, true); 266 if (IS_ERR(rt)) { 267 err = PTR_ERR(rt); 268 goto out; 269 } 270 aca = aca_alloc(rt, addr); |
271 if (aca == NULL) { | 271 if (!aca) { |
272 ip6_rt_put(rt); 273 err = -ENOMEM; 274 goto out; 275 } 276 277 aca->aca_next = idev->ac_list; 278 idev->ac_list = aca; 279 --- 52 unchanged lines hidden (view full) --- 332 return 0; 333} 334 335/* called with rtnl_lock() */ 336static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr) 337{ 338 struct inet6_dev *idev = __in6_dev_get(dev); 339 | 272 ip6_rt_put(rt); 273 err = -ENOMEM; 274 goto out; 275 } 276 277 aca->aca_next = idev->ac_list; 278 idev->ac_list = aca; 279 --- 52 unchanged lines hidden (view full) --- 332 return 0; 333} 334 335/* called with rtnl_lock() */ 336static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr) 337{ 338 struct inet6_dev *idev = __in6_dev_get(dev); 339 |
340 if (idev == NULL) | 340 if (!idev) |
341 return -ENODEV; 342 return __ipv6_dev_ac_dec(idev, addr); 343} 344 345void ipv6_ac_destroy_dev(struct inet6_dev *idev) 346{ 347 struct ifacaddr6 *aca; 348 --- 208 unchanged lines hidden --- | 341 return -ENODEV; 342 return __ipv6_dev_ac_dec(idev, addr); 343} 344 345void ipv6_ac_destroy_dev(struct inet6_dev *idev) 346{ 347 struct ifacaddr6 *aca; 348 --- 208 unchanged lines hidden --- |