addrconf.c (8f0315190dec88bf035d50e4fd1db89859b414f6) | addrconf.c (4af04aba93f47699e7ac33e7cfd4da22550e6114) |
---|---|
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 * --- 616 unchanged lines hidden (view full) --- 625 ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC); 626 627 if (ifa == NULL) { 628 ADBG(("ipv6_add_addr: malloc failed\n")); 629 err = -ENOBUFS; 630 goto out; 631 } 632 | 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 * --- 616 unchanged lines hidden (view full) --- 625 ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC); 626 627 if (ifa == NULL) { 628 ADBG(("ipv6_add_addr: malloc failed\n")); 629 err = -ENOBUFS; 630 goto out; 631 } 632 |
633 rt = addrconf_dst_alloc(idev, addr, false); | 633 rt = addrconf_dst_alloc(idev, addr, 0); |
634 if (IS_ERR(rt)) { 635 err = PTR_ERR(rt); 636 goto out; 637 } 638 | 634 if (IS_ERR(rt)) { 635 err = PTR_ERR(rt); 636 goto out; 637 } 638 |
639 ifa->addr = *addr; | 639 ipv6_addr_copy(&ifa->addr, addr); |
640 641 spin_lock_init(&ifa->lock); 642 spin_lock_init(&ifa->state_lock); 643 init_timer(&ifa->timer); 644 INIT_HLIST_NODE(&ifa->addr_lst); 645 ifa->timer.data = (unsigned long) ifa; 646 ifa->scope = scope; 647 ifa->prefix_len = pfxlen; --- 4 unchanged lines hidden (view full) --- 652 653 /* 654 * part one of RFC 4429, section 3.3 655 * We should not configure an address as 656 * optimistic if we do not yet know the link 657 * layer address of our nexhop router 658 */ 659 | 640 641 spin_lock_init(&ifa->lock); 642 spin_lock_init(&ifa->state_lock); 643 init_timer(&ifa->timer); 644 INIT_HLIST_NODE(&ifa->addr_lst); 645 ifa->timer.data = (unsigned long) ifa; 646 ifa->scope = scope; 647 ifa->prefix_len = pfxlen; --- 4 unchanged lines hidden (view full) --- 652 653 /* 654 * part one of RFC 4429, section 3.3 655 * We should not configure an address as 656 * optimistic if we do not yet know the link 657 * layer address of our nexhop router 658 */ 659 |
660 if (dst_get_neighbour_noref_raw(&rt->dst) == NULL) | 660 if (dst_get_neighbour_raw(&rt->dst) == NULL) |
661 ifa->flags &= ~IFA_F_OPTIMISTIC; 662 663 ifa->idev = idev; 664 in6_dev_hold(idev); 665 /* For caller */ 666 in6_ifa_hold(ifa); 667 668 /* Add to big hash table */ --- 554 unchanged lines hidden (view full) --- 1223try_nextdev: 1224 read_unlock_bh(&idev->lock); 1225 } 1226 rcu_read_unlock(); 1227 1228 if (!hiscore->ifa) 1229 return -EADDRNOTAVAIL; 1230 | 661 ifa->flags &= ~IFA_F_OPTIMISTIC; 662 663 ifa->idev = idev; 664 in6_dev_hold(idev); 665 /* For caller */ 666 in6_ifa_hold(ifa); 667 668 /* Add to big hash table */ --- 554 unchanged lines hidden (view full) --- 1223try_nextdev: 1224 read_unlock_bh(&idev->lock); 1225 } 1226 rcu_read_unlock(); 1227 1228 if (!hiscore->ifa) 1229 return -EADDRNOTAVAIL; 1230 |
1231 *saddr = hiscore->ifa->addr; | 1231 ipv6_addr_copy(saddr, &hiscore->ifa->addr); |
1232 in6_ifa_put(hiscore->ifa); 1233 return 0; 1234} 1235EXPORT_SYMBOL(ipv6_dev_get_saddr); 1236 1237int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr, 1238 unsigned char banned_flags) 1239{ --- 4 unchanged lines hidden (view full) --- 1244 idev = __in6_dev_get(dev); 1245 if (idev) { 1246 struct inet6_ifaddr *ifp; 1247 1248 read_lock_bh(&idev->lock); 1249 list_for_each_entry(ifp, &idev->addr_list, if_list) { 1250 if (ifp->scope == IFA_LINK && 1251 !(ifp->flags & banned_flags)) { | 1232 in6_ifa_put(hiscore->ifa); 1233 return 0; 1234} 1235EXPORT_SYMBOL(ipv6_dev_get_saddr); 1236 1237int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr, 1238 unsigned char banned_flags) 1239{ --- 4 unchanged lines hidden (view full) --- 1244 idev = __in6_dev_get(dev); 1245 if (idev) { 1246 struct inet6_ifaddr *ifp; 1247 1248 read_lock_bh(&idev->lock); 1249 list_for_each_entry(ifp, &idev->addr_list, if_list) { 1250 if (ifp->scope == IFA_LINK && 1251 !(ifp->flags & banned_flags)) { |
1252 *addr = ifp->addr; | 1252 ipv6_addr_copy(addr, &ifp->addr); |
1253 err = 0; 1254 break; 1255 } 1256 } 1257 read_unlock_bh(&idev->lock); 1258 } 1259 rcu_read_unlock(); 1260 return err; --- 434 unchanged lines hidden (view full) --- 1695 .fc_ifindex = dev->ifindex, 1696 .fc_expires = expires, 1697 .fc_dst_len = plen, 1698 .fc_flags = RTF_UP | flags, 1699 .fc_nlinfo.nl_net = dev_net(dev), 1700 .fc_protocol = RTPROT_KERNEL, 1701 }; 1702 | 1253 err = 0; 1254 break; 1255 } 1256 } 1257 read_unlock_bh(&idev->lock); 1258 } 1259 rcu_read_unlock(); 1260 return err; --- 434 unchanged lines hidden (view full) --- 1695 .fc_ifindex = dev->ifindex, 1696 .fc_expires = expires, 1697 .fc_dst_len = plen, 1698 .fc_flags = RTF_UP | flags, 1699 .fc_nlinfo.nl_net = dev_net(dev), 1700 .fc_protocol = RTPROT_KERNEL, 1701 }; 1702 |
1703 cfg.fc_dst = *pfx; | 1703 ipv6_addr_copy(&cfg.fc_dst, pfx); |
1704 1705 /* Prevent useless cloning on PtP SIT. 1706 This thing is done here expecting that the whole 1707 class of non-broadcast devices need not cloning. 1708 */ 1709#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) 1710 if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT)) 1711 cfg.fc_flags |= RTF_NONEXTHOP; --- 88 unchanged lines hidden (view full) --- 1800 idev = ipv6_find_idev(dev); 1801 if (!idev) 1802 return ERR_PTR(-ENOBUFS); 1803 1804 if (idev->cnf.disable_ipv6) 1805 return ERR_PTR(-EACCES); 1806 1807 /* Add default multicast route */ | 1704 1705 /* Prevent useless cloning on PtP SIT. 1706 This thing is done here expecting that the whole 1707 class of non-broadcast devices need not cloning. 1708 */ 1709#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE) 1710 if (dev->type == ARPHRD_SIT && (dev->flags & IFF_POINTOPOINT)) 1711 cfg.fc_flags |= RTF_NONEXTHOP; --- 88 unchanged lines hidden (view full) --- 1800 idev = ipv6_find_idev(dev); 1801 if (!idev) 1802 return ERR_PTR(-ENOBUFS); 1803 1804 if (idev->cnf.disable_ipv6) 1805 return ERR_PTR(-EACCES); 1806 1807 /* Add default multicast route */ |
1808 addrconf_add_mroute(dev); | 1808 if (!(dev->flags & IFF_LOOPBACK)) 1809 addrconf_add_mroute(dev); |
1809 1810 /* Add link local route */ 1811 addrconf_add_lroute(dev); 1812 return idev; 1813} 1814 1815void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len) 1816{ --- 3044 unchanged lines hidden --- | 1810 1811 /* Add link local route */ 1812 addrconf_add_lroute(dev); 1813 return idev; 1814} 1815 1816void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len) 1817{ --- 3044 unchanged lines hidden --- |