aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-10-28 20:07:50 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-28 20:07:50 -0400
commit5d9efa7ee99eed58388f186c13cf2e2a87e9ceb4 (patch)
tree789ab10091718b238342a7d2bf53524790869395 /net/ipv6/addrconf.c
parentd5d45d429402c2d3de056a412d6e9bb41e58deb6 (diff)
ipv6: Remove privacy config option.
The code for privacy extentions is very mature, and making it configurable only gives marginal memory/code savings in exchange for obfuscation and hard to read code via CPP ifdef'ery. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cd3fb301da38..542d09561ed6 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -83,11 +83,7 @@
83#include <linux/if_tunnel.h> 83#include <linux/if_tunnel.h>
84#include <linux/rtnetlink.h> 84#include <linux/rtnetlink.h>
85#include <linux/netconf.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> 87#include <linux/uaccess.h>
92#include <asm/unaligned.h> 88#include <asm/unaligned.h>
93 89
@@ -124,11 +120,9 @@ static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)
124} 120}
125#endif 121#endif
126 122
127#ifdef CONFIG_IPV6_PRIVACY
128static void __ipv6_regen_rndid(struct inet6_dev *idev); 123static void __ipv6_regen_rndid(struct inet6_dev *idev);
129static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); 124static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
130static void ipv6_regen_rndid(unsigned long data); 125static void ipv6_regen_rndid(unsigned long data);
131#endif
132 126
133static int ipv6_generate_eui64(u8 *eui, struct net_device *dev); 127static int ipv6_generate_eui64(u8 *eui, struct net_device *dev);
134static int ipv6_count_addresses(struct inet6_dev *idev); 128static int ipv6_count_addresses(struct inet6_dev *idev);
@@ -183,13 +177,11 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
183 .rtr_solicits = MAX_RTR_SOLICITATIONS, 177 .rtr_solicits = MAX_RTR_SOLICITATIONS,
184 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 178 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
185 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, 179 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
186#ifdef CONFIG_IPV6_PRIVACY
187 .use_tempaddr = 0, 180 .use_tempaddr = 0,
188 .temp_valid_lft = TEMP_VALID_LIFETIME, 181 .temp_valid_lft = TEMP_VALID_LIFETIME,
189 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 182 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
190 .regen_max_retry = REGEN_MAX_RETRY, 183 .regen_max_retry = REGEN_MAX_RETRY,
191 .max_desync_factor = MAX_DESYNC_FACTOR, 184 .max_desync_factor = MAX_DESYNC_FACTOR,
192#endif
193 .max_addresses = IPV6_MAX_ADDRESSES, 185 .max_addresses = IPV6_MAX_ADDRESSES,
194 .accept_ra_defrtr = 1, 186 .accept_ra_defrtr = 1,
195 .accept_ra_pinfo = 1, 187 .accept_ra_pinfo = 1,
@@ -221,13 +213,11 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
221 .rtr_solicits = MAX_RTR_SOLICITATIONS, 213 .rtr_solicits = MAX_RTR_SOLICITATIONS,
222 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL, 214 .rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
223 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY, 215 .rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
224#ifdef CONFIG_IPV6_PRIVACY
225 .use_tempaddr = 0, 216 .use_tempaddr = 0,
226 .temp_valid_lft = TEMP_VALID_LIFETIME, 217 .temp_valid_lft = TEMP_VALID_LIFETIME,
227 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME, 218 .temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
228 .regen_max_retry = REGEN_MAX_RETRY, 219 .regen_max_retry = REGEN_MAX_RETRY,
229 .max_desync_factor = MAX_DESYNC_FACTOR, 220 .max_desync_factor = MAX_DESYNC_FACTOR,
230#endif
231 .max_addresses = IPV6_MAX_ADDRESSES, 221 .max_addresses = IPV6_MAX_ADDRESSES,
232 .accept_ra_defrtr = 1, 222 .accept_ra_defrtr = 1,
233 .accept_ra_pinfo = 1, 223 .accept_ra_pinfo = 1,
@@ -371,7 +361,6 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
371 } 361 }
372#endif 362#endif
373 363
374#ifdef CONFIG_IPV6_PRIVACY
375 INIT_LIST_HEAD(&ndev->tempaddr_list); 364 INIT_LIST_HEAD(&ndev->tempaddr_list);
376 setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev); 365 setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
377 if ((dev->flags&IFF_LOOPBACK) || 366 if ((dev->flags&IFF_LOOPBACK) ||
@@ -384,7 +373,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
384 in6_dev_hold(ndev); 373 in6_dev_hold(ndev);
385 ipv6_regen_rndid((unsigned long) ndev); 374 ipv6_regen_rndid((unsigned long) ndev);
386 } 375 }
387#endif 376
388 ndev->token = in6addr_any; 377 ndev->token = in6addr_any;
389 378
390 if (netif_running(dev) && addrconf_qdisc_ok(dev)) 379 if (netif_running(dev) && addrconf_qdisc_ok(dev))
@@ -865,12 +854,10 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
865 /* Add to inet6_dev unicast addr list. */ 854 /* Add to inet6_dev unicast addr list. */
866 ipv6_link_dev_addr(idev, ifa); 855 ipv6_link_dev_addr(idev, ifa);
867 856
868#ifdef CONFIG_IPV6_PRIVACY
869 if (ifa->flags&IFA_F_TEMPORARY) { 857 if (ifa->flags&IFA_F_TEMPORARY) {
870 list_add(&ifa->tmp_list, &idev->tempaddr_list); 858 list_add(&ifa->tmp_list, &idev->tempaddr_list);
871 in6_ifa_hold(ifa); 859 in6_ifa_hold(ifa);
872 } 860 }
873#endif
874 861
875 in6_ifa_hold(ifa); 862 in6_ifa_hold(ifa);
876 write_unlock(&idev->lock); 863 write_unlock(&idev->lock);
@@ -913,7 +900,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
913 spin_unlock_bh(&addrconf_hash_lock); 900 spin_unlock_bh(&addrconf_hash_lock);
914 901
915 write_lock_bh(&idev->lock); 902 write_lock_bh(&idev->lock);
916#ifdef CONFIG_IPV6_PRIVACY 903
917 if (ifp->flags&IFA_F_TEMPORARY) { 904 if (ifp->flags&IFA_F_TEMPORARY) {
918 list_del(&ifp->tmp_list); 905 list_del(&ifp->tmp_list);
919 if (ifp->ifpub) { 906 if (ifp->ifpub) {
@@ -922,7 +909,6 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
922 } 909 }
923 __in6_ifa_put(ifp); 910 __in6_ifa_put(ifp);
924 } 911 }
925#endif
926 912
927 list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) { 913 list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) {
928 if (ifa == ifp) { 914 if (ifa == ifp) {
@@ -1013,7 +999,6 @@ out:
1013 in6_ifa_put(ifp); 999 in6_ifa_put(ifp);
1014} 1000}
1015 1001
1016#ifdef CONFIG_IPV6_PRIVACY
1017static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift) 1002static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)
1018{ 1003{
1019 struct inet6_dev *idev = ifp->idev; 1004 struct inet6_dev *idev = ifp->idev;
@@ -1116,7 +1101,6 @@ retry:
1116out: 1101out:
1117 return ret; 1102 return ret;
1118} 1103}
1119#endif
1120 1104
1121/* 1105/*
1122 * Choose an appropriate source address (RFC3484) 1106 * Choose an appropriate source address (RFC3484)
@@ -1131,9 +1115,7 @@ enum {
1131#endif 1115#endif
1132 IPV6_SADDR_RULE_OIF, 1116 IPV6_SADDR_RULE_OIF,
1133 IPV6_SADDR_RULE_LABEL, 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, 1119 IPV6_SADDR_RULE_ORCHID,
1138 IPV6_SADDR_RULE_PREFIX, 1120 IPV6_SADDR_RULE_PREFIX,
1139 IPV6_SADDR_RULE_MAX 1121 IPV6_SADDR_RULE_MAX
@@ -1247,7 +1229,6 @@ static int ipv6_get_saddr_eval(struct net *net,
1247 &score->ifa->addr, score->addr_type, 1229 &score->ifa->addr, score->addr_type,
1248 score->ifa->idev->dev->ifindex) == dst->label; 1230 score->ifa->idev->dev->ifindex) == dst->label;
1249 break; 1231 break;
1250#ifdef CONFIG_IPV6_PRIVACY
1251 case IPV6_SADDR_RULE_PRIVACY: 1232 case IPV6_SADDR_RULE_PRIVACY:
1252 { 1233 {
1253 /* Rule 7: Prefer public address 1234 /* Rule 7: Prefer public address
@@ -1259,7 +1240,6 @@ static int ipv6_get_saddr_eval(struct net *net,
1259 ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp; 1240 ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp;
1260 break; 1241 break;
1261 } 1242 }
1262#endif
1263 case IPV6_SADDR_RULE_ORCHID: 1243 case IPV6_SADDR_RULE_ORCHID:
1264 /* Rule 8-: Prefer ORCHID vs ORCHID or 1244 /* Rule 8-: Prefer ORCHID vs ORCHID or
1265 * non-ORCHID vs non-ORCHID 1245 * non-ORCHID vs non-ORCHID
@@ -1588,7 +1568,6 @@ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
1588 if (dad_failed) 1568 if (dad_failed)
1589 ipv6_ifa_notify(0, ifp); 1569 ipv6_ifa_notify(0, ifp);
1590 in6_ifa_put(ifp); 1570 in6_ifa_put(ifp);
1591#ifdef CONFIG_IPV6_PRIVACY
1592 } else if (ifp->flags&IFA_F_TEMPORARY) { 1571 } else if (ifp->flags&IFA_F_TEMPORARY) {
1593 struct inet6_ifaddr *ifpub; 1572 struct inet6_ifaddr *ifpub;
1594 spin_lock_bh(&ifp->lock); 1573 spin_lock_bh(&ifp->lock);
@@ -1602,7 +1581,6 @@ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
1602 spin_unlock_bh(&ifp->lock); 1581 spin_unlock_bh(&ifp->lock);
1603 } 1582 }
1604 ipv6_del_addr(ifp); 1583 ipv6_del_addr(ifp);
1605#endif
1606 } else 1584 } else
1607 ipv6_del_addr(ifp); 1585 ipv6_del_addr(ifp);
1608} 1586}
@@ -1851,7 +1829,6 @@ static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)
1851 return err; 1829 return err;
1852} 1830}
1853 1831
1854#ifdef CONFIG_IPV6_PRIVACY
1855/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */ 1832/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */
1856static void __ipv6_regen_rndid(struct inet6_dev *idev) 1833static void __ipv6_regen_rndid(struct inet6_dev *idev)
1857{ 1834{
@@ -1919,7 +1896,6 @@ static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmp
1919 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0) 1896 if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0)
1920 __ipv6_regen_rndid(idev); 1897 __ipv6_regen_rndid(idev);
1921} 1898}
1922#endif
1923 1899
1924/* 1900/*
1925 * Add prefix route. 1901 * Add prefix route.
@@ -2207,9 +2183,7 @@ ok:
2207 if (ifp) { 2183 if (ifp) {
2208 int flags; 2184 int flags;
2209 unsigned long now; 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; 2187 u32 stored_lft;
2214 2188
2215 /* update lifetime (RFC2462 5.5.3 e) */ 2189 /* update lifetime (RFC2462 5.5.3 e) */
@@ -2250,7 +2224,6 @@ ok:
2250 } else 2224 } else
2251 spin_unlock(&ifp->lock); 2225 spin_unlock(&ifp->lock);
2252 2226
2253#ifdef CONFIG_IPV6_PRIVACY
2254 read_lock_bh(&in6_dev->lock); 2227 read_lock_bh(&in6_dev->lock);
2255 /* update all temporary addresses in the list */ 2228 /* update all temporary addresses in the list */
2256 list_for_each_entry(ift, &in6_dev->tempaddr_list, 2229 list_for_each_entry(ift, &in6_dev->tempaddr_list,
@@ -2315,7 +2288,7 @@ ok:
2315 } else { 2288 } else {
2316 read_unlock_bh(&in6_dev->lock); 2289 read_unlock_bh(&in6_dev->lock);
2317 } 2290 }
2318#endif 2291
2319 in6_ifa_put(ifp); 2292 in6_ifa_put(ifp);
2320 addrconf_verify(0); 2293 addrconf_verify(0);
2321 } 2294 }
@@ -2995,7 +2968,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2995 if (!how) 2968 if (!how)
2996 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY); 2969 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY);
2997 2970
2998#ifdef CONFIG_IPV6_PRIVACY
2999 if (how && del_timer(&idev->regen_timer)) 2971 if (how && del_timer(&idev->regen_timer))
3000 in6_dev_put(idev); 2972 in6_dev_put(idev);
3001 2973
@@ -3015,7 +2987,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
3015 in6_ifa_put(ifa); 2987 in6_ifa_put(ifa);
3016 write_lock_bh(&idev->lock); 2988 write_lock_bh(&idev->lock);
3017 } 2989 }
3018#endif
3019 2990
3020 while (!list_empty(&idev->addr_list)) { 2991 while (!list_empty(&idev->addr_list)) {
3021 ifa = list_first_entry(&idev->addr_list, 2992 ifa = list_first_entry(&idev->addr_list,
@@ -3528,7 +3499,6 @@ restart:
3528 in6_ifa_put(ifp); 3499 in6_ifa_put(ifp);
3529 goto restart; 3500 goto restart;
3530 } 3501 }
3531#ifdef CONFIG_IPV6_PRIVACY
3532 } else if ((ifp->flags&IFA_F_TEMPORARY) && 3502 } else if ((ifp->flags&IFA_F_TEMPORARY) &&
3533 !(ifp->flags&IFA_F_TENTATIVE)) { 3503 !(ifp->flags&IFA_F_TENTATIVE)) {
3534 unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * 3504 unsigned long regen_advance = ifp->idev->cnf.regen_max_retry *
@@ -3556,7 +3526,6 @@ restart:
3556 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) 3526 } 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; 3527 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ;
3558 spin_unlock(&ifp->lock); 3528 spin_unlock(&ifp->lock);
3559#endif
3560 } else { 3529 } else {
3561 /* ifp->prefered_lft <= ifp->valid_lft */ 3530 /* ifp->prefered_lft <= ifp->valid_lft */
3562 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) 3531 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next))
@@ -4128,13 +4097,11 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
4128 jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval); 4097 jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval);
4129 array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] = 4098 array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] =
4130 jiffies_to_msecs(cnf->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; 4100 array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
4133 array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft; 4101 array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
4134 array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft; 4102 array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
4135 array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry; 4103 array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
4136 array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; 4104 array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
4137#endif
4138 array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; 4105 array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
4139 array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; 4106 array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
4140 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; 4107 array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
@@ -4828,7 +4795,6 @@ static struct addrconf_sysctl_table
4828 .mode = 0644, 4795 .mode = 0644,
4829 .proc_handler = proc_dointvec_ms_jiffies, 4796 .proc_handler = proc_dointvec_ms_jiffies,
4830 }, 4797 },
4831#ifdef CONFIG_IPV6_PRIVACY
4832 { 4798 {
4833 .procname = "use_tempaddr", 4799 .procname = "use_tempaddr",
4834 .data = &ipv6_devconf.use_tempaddr, 4800 .data = &ipv6_devconf.use_tempaddr,
@@ -4864,7 +4830,6 @@ static struct addrconf_sysctl_table
4864 .mode = 0644, 4830 .mode = 0644,
4865 .proc_handler = proc_dointvec, 4831 .proc_handler = proc_dointvec,
4866 }, 4832 },
4867#endif
4868 { 4833 {
4869 .procname = "max_addresses", 4834 .procname = "max_addresses",
4870 .data = &ipv6_devconf.max_addresses, 4835 .data = &ipv6_devconf.max_addresses,