addrconf.c (43d93947a54cf9323198a3a37eaf3ec14adb23e1) | addrconf.c (5d9efa7ee99eed58388f186c13cf2e2a87e9ceb4) |
---|---|
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 * --- 69 unchanged lines hidden (view full) --- 78#include <net/addrconf.h> 79#include <net/tcp.h> 80#include <net/ip.h> 81#include <net/netlink.h> 82#include <net/pkt_sched.h> 83#include <linux/if_tunnel.h> 84#include <linux/rtnetlink.h> 85#include <linux/netconf.h> | 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 * --- 69 unchanged lines hidden (view full) --- 78#include <net/addrconf.h> 79#include <net/tcp.h> 80#include <net/ip.h> 81#include <net/netlink.h> 82#include <net/pkt_sched.h> 83#include <linux/if_tunnel.h> 84#include <linux/rtnetlink.h> 85#include <linux/netconf.h> |
86 87#ifdef CONFIG_IPV6_PRIVACY | |
88#include <linux/random.h> | 86#include <linux/random.h> |
89#endif 90 | |
91#include <linux/uaccess.h> 92#include <asm/unaligned.h> 93 94#include <linux/proc_fs.h> 95#include <linux/seq_file.h> 96#include <linux/export.h> 97 98/* Set to 3 to get tracing... */ --- 20 unchanged lines hidden (view full) --- 119{ 120} 121 122static inline void addrconf_sysctl_unregister(struct inet6_dev *idev) 123{ 124} 125#endif 126 | 87#include <linux/uaccess.h> 88#include <asm/unaligned.h> 89 90#include <linux/proc_fs.h> 91#include <linux/seq_file.h> 92#include <linux/export.h> 93 94/* Set to 3 to get tracing... */ --- 20 unchanged lines hidden (view full) --- 115{ 116} 117 118static inline void addrconf_sysctl_unregister(struct inet6_dev *idev) 119{ 120} 121#endif 122 |
127#ifdef CONFIG_IPV6_PRIVACY | |
128static void __ipv6_regen_rndid(struct inet6_dev *idev); 129static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 130static void ipv6_regen_rndid(unsigned long data); | 123static void __ipv6_regen_rndid(struct inet6_dev *idev); 124static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 125static void ipv6_regen_rndid(unsigned long data); |
131#endif | |
132 133static int ipv6_generate_eui64(u8 *eui, struct net_device *dev); 134static int ipv6_count_addresses(struct inet6_dev *idev); 135 136/* 137 * Configured unicast address hash table 138 */ 139static struct hlist_head inet6_addr_lst[IN6_ADDR_HSIZE]; --- 38 unchanged lines hidden (view full) --- 178 .autoconf = 1, 179 .force_mld_version = 0, 180 .mldv1_unsolicited_report_interval = 10 * HZ, 181 .mldv2_unsolicited_report_interval = HZ, 182 .dad_transmits = 1, 183 .rtr_solicits = MAX_RTR_SOLICITATIONS, 184 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 185 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, | 126 127static int ipv6_generate_eui64(u8 *eui, struct net_device *dev); 128static int ipv6_count_addresses(struct inet6_dev *idev); 129 130/* 131 * Configured unicast address hash table 132 */ 133static struct hlist_head inet6_addr_lst[IN6_ADDR_HSIZE]; --- 38 unchanged lines hidden (view full) --- 172 .autoconf = 1, 173 .force_mld_version = 0, 174 .mldv1_unsolicited_report_interval = 10 * HZ, 175 .mldv2_unsolicited_report_interval = HZ, 176 .dad_transmits = 1, 177 .rtr_solicits = MAX_RTR_SOLICITATIONS, 178 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 179 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, |
186#ifdef CONFIG_IPV6_PRIVACY | |
187 .use_tempaddr = 0, 188 .temp_valid_lft = TEMP_VALID_LIFETIME, 189 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 190 .regen_max_retry = REGEN_MAX_RETRY, 191 .max_desync_factor = MAX_DESYNC_FACTOR, | 180 .use_tempaddr = 0, 181 .temp_valid_lft = TEMP_VALID_LIFETIME, 182 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 183 .regen_max_retry = REGEN_MAX_RETRY, 184 .max_desync_factor = MAX_DESYNC_FACTOR, |
192#endif | |
193 .max_addresses = IPV6_MAX_ADDRESSES, 194 .accept_ra_defrtr = 1, 195 .accept_ra_pinfo = 1, 196#ifdef CONFIG_IPV6_ROUTER_PREF 197 .accept_ra_rtr_pref = 1, 198 .rtr_probe_interval = 60 * HZ, 199#ifdef CONFIG_IPV6_ROUTE_INFO 200 .accept_ra_rt_info_max_plen = 0, --- 15 unchanged lines hidden (view full) --- 216 .autoconf = 1, 217 .force_mld_version = 0, 218 .mldv1_unsolicited_report_interval = 10 * HZ, 219 .mldv2_unsolicited_report_interval = HZ, 220 .dad_transmits = 1, 221 .rtr_solicits = MAX_RTR_SOLICITATIONS, 222 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 223 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, | 185 .max_addresses = IPV6_MAX_ADDRESSES, 186 .accept_ra_defrtr = 1, 187 .accept_ra_pinfo = 1, 188#ifdef CONFIG_IPV6_ROUTER_PREF 189 .accept_ra_rtr_pref = 1, 190 .rtr_probe_interval = 60 * HZ, 191#ifdef CONFIG_IPV6_ROUTE_INFO 192 .accept_ra_rt_info_max_plen = 0, --- 15 unchanged lines hidden (view full) --- 208 .autoconf = 1, 209 .force_mld_version = 0, 210 .mldv1_unsolicited_report_interval = 10 * HZ, 211 .mldv2_unsolicited_report_interval = HZ, 212 .dad_transmits = 1, 213 .rtr_solicits = MAX_RTR_SOLICITATIONS, 214 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 215 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, |
224#ifdef CONFIG_IPV6_PRIVACY | |
225 .use_tempaddr = 0, 226 .temp_valid_lft = TEMP_VALID_LIFETIME, 227 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 228 .regen_max_retry = REGEN_MAX_RETRY, 229 .max_desync_factor = MAX_DESYNC_FACTOR, | 216 .use_tempaddr = 0, 217 .temp_valid_lft = TEMP_VALID_LIFETIME, 218 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 219 .regen_max_retry = REGEN_MAX_RETRY, 220 .max_desync_factor = MAX_DESYNC_FACTOR, |
230#endif | |
231 .max_addresses = IPV6_MAX_ADDRESSES, 232 .accept_ra_defrtr = 1, 233 .accept_ra_pinfo = 1, 234#ifdef CONFIG_IPV6_ROUTER_PREF 235 .accept_ra_rtr_pref = 1, 236 .rtr_probe_interval = 60 * HZ, 237#ifdef CONFIG_IPV6_ROUTE_INFO 238 .accept_ra_rt_info_max_plen = 0, --- 127 unchanged lines hidden (view full) --- 366 367#if IS_ENABLED(CONFIG_IPV6_SIT) 368 if (dev->type == ARPHRD_SIT && (dev->priv_flags & IFF_ISATAP)) { 369 pr_info("%s: Disabled Multicast RS\n", dev->name); 370 ndev->cnf.rtr_solicits = 0; 371 } 372#endif 373 | 221 .max_addresses = IPV6_MAX_ADDRESSES, 222 .accept_ra_defrtr = 1, 223 .accept_ra_pinfo = 1, 224#ifdef CONFIG_IPV6_ROUTER_PREF 225 .accept_ra_rtr_pref = 1, 226 .rtr_probe_interval = 60 * HZ, 227#ifdef CONFIG_IPV6_ROUTE_INFO 228 .accept_ra_rt_info_max_plen = 0, --- 127 unchanged lines hidden (view full) --- 356 357#if IS_ENABLED(CONFIG_IPV6_SIT) 358 if (dev->type == ARPHRD_SIT && (dev->priv_flags & IFF_ISATAP)) { 359 pr_info("%s: Disabled Multicast RS\n", dev->name); 360 ndev->cnf.rtr_solicits = 0; 361 } 362#endif 363 |
374#ifdef CONFIG_IPV6_PRIVACY | |
375 INIT_LIST_HEAD(&ndev->tempaddr_list); 376 setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev); 377 if ((dev->flags&IFF_LOOPBACK) || 378 dev->type == ARPHRD_TUNNEL || 379 dev->type == ARPHRD_TUNNEL6 || 380 dev->type == ARPHRD_SIT || 381 dev->type == ARPHRD_NONE) { 382 ndev->cnf.use_tempaddr = -1; 383 } else { 384 in6_dev_hold(ndev); 385 ipv6_regen_rndid((unsigned long) ndev); 386 } | 364 INIT_LIST_HEAD(&ndev->tempaddr_list); 365 setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev); 366 if ((dev->flags&IFF_LOOPBACK) || 367 dev->type == ARPHRD_TUNNEL || 368 dev->type == ARPHRD_TUNNEL6 || 369 dev->type == ARPHRD_SIT || 370 dev->type == ARPHRD_NONE) { 371 ndev->cnf.use_tempaddr = -1; 372 } else { 373 in6_dev_hold(ndev); 374 ipv6_regen_rndid((unsigned long) ndev); 375 } |
387#endif | 376 |
388 ndev->token = in6addr_any; 389 390 if (netif_running(dev) && addrconf_qdisc_ok(dev)) 391 ndev->if_flags |= IF_READY; 392 393 ipv6_mc_init_dev(ndev); 394 ndev->tstamp = jiffies; 395 addrconf_sysctl_register(ndev); --- 464 unchanged lines hidden (view full) --- 860 861 hlist_add_head_rcu(&ifa->addr_lst, &inet6_addr_lst[hash]); 862 spin_unlock(&addrconf_hash_lock); 863 864 write_lock(&idev->lock); 865 /* Add to inet6_dev unicast addr list. */ 866 ipv6_link_dev_addr(idev, ifa); 867 | 377 ndev->token = in6addr_any; 378 379 if (netif_running(dev) && addrconf_qdisc_ok(dev)) 380 ndev->if_flags |= IF_READY; 381 382 ipv6_mc_init_dev(ndev); 383 ndev->tstamp = jiffies; 384 addrconf_sysctl_register(ndev); --- 464 unchanged lines hidden (view full) --- 849 850 hlist_add_head_rcu(&ifa->addr_lst, &inet6_addr_lst[hash]); 851 spin_unlock(&addrconf_hash_lock); 852 853 write_lock(&idev->lock); 854 /* Add to inet6_dev unicast addr list. */ 855 ipv6_link_dev_addr(idev, ifa); 856 |
868#ifdef CONFIG_IPV6_PRIVACY | |
869 if (ifa->flags&IFA_F_TEMPORARY) { 870 list_add(&ifa->tmp_list, &idev->tempaddr_list); 871 in6_ifa_hold(ifa); 872 } | 857 if (ifa->flags&IFA_F_TEMPORARY) { 858 list_add(&ifa->tmp_list, &idev->tempaddr_list); 859 in6_ifa_hold(ifa); 860 } |
873#endif | |
874 875 in6_ifa_hold(ifa); 876 write_unlock(&idev->lock); 877out2: 878 rcu_read_unlock_bh(); 879 880 if (likely(err == 0)) 881 inet6addr_notifier_call_chain(NETDEV_UP, ifa); --- 26 unchanged lines hidden (view full) --- 908 if (state == INET6_IFADDR_STATE_DEAD) 909 goto out; 910 911 spin_lock_bh(&addrconf_hash_lock); 912 hlist_del_init_rcu(&ifp->addr_lst); 913 spin_unlock_bh(&addrconf_hash_lock); 914 915 write_lock_bh(&idev->lock); | 861 862 in6_ifa_hold(ifa); 863 write_unlock(&idev->lock); 864out2: 865 rcu_read_unlock_bh(); 866 867 if (likely(err == 0)) 868 inet6addr_notifier_call_chain(NETDEV_UP, ifa); --- 26 unchanged lines hidden (view full) --- 895 if (state == INET6_IFADDR_STATE_DEAD) 896 goto out; 897 898 spin_lock_bh(&addrconf_hash_lock); 899 hlist_del_init_rcu(&ifp->addr_lst); 900 spin_unlock_bh(&addrconf_hash_lock); 901 902 write_lock_bh(&idev->lock); |
916#ifdef CONFIG_IPV6_PRIVACY | 903 |
917 if (ifp->flags&IFA_F_TEMPORARY) { 918 list_del(&ifp->tmp_list); 919 if (ifp->ifpub) { 920 in6_ifa_put(ifp->ifpub); 921 ifp->ifpub = NULL; 922 } 923 __in6_ifa_put(ifp); 924 } | 904 if (ifp->flags&IFA_F_TEMPORARY) { 905 list_del(&ifp->tmp_list); 906 if (ifp->ifpub) { 907 in6_ifa_put(ifp->ifpub); 908 ifp->ifpub = NULL; 909 } 910 __in6_ifa_put(ifp); 911 } |
925#endif | |
926 927 list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) { 928 if (ifa == ifp) { 929 list_del_init(&ifp->if_list); 930 __in6_ifa_put(ifp); 931 932 if (!(ifp->flags & IFA_F_PERMANENT) || onlink > 0) 933 break; --- 74 unchanged lines hidden (view full) --- 1008 } 1009 1010 /* clean up prefsrc entries */ 1011 rt6_remove_prefsrc(ifp); 1012out: 1013 in6_ifa_put(ifp); 1014} 1015 | 912 913 list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) { 914 if (ifa == ifp) { 915 list_del_init(&ifp->if_list); 916 __in6_ifa_put(ifp); 917 918 if (!(ifp->flags & IFA_F_PERMANENT) || onlink > 0) 919 break; --- 74 unchanged lines hidden (view full) --- 994 } 995 996 /* clean up prefsrc entries */ 997 rt6_remove_prefsrc(ifp); 998out: 999 in6_ifa_put(ifp); 1000} 1001 |
1016#ifdef CONFIG_IPV6_PRIVACY | |
1017static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift) 1018{ 1019 struct inet6_dev *idev = ifp->idev; 1020 struct in6_addr addr, *tmpaddr; 1021 unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age; 1022 unsigned long regen_advance; 1023 int tmp_plen; 1024 int ret = 0; --- 86 unchanged lines hidden (view full) --- 1111 spin_unlock_bh(&ift->lock); 1112 1113 addrconf_dad_start(ift); 1114 in6_ifa_put(ift); 1115 in6_dev_put(idev); 1116out: 1117 return ret; 1118} | 1002static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift) 1003{ 1004 struct inet6_dev *idev = ifp->idev; 1005 struct in6_addr addr, *tmpaddr; 1006 unsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age; 1007 unsigned long regen_advance; 1008 int tmp_plen; 1009 int ret = 0; --- 86 unchanged lines hidden (view full) --- 1096 spin_unlock_bh(&ift->lock); 1097 1098 addrconf_dad_start(ift); 1099 in6_ifa_put(ift); 1100 in6_dev_put(idev); 1101out: 1102 return ret; 1103} |
1119#endif | |
1120 1121/* 1122 * Choose an appropriate source address (RFC3484) 1123 */ 1124enum { 1125 IPV6_SADDR_RULE_INIT = 0, 1126 IPV6_SADDR_RULE_LOCAL, 1127 IPV6_SADDR_RULE_SCOPE, 1128 IPV6_SADDR_RULE_PREFERRED, 1129#ifdef CONFIG_IPV6_MIP6 1130 IPV6_SADDR_RULE_HOA, 1131#endif 1132 IPV6_SADDR_RULE_OIF, 1133 IPV6_SADDR_RULE_LABEL, | 1104 1105/* 1106 * Choose an appropriate source address (RFC3484) 1107 */ 1108enum { 1109 IPV6_SADDR_RULE_INIT = 0, 1110 IPV6_SADDR_RULE_LOCAL, 1111 IPV6_SADDR_RULE_SCOPE, 1112 IPV6_SADDR_RULE_PREFERRED, 1113#ifdef CONFIG_IPV6_MIP6 1114 IPV6_SADDR_RULE_HOA, 1115#endif 1116 IPV6_SADDR_RULE_OIF, 1117 IPV6_SADDR_RULE_LABEL, |
1134#ifdef CONFIG_IPV6_PRIVACY | |
1135 IPV6_SADDR_RULE_PRIVACY, | 1118 IPV6_SADDR_RULE_PRIVACY, |
1136#endif | |
1137 IPV6_SADDR_RULE_ORCHID, 1138 IPV6_SADDR_RULE_PREFIX, 1139 IPV6_SADDR_RULE_MAX 1140}; 1141 1142struct ipv6_saddr_score { 1143 int rule; 1144 int addr_type; --- 97 unchanged lines hidden (view full) --- 1242 dst->ifindex == score->ifa->idev->dev->ifindex); 1243 break; 1244 case IPV6_SADDR_RULE_LABEL: 1245 /* Rule 6: Prefer matching label */ 1246 ret = ipv6_addr_label(net, 1247 &score->ifa->addr, score->addr_type, 1248 score->ifa->idev->dev->ifindex) == dst->label; 1249 break; | 1119 IPV6_SADDR_RULE_ORCHID, 1120 IPV6_SADDR_RULE_PREFIX, 1121 IPV6_SADDR_RULE_MAX 1122}; 1123 1124struct ipv6_saddr_score { 1125 int rule; 1126 int addr_type; --- 97 unchanged lines hidden (view full) --- 1224 dst->ifindex == score->ifa->idev->dev->ifindex); 1225 break; 1226 case IPV6_SADDR_RULE_LABEL: 1227 /* Rule 6: Prefer matching label */ 1228 ret = ipv6_addr_label(net, 1229 &score->ifa->addr, score->addr_type, 1230 score->ifa->idev->dev->ifindex) == dst->label; 1231 break; |
1250#ifdef CONFIG_IPV6_PRIVACY | |
1251 case IPV6_SADDR_RULE_PRIVACY: 1252 { 1253 /* Rule 7: Prefer public address 1254 * Note: prefer temporary address if use_tempaddr >= 2 1255 */ 1256 int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ? 1257 !!(dst->prefs & IPV6_PREFER_SRC_TMP) : 1258 score->ifa->idev->cnf.use_tempaddr >= 2; 1259 ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp; 1260 break; 1261 } | 1232 case IPV6_SADDR_RULE_PRIVACY: 1233 { 1234 /* Rule 7: Prefer public address 1235 * Note: prefer temporary address if use_tempaddr >= 2 1236 */ 1237 int preftmp = dst->prefs & (IPV6_PREFER_SRC_PUBLIC|IPV6_PREFER_SRC_TMP) ? 1238 !!(dst->prefs & IPV6_PREFER_SRC_TMP) : 1239 score->ifa->idev->cnf.use_tempaddr >= 2; 1240 ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp; 1241 break; 1242 } |
1262#endif | |
1263 case IPV6_SADDR_RULE_ORCHID: 1264 /* Rule 8-: Prefer ORCHID vs ORCHID or 1265 * non-ORCHID vs non-ORCHID 1266 */ 1267 ret = !(ipv6_addr_orchid(&score->ifa->addr) ^ 1268 ipv6_addr_orchid(dst->addr)); 1269 break; 1270 case IPV6_SADDR_RULE_PREFIX: --- 312 unchanged lines hidden (view full) --- 1583 addrconf_del_dad_timer(ifp); 1584 ifp->flags |= IFA_F_TENTATIVE; 1585 if (dad_failed) 1586 ifp->flags |= IFA_F_DADFAILED; 1587 spin_unlock_bh(&ifp->lock); 1588 if (dad_failed) 1589 ipv6_ifa_notify(0, ifp); 1590 in6_ifa_put(ifp); | 1243 case IPV6_SADDR_RULE_ORCHID: 1244 /* Rule 8-: Prefer ORCHID vs ORCHID or 1245 * non-ORCHID vs non-ORCHID 1246 */ 1247 ret = !(ipv6_addr_orchid(&score->ifa->addr) ^ 1248 ipv6_addr_orchid(dst->addr)); 1249 break; 1250 case IPV6_SADDR_RULE_PREFIX: --- 312 unchanged lines hidden (view full) --- 1563 addrconf_del_dad_timer(ifp); 1564 ifp->flags |= IFA_F_TENTATIVE; 1565 if (dad_failed) 1566 ifp->flags |= IFA_F_DADFAILED; 1567 spin_unlock_bh(&ifp->lock); 1568 if (dad_failed) 1569 ipv6_ifa_notify(0, ifp); 1570 in6_ifa_put(ifp); |
1591#ifdef CONFIG_IPV6_PRIVACY | |
1592 } else if (ifp->flags&IFA_F_TEMPORARY) { 1593 struct inet6_ifaddr *ifpub; 1594 spin_lock_bh(&ifp->lock); 1595 ifpub = ifp->ifpub; 1596 if (ifpub) { 1597 in6_ifa_hold(ifpub); 1598 spin_unlock_bh(&ifp->lock); 1599 ipv6_create_tempaddr(ifpub, ifp); 1600 in6_ifa_put(ifpub); 1601 } else { 1602 spin_unlock_bh(&ifp->lock); 1603 } 1604 ipv6_del_addr(ifp); | 1571 } else if (ifp->flags&IFA_F_TEMPORARY) { 1572 struct inet6_ifaddr *ifpub; 1573 spin_lock_bh(&ifp->lock); 1574 ifpub = ifp->ifpub; 1575 if (ifpub) { 1576 in6_ifa_hold(ifpub); 1577 spin_unlock_bh(&ifp->lock); 1578 ipv6_create_tempaddr(ifpub, ifp); 1579 in6_ifa_put(ifpub); 1580 } else { 1581 spin_unlock_bh(&ifp->lock); 1582 } 1583 ipv6_del_addr(ifp); |
1605#endif | |
1606 } else 1607 ipv6_del_addr(ifp); 1608} 1609 1610static int addrconf_dad_end(struct inet6_ifaddr *ifp) 1611{ 1612 int err = -ENOENT; 1613 --- 232 unchanged lines hidden (view full) --- 1846 err = 0; 1847 break; 1848 } 1849 } 1850 read_unlock_bh(&idev->lock); 1851 return err; 1852} 1853 | 1584 } else 1585 ipv6_del_addr(ifp); 1586} 1587 1588static int addrconf_dad_end(struct inet6_ifaddr *ifp) 1589{ 1590 int err = -ENOENT; 1591 --- 232 unchanged lines hidden (view full) --- 1824 err = 0; 1825 break; 1826 } 1827 } 1828 read_unlock_bh(&idev->lock); 1829 return err; 1830} 1831 |
1854#ifdef CONFIG_IPV6_PRIVACY | |
1855/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */ 1856static void __ipv6_regen_rndid(struct inet6_dev *idev) 1857{ 1858regen: 1859 get_random_bytes(idev->rndid, sizeof(idev->rndid)); 1860 idev->rndid[0] &= ~0x02; 1861 1862 /* --- 51 unchanged lines hidden (view full) --- 1914 in6_dev_put(idev); 1915} 1916 1917static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr) 1918{ 1919 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0) 1920 __ipv6_regen_rndid(idev); 1921} | 1832/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */ 1833static void __ipv6_regen_rndid(struct inet6_dev *idev) 1834{ 1835regen: 1836 get_random_bytes(idev->rndid, sizeof(idev->rndid)); 1837 idev->rndid[0] &= ~0x02; 1838 1839 /* --- 51 unchanged lines hidden (view full) --- 1891 in6_dev_put(idev); 1892} 1893 1894static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr) 1895{ 1896 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0) 1897 __ipv6_regen_rndid(idev); 1898} |
1922#endif | |
1923 1924/* 1925 * Add prefix route. 1926 */ 1927 1928static void 1929addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, 1930 unsigned long expires, u32 flags) --- 271 unchanged lines hidden (view full) --- 2202 ifp->cstamp = jiffies; 2203 ifp->tokenized = tokenized; 2204 addrconf_dad_start(ifp); 2205 } 2206 2207 if (ifp) { 2208 int flags; 2209 unsigned long now; | 1899 1900/* 1901 * Add prefix route. 1902 */ 1903 1904static void 1905addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, 1906 unsigned long expires, u32 flags) --- 271 unchanged lines hidden (view full) --- 2178 ifp->cstamp = jiffies; 2179 ifp->tokenized = tokenized; 2180 addrconf_dad_start(ifp); 2181 } 2182 2183 if (ifp) { 2184 int flags; 2185 unsigned long now; |
2210#ifdef CONFIG_IPV6_PRIVACY | |
2211 struct inet6_ifaddr *ift; | 2186 struct inet6_ifaddr *ift; |
2212#endif | |
2213 u32 stored_lft; 2214 2215 /* update lifetime (RFC2462 5.5.3 e) */ 2216 spin_lock(&ifp->lock); 2217 now = jiffies; 2218 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) 2219 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; 2220 else --- 24 unchanged lines hidden (view full) --- 2245 ifp->flags &= ~IFA_F_DEPRECATED; 2246 spin_unlock(&ifp->lock); 2247 2248 if (!(flags&IFA_F_TENTATIVE)) 2249 ipv6_ifa_notify(0, ifp); 2250 } else 2251 spin_unlock(&ifp->lock); 2252 | 2187 u32 stored_lft; 2188 2189 /* update lifetime (RFC2462 5.5.3 e) */ 2190 spin_lock(&ifp->lock); 2191 now = jiffies; 2192 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) 2193 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; 2194 else --- 24 unchanged lines hidden (view full) --- 2219 ifp->flags &= ~IFA_F_DEPRECATED; 2220 spin_unlock(&ifp->lock); 2221 2222 if (!(flags&IFA_F_TENTATIVE)) 2223 ipv6_ifa_notify(0, ifp); 2224 } else 2225 spin_unlock(&ifp->lock); 2226 |
2253#ifdef CONFIG_IPV6_PRIVACY | |
2254 read_lock_bh(&in6_dev->lock); 2255 /* update all temporary addresses in the list */ 2256 list_for_each_entry(ift, &in6_dev->tempaddr_list, 2257 tmp_list) { 2258 int age, max_valid, max_prefered; 2259 2260 if (ifp != ift->ifpub) 2261 continue; --- 48 unchanged lines hidden (view full) --- 2310 * address if it's enabled but no temporary 2311 * address currently exists. 2312 */ 2313 read_unlock_bh(&in6_dev->lock); 2314 ipv6_create_tempaddr(ifp, NULL); 2315 } else { 2316 read_unlock_bh(&in6_dev->lock); 2317 } | 2227 read_lock_bh(&in6_dev->lock); 2228 /* update all temporary addresses in the list */ 2229 list_for_each_entry(ift, &in6_dev->tempaddr_list, 2230 tmp_list) { 2231 int age, max_valid, max_prefered; 2232 2233 if (ifp != ift->ifpub) 2234 continue; --- 48 unchanged lines hidden (view full) --- 2283 * address if it's enabled but no temporary 2284 * address currently exists. 2285 */ 2286 read_unlock_bh(&in6_dev->lock); 2287 ipv6_create_tempaddr(ifp, NULL); 2288 } else { 2289 read_unlock_bh(&in6_dev->lock); 2290 } |
2318#endif | 2291 |
2319 in6_ifa_put(ifp); 2320 addrconf_verify(0); 2321 } 2322 } 2323 inet6_prefix_notify(RTM_NEWPREFIX, in6_dev, pinfo); 2324 in6_dev_put(in6_dev); 2325} 2326 --- 663 unchanged lines hidden (view full) --- 2990 write_lock_bh(&idev->lock); 2991 2992 addrconf_del_rs_timer(idev); 2993 2994 /* Step 2: clear flags for stateless addrconf */ 2995 if (!how) 2996 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY); 2997 | 2292 in6_ifa_put(ifp); 2293 addrconf_verify(0); 2294 } 2295 } 2296 inet6_prefix_notify(RTM_NEWPREFIX, in6_dev, pinfo); 2297 in6_dev_put(in6_dev); 2298} 2299 --- 663 unchanged lines hidden (view full) --- 2963 write_lock_bh(&idev->lock); 2964 2965 addrconf_del_rs_timer(idev); 2966 2967 /* Step 2: clear flags for stateless addrconf */ 2968 if (!how) 2969 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY); 2970 |
2998#ifdef CONFIG_IPV6_PRIVACY | |
2999 if (how && del_timer(&idev->regen_timer)) 3000 in6_dev_put(idev); 3001 3002 /* Step 3: clear tempaddr list */ 3003 while (!list_empty(&idev->tempaddr_list)) { 3004 ifa = list_first_entry(&idev->tempaddr_list, 3005 struct inet6_ifaddr, tmp_list); 3006 list_del(&ifa->tmp_list); 3007 write_unlock_bh(&idev->lock); 3008 spin_lock_bh(&ifa->lock); 3009 3010 if (ifa->ifpub) { 3011 in6_ifa_put(ifa->ifpub); 3012 ifa->ifpub = NULL; 3013 } 3014 spin_unlock_bh(&ifa->lock); 3015 in6_ifa_put(ifa); 3016 write_lock_bh(&idev->lock); 3017 } | 2971 if (how && del_timer(&idev->regen_timer)) 2972 in6_dev_put(idev); 2973 2974 /* Step 3: clear tempaddr list */ 2975 while (!list_empty(&idev->tempaddr_list)) { 2976 ifa = list_first_entry(&idev->tempaddr_list, 2977 struct inet6_ifaddr, tmp_list); 2978 list_del(&ifa->tmp_list); 2979 write_unlock_bh(&idev->lock); 2980 spin_lock_bh(&ifa->lock); 2981 2982 if (ifa->ifpub) { 2983 in6_ifa_put(ifa->ifpub); 2984 ifa->ifpub = NULL; 2985 } 2986 spin_unlock_bh(&ifa->lock); 2987 in6_ifa_put(ifa); 2988 write_lock_bh(&idev->lock); 2989 } |
3018#endif | |
3019 3020 while (!list_empty(&idev->addr_list)) { 3021 ifa = list_first_entry(&idev->addr_list, 3022 struct inet6_ifaddr, if_list); 3023 addrconf_del_dad_timer(ifa); 3024 3025 list_del(&ifa->if_list); 3026 --- 496 unchanged lines hidden (view full) --- 3523 3524 if (deprecate) { 3525 in6_ifa_hold(ifp); 3526 3527 ipv6_ifa_notify(0, ifp); 3528 in6_ifa_put(ifp); 3529 goto restart; 3530 } | 2990 2991 while (!list_empty(&idev->addr_list)) { 2992 ifa = list_first_entry(&idev->addr_list, 2993 struct inet6_ifaddr, if_list); 2994 addrconf_del_dad_timer(ifa); 2995 2996 list_del(&ifa->if_list); 2997 --- 496 unchanged lines hidden (view full) --- 3494 3495 if (deprecate) { 3496 in6_ifa_hold(ifp); 3497 3498 ipv6_ifa_notify(0, ifp); 3499 in6_ifa_put(ifp); 3500 goto restart; 3501 } |
3531#ifdef CONFIG_IPV6_PRIVACY | |
3532 } else if ((ifp->flags&IFA_F_TEMPORARY) && 3533 !(ifp->flags&IFA_F_TENTATIVE)) { 3534 unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * 3535 ifp->idev->cnf.dad_transmits * 3536 ifp->idev->nd_parms->retrans_time / HZ; 3537 3538 if (age >= ifp->prefered_lft - regen_advance) { 3539 struct inet6_ifaddr *ifpub = ifp->ifpub; --- 11 unchanged lines hidden (view full) --- 3551 ipv6_create_tempaddr(ifpub, ifp); 3552 in6_ifa_put(ifpub); 3553 in6_ifa_put(ifp); 3554 goto restart; 3555 } 3556 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) 3557 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ; 3558 spin_unlock(&ifp->lock); | 3502 } else if ((ifp->flags&IFA_F_TEMPORARY) && 3503 !(ifp->flags&IFA_F_TENTATIVE)) { 3504 unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * 3505 ifp->idev->cnf.dad_transmits * 3506 ifp->idev->nd_parms->retrans_time / HZ; 3507 3508 if (age >= ifp->prefered_lft - regen_advance) { 3509 struct inet6_ifaddr *ifpub = ifp->ifpub; --- 11 unchanged lines hidden (view full) --- 3521 ipv6_create_tempaddr(ifpub, ifp); 3522 in6_ifa_put(ifpub); 3523 in6_ifa_put(ifp); 3524 goto restart; 3525 } 3526 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) 3527 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ; 3528 spin_unlock(&ifp->lock); |
3559#endif | |
3560 } else { 3561 /* ifp->prefered_lft <= ifp->valid_lft */ 3562 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) 3563 next = ifp->tstamp + ifp->prefered_lft * HZ; 3564 spin_unlock(&ifp->lock); 3565 } 3566 } 3567 } --- 555 unchanged lines hidden (view full) --- 4123 jiffies_to_msecs(cnf->rtr_solicit_interval); 4124 array[DEVCONF_RTR_SOLICIT_DELAY] = 4125 jiffies_to_msecs(cnf->rtr_solicit_delay); 4126 array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version; 4127 array[DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL] = 4128 jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval); 4129 array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] = 4130 jiffies_to_msecs(cnf->mldv2_unsolicited_report_interval); | 3529 } else { 3530 /* ifp->prefered_lft <= ifp->valid_lft */ 3531 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) 3532 next = ifp->tstamp + ifp->prefered_lft * HZ; 3533 spin_unlock(&ifp->lock); 3534 } 3535 } 3536 } --- 555 unchanged lines hidden (view full) --- 4092 jiffies_to_msecs(cnf->rtr_solicit_interval); 4093 array[DEVCONF_RTR_SOLICIT_DELAY] = 4094 jiffies_to_msecs(cnf->rtr_solicit_delay); 4095 array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version; 4096 array[DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL] = 4097 jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval); 4098 array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] = 4099 jiffies_to_msecs(cnf->mldv2_unsolicited_report_interval); |
4131#ifdef CONFIG_IPV6_PRIVACY | |
4132 array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr; 4133 array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft; 4134 array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft; 4135 array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry; 4136 array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; | 4100 array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr; 4101 array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft; 4102 array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft; 4103 array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry; 4104 array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; |
4137#endif | |
4138 array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; 4139 array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; 4140 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; 4141#ifdef CONFIG_IPV6_ROUTER_PREF 4142 array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; 4143 array[DEVCONF_RTR_PROBE_INTERVAL] = 4144 jiffies_to_msecs(cnf->rtr_probe_interval); 4145#ifdef CONFIG_IPV6_ROUTE_INFO --- 677 unchanged lines hidden (view full) --- 4823 { 4824 .procname = "mldv2_unsolicited_report_interval", 4825 .data = 4826 &ipv6_devconf.mldv2_unsolicited_report_interval, 4827 .maxlen = sizeof(int), 4828 .mode = 0644, 4829 .proc_handler = proc_dointvec_ms_jiffies, 4830 }, | 4105 array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; 4106 array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; 4107 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; 4108#ifdef CONFIG_IPV6_ROUTER_PREF 4109 array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; 4110 array[DEVCONF_RTR_PROBE_INTERVAL] = 4111 jiffies_to_msecs(cnf->rtr_probe_interval); 4112#ifdef CONFIG_IPV6_ROUTE_INFO --- 677 unchanged lines hidden (view full) --- 4790 { 4791 .procname = "mldv2_unsolicited_report_interval", 4792 .data = 4793 &ipv6_devconf.mldv2_unsolicited_report_interval, 4794 .maxlen = sizeof(int), 4795 .mode = 0644, 4796 .proc_handler = proc_dointvec_ms_jiffies, 4797 }, |
4831#ifdef CONFIG_IPV6_PRIVACY | |
4832 { 4833 .procname = "use_tempaddr", 4834 .data = &ipv6_devconf.use_tempaddr, 4835 .maxlen = sizeof(int), 4836 .mode = 0644, 4837 .proc_handler = proc_dointvec, 4838 }, 4839 { --- 19 unchanged lines hidden (view full) --- 4859 }, 4860 { 4861 .procname = "max_desync_factor", 4862 .data = &ipv6_devconf.max_desync_factor, 4863 .maxlen = sizeof(int), 4864 .mode = 0644, 4865 .proc_handler = proc_dointvec, 4866 }, | 4798 { 4799 .procname = "use_tempaddr", 4800 .data = &ipv6_devconf.use_tempaddr, 4801 .maxlen = sizeof(int), 4802 .mode = 0644, 4803 .proc_handler = proc_dointvec, 4804 }, 4805 { --- 19 unchanged lines hidden (view full) --- 4825 }, 4826 { 4827 .procname = "max_desync_factor", 4828 .data = &ipv6_devconf.max_desync_factor, 4829 .maxlen = sizeof(int), 4830 .mode = 0644, 4831 .proc_handler = proc_dointvec, 4832 }, |
4867#endif | |
4868 { 4869 .procname = "max_addresses", 4870 .data = &ipv6_devconf.max_addresses, 4871 .maxlen = sizeof(int), 4872 .mode = 0644, 4873 .proc_handler = proc_dointvec, 4874 }, 4875 { --- 360 unchanged lines hidden --- | 4833 { 4834 .procname = "max_addresses", 4835 .data = &ipv6_devconf.max_addresses, 4836 .maxlen = sizeof(int), 4837 .mode = 0644, 4838 .proc_handler = proc_dointvec, 4839 }, 4840 { --- 360 unchanged lines hidden --- |