Skip to content

Commit 5d9efa7

Browse files
committed
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 <[email protected]>
1 parent d5d45d4 commit 5d9efa7

File tree

4 files changed

+4
-62
lines changed

4 files changed

+4
-62
lines changed

include/linux/ipv6.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ struct ipv6_devconf {
2121
__s32 force_mld_version;
2222
__s32 mldv1_unsolicited_report_interval;
2323
__s32 mldv2_unsolicited_report_interval;
24-
#ifdef CONFIG_IPV6_PRIVACY
2524
__s32 use_tempaddr;
2625
__s32 temp_valid_lft;
2726
__s32 temp_prefered_lft;
2827
__s32 regen_max_retry;
2928
__s32 max_desync_factor;
30-
#endif
3129
__s32 max_addresses;
3230
__s32 accept_ra_defrtr;
3331
__s32 accept_ra_pinfo;

include/net/if_inet6.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ struct inet6_ifaddr {
6666
struct hlist_node addr_lst;
6767
struct list_head if_list;
6868

69-
#ifdef CONFIG_IPV6_PRIVACY
7069
struct list_head tmp_list;
7170
struct inet6_ifaddr *ifpub;
7271
int regen_count;
73-
#endif
72+
7473
bool tokenized;
7574

7675
struct rcu_head rcu;
@@ -192,11 +191,9 @@ struct inet6_dev {
192191
__u32 if_flags;
193192
int dead;
194193

195-
#ifdef CONFIG_IPV6_PRIVACY
196194
u8 rndid[8];
197195
struct timer_list regen_timer;
198196
struct list_head tempaddr_list;
199-
#endif
200197

201198
struct in6_addr token;
202199

net/ipv6/Kconfig

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,6 @@ menuconfig IPV6
2121

2222
if IPV6
2323

24-
config IPV6_PRIVACY
25-
bool "IPv6: Privacy Extensions (RFC 3041) support"
26-
---help---
27-
Privacy Extensions for Stateless Address Autoconfiguration in IPv6
28-
support. With this option, additional periodically-altered
29-
pseudo-random global-scope unicast address(es) will be assigned to
30-
your interface(s).
31-
32-
We use our standard pseudo-random algorithm to generate the
33-
randomized interface identifier, instead of one described in RFC 3041.
34-
35-
By default the kernel does not generate temporary addresses.
36-
To use temporary addresses, do
37-
38-
echo 2 >/proc/sys/net/ipv6/conf/all/use_tempaddr
39-
40-
See <file:Documentation/networking/ip-sysctl.txt> for details.
41-
4224
config IPV6_ROUTER_PREF
4325
bool "IPv6: Router Preference (RFC 4191) support"
4426
---help---

net/ipv6/addrconf.c

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@
8383
#include <linux/if_tunnel.h>
8484
#include <linux/rtnetlink.h>
8585
#include <linux/netconf.h>
86-
87-
#ifdef CONFIG_IPV6_PRIVACY
8886
#include <linux/random.h>
89-
#endif
90-
9187
#include <linux/uaccess.h>
9288
#include <asm/unaligned.h>
9389

@@ -124,11 +120,9 @@ static inline void addrconf_sysctl_unregister(struct inet6_dev *idev)
124120
}
125121
#endif
126122

127-
#ifdef CONFIG_IPV6_PRIVACY
128123
static void __ipv6_regen_rndid(struct inet6_dev *idev);
129124
static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr);
130125
static void ipv6_regen_rndid(unsigned long data);
131-
#endif
132126

133127
static int ipv6_generate_eui64(u8 *eui, struct net_device *dev);
134128
static int ipv6_count_addresses(struct inet6_dev *idev);
@@ -183,13 +177,11 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
183177
.rtr_solicits = MAX_RTR_SOLICITATIONS,
184178
.rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
185179
.rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
186-
#ifdef CONFIG_IPV6_PRIVACY
187180
.use_tempaddr = 0,
188181
.temp_valid_lft = TEMP_VALID_LIFETIME,
189182
.temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
190183
.regen_max_retry = REGEN_MAX_RETRY,
191184
.max_desync_factor = MAX_DESYNC_FACTOR,
192-
#endif
193185
.max_addresses = IPV6_MAX_ADDRESSES,
194186
.accept_ra_defrtr = 1,
195187
.accept_ra_pinfo = 1,
@@ -221,13 +213,11 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
221213
.rtr_solicits = MAX_RTR_SOLICITATIONS,
222214
.rtr_solicit_interval = RTR_SOLICITATION_INTERVAL,
223215
.rtr_solicit_delay = MAX_RTR_SOLICITATION_DELAY,
224-
#ifdef CONFIG_IPV6_PRIVACY
225216
.use_tempaddr = 0,
226217
.temp_valid_lft = TEMP_VALID_LIFETIME,
227218
.temp_prefered_lft = TEMP_PREFERRED_LIFETIME,
228219
.regen_max_retry = REGEN_MAX_RETRY,
229220
.max_desync_factor = MAX_DESYNC_FACTOR,
230-
#endif
231221
.max_addresses = IPV6_MAX_ADDRESSES,
232222
.accept_ra_defrtr = 1,
233223
.accept_ra_pinfo = 1,
@@ -371,7 +361,6 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
371361
}
372362
#endif
373363

374-
#ifdef CONFIG_IPV6_PRIVACY
375364
INIT_LIST_HEAD(&ndev->tempaddr_list);
376365
setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
377366
if ((dev->flags&IFF_LOOPBACK) ||
@@ -384,7 +373,7 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
384373
in6_dev_hold(ndev);
385374
ipv6_regen_rndid((unsigned long) ndev);
386375
}
387-
#endif
376+
388377
ndev->token = in6addr_any;
389378

390379
if (netif_running(dev) && addrconf_qdisc_ok(dev))
@@ -865,12 +854,10 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
865854
/* Add to inet6_dev unicast addr list. */
866855
ipv6_link_dev_addr(idev, ifa);
867856

868-
#ifdef CONFIG_IPV6_PRIVACY
869857
if (ifa->flags&IFA_F_TEMPORARY) {
870858
list_add(&ifa->tmp_list, &idev->tempaddr_list);
871859
in6_ifa_hold(ifa);
872860
}
873-
#endif
874861

875862
in6_ifa_hold(ifa);
876863
write_unlock(&idev->lock);
@@ -913,7 +900,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
913900
spin_unlock_bh(&addrconf_hash_lock);
914901

915902
write_lock_bh(&idev->lock);
916-
#ifdef CONFIG_IPV6_PRIVACY
903+
917904
if (ifp->flags&IFA_F_TEMPORARY) {
918905
list_del(&ifp->tmp_list);
919906
if (ifp->ifpub) {
@@ -922,7 +909,6 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
922909
}
923910
__in6_ifa_put(ifp);
924911
}
925-
#endif
926912

927913
list_for_each_entry_safe(ifa, ifn, &idev->addr_list, if_list) {
928914
if (ifa == ifp) {
@@ -1013,7 +999,6 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
1013999
in6_ifa_put(ifp);
10141000
}
10151001

1016-
#ifdef CONFIG_IPV6_PRIVACY
10171002
static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)
10181003
{
10191004
struct inet6_dev *idev = ifp->idev;
@@ -1116,7 +1101,6 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *i
11161101
out:
11171102
return ret;
11181103
}
1119-
#endif
11201104

11211105
/*
11221106
* Choose an appropriate source address (RFC3484)
@@ -1131,9 +1115,7 @@ enum {
11311115
#endif
11321116
IPV6_SADDR_RULE_OIF,
11331117
IPV6_SADDR_RULE_LABEL,
1134-
#ifdef CONFIG_IPV6_PRIVACY
11351118
IPV6_SADDR_RULE_PRIVACY,
1136-
#endif
11371119
IPV6_SADDR_RULE_ORCHID,
11381120
IPV6_SADDR_RULE_PREFIX,
11391121
IPV6_SADDR_RULE_MAX
@@ -1247,7 +1229,6 @@ static int ipv6_get_saddr_eval(struct net *net,
12471229
&score->ifa->addr, score->addr_type,
12481230
score->ifa->idev->dev->ifindex) == dst->label;
12491231
break;
1250-
#ifdef CONFIG_IPV6_PRIVACY
12511232
case IPV6_SADDR_RULE_PRIVACY:
12521233
{
12531234
/* Rule 7: Prefer public address
@@ -1259,7 +1240,6 @@ static int ipv6_get_saddr_eval(struct net *net,
12591240
ret = (!(score->ifa->flags & IFA_F_TEMPORARY)) ^ preftmp;
12601241
break;
12611242
}
1262-
#endif
12631243
case IPV6_SADDR_RULE_ORCHID:
12641244
/* Rule 8-: Prefer ORCHID vs ORCHID or
12651245
* non-ORCHID vs non-ORCHID
@@ -1588,7 +1568,6 @@ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
15881568
if (dad_failed)
15891569
ipv6_ifa_notify(0, ifp);
15901570
in6_ifa_put(ifp);
1591-
#ifdef CONFIG_IPV6_PRIVACY
15921571
} else if (ifp->flags&IFA_F_TEMPORARY) {
15931572
struct inet6_ifaddr *ifpub;
15941573
spin_lock_bh(&ifp->lock);
@@ -1602,7 +1581,6 @@ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)
16021581
spin_unlock_bh(&ifp->lock);
16031582
}
16041583
ipv6_del_addr(ifp);
1605-
#endif
16061584
} else
16071585
ipv6_del_addr(ifp);
16081586
}
@@ -1851,7 +1829,6 @@ static int ipv6_inherit_eui64(u8 *eui, struct inet6_dev *idev)
18511829
return err;
18521830
}
18531831

1854-
#ifdef CONFIG_IPV6_PRIVACY
18551832
/* (re)generation of randomized interface identifier (RFC 3041 3.2, 3.5) */
18561833
static void __ipv6_regen_rndid(struct inet6_dev *idev)
18571834
{
@@ -1919,7 +1896,6 @@ static void __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmp
19191896
if (tmpaddr && memcmp(idev->rndid, &tmpaddr->s6_addr[8], 8) == 0)
19201897
__ipv6_regen_rndid(idev);
19211898
}
1922-
#endif
19231899

19241900
/*
19251901
* Add prefix route.
@@ -2207,9 +2183,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
22072183
if (ifp) {
22082184
int flags;
22092185
unsigned long now;
2210-
#ifdef CONFIG_IPV6_PRIVACY
22112186
struct inet6_ifaddr *ift;
2212-
#endif
22132187
u32 stored_lft;
22142188

22152189
/* update lifetime (RFC2462 5.5.3 e) */
@@ -2250,7 +2224,6 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
22502224
} else
22512225
spin_unlock(&ifp->lock);
22522226

2253-
#ifdef CONFIG_IPV6_PRIVACY
22542227
read_lock_bh(&in6_dev->lock);
22552228
/* update all temporary addresses in the list */
22562229
list_for_each_entry(ift, &in6_dev->tempaddr_list,
@@ -2315,7 +2288,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
23152288
} else {
23162289
read_unlock_bh(&in6_dev->lock);
23172290
}
2318-
#endif
2291+
23192292
in6_ifa_put(ifp);
23202293
addrconf_verify(0);
23212294
}
@@ -2995,7 +2968,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
29952968
if (!how)
29962969
idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY);
29972970

2998-
#ifdef CONFIG_IPV6_PRIVACY
29992971
if (how && del_timer(&idev->regen_timer))
30002972
in6_dev_put(idev);
30012973

@@ -3015,7 +2987,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
30152987
in6_ifa_put(ifa);
30162988
write_lock_bh(&idev->lock);
30172989
}
3018-
#endif
30192990

30202991
while (!list_empty(&idev->addr_list)) {
30212992
ifa = list_first_entry(&idev->addr_list,
@@ -3528,7 +3499,6 @@ static void addrconf_verify(unsigned long foo)
35283499
in6_ifa_put(ifp);
35293500
goto restart;
35303501
}
3531-
#ifdef CONFIG_IPV6_PRIVACY
35323502
} else if ((ifp->flags&IFA_F_TEMPORARY) &&
35333503
!(ifp->flags&IFA_F_TENTATIVE)) {
35343504
unsigned long regen_advance = ifp->idev->cnf.regen_max_retry *
@@ -3556,7 +3526,6 @@ static void addrconf_verify(unsigned long foo)
35563526
} else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next))
35573527
next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ;
35583528
spin_unlock(&ifp->lock);
3559-
#endif
35603529
} else {
35613530
/* ifp->prefered_lft <= ifp->valid_lft */
35623531
if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next))
@@ -4128,13 +4097,11 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
41284097
jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval);
41294098
array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] =
41304099
jiffies_to_msecs(cnf->mldv2_unsolicited_report_interval);
4131-
#ifdef CONFIG_IPV6_PRIVACY
41324100
array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
41334101
array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
41344102
array[DEVCONF_TEMP_PREFERED_LFT] = cnf->temp_prefered_lft;
41354103
array[DEVCONF_REGEN_MAX_RETRY] = cnf->regen_max_retry;
41364104
array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor;
4137-
#endif
41384105
array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
41394106
array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
41404107
array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
@@ -4828,7 +4795,6 @@ static struct addrconf_sysctl_table
48284795
.mode = 0644,
48294796
.proc_handler = proc_dointvec_ms_jiffies,
48304797
},
4831-
#ifdef CONFIG_IPV6_PRIVACY
48324798
{
48334799
.procname = "use_tempaddr",
48344800
.data = &ipv6_devconf.use_tempaddr,
@@ -4864,7 +4830,6 @@ static struct addrconf_sysctl_table
48644830
.mode = 0644,
48654831
.proc_handler = proc_dointvec,
48664832
},
4867-
#endif
48684833
{
48694834
.procname = "max_addresses",
48704835
.data = &ipv6_devconf.max_addresses,

0 commit comments

Comments
 (0)