commit 59dd205f4d8f281cd39429bbb6a9f158be8adcd1 Author: Julien Aube Date: Mon Jan 24 11:15:49 2011 +0100 [IPv6]: Add a kernel parameter to preset the default value of the use_tempaddr flag. This patch add the kernel parameter '--ipv6.privacy_default=[0|1|2]' , which preset the value of the flags /proc/sys/net/ipv6/conf/all/use_tempaddr and /proc/sys/net/ipv6/conf/conf/use_tempaddr . This is usefull because some distributions does not handle this well: When the flag is changed in the kernel, it's often too late, the persistent address is already set, and the flag value is never taken into account. With this parameter, it's possible to "preset" the default value of the flag for the interfaces. The values [0|1|2+] have the same meaning than the corresponding use_tempaddr flag. Signed-off-by: Julien Aubé diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 01ece1b..b756214 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -2081,6 +2081,9 @@ and is between 256 and 4096 characters. It is defined in the file printk.time= Show timing data prefixed to each printk message line Format: (1/Y/y=enable, 0/N/n=disable) + privacy_default= [IPV6] + See Documentation/networking/ipv6.txt. + processor.max_cstate= [HW,ACPI] Limit processor to maximum C-state max_cstate=9 overrides any DMI blacklist limit. diff --git a/Documentation/networking/ipv6.txt b/Documentation/networking/ipv6.txt index 9fd7e21..076b6e6 100644 --- a/Documentation/networking/ipv6.txt +++ b/Documentation/networking/ipv6.txt @@ -70,3 +70,20 @@ disable_ipv6 No IPv6 addresses will be added to interfaces. +privacy_default + + Specifies the default value of the flag "use_tempaddr" + (aka. Privacy Extension, RFC 3041 and RFC 4941). + This is usefull to ensure the value of this flag for + distributions that do no takes care of it. + + The possible values are the same as the one used by sysctl: + + 0 Privacy Extension (RFC 3041) is not used. + This is the default value. + + 1 A random address suffix is configured when a Router Advertisement + is received,but is not used by default for outgoing communications. + + 2 A random address suffix is configured when a Router Advertisement + is received, and is used by deault for outgoing communications. diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 848b355..c93ce71 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -15,6 +15,11 @@ /* * Changes: * + * Julien Aubé : Add a configurable default value for the + * use_tmpaddr flag, which control the behavior of + * the kernel according to the RFC 3041 and 4941. + * + * * Janos Farkas : delete timer on ifdown * * Andi Kleen : kill double kfree on module @@ -125,6 +130,12 @@ static inline void addrconf_sysctl_unregister(struct inet6_dev *idev) static int __ipv6_regen_rndid(struct inet6_dev *idev); static int __ipv6_try_regen_rndid(struct inet6_dev *idev, struct in6_addr *tmpaddr); static void ipv6_regen_rndid(unsigned long data); + +static int ipv6_default_privacy; +module_param_named(privacy_default, ipv6_default_privacy, int, 0444); +MODULE_PARM_DESC(privacy_default, "Set IPv6 privacy extension by default \ +on all interfaces (0,1 or 2)"); + #endif static int ipv6_generate_eui64(u8 *eui, struct net_device *dev); @@ -4554,6 +4565,26 @@ static int __net_init addrconf_init_net(struct net *net) all = &ipv6_devconf; dflt = &ipv6_devconf_dflt; +#ifdef CONFIG_IPV6_PRIVACY + if (ipv6_default_privacy == 0) { + printk(KERN_INFO "IPv6 Privacy Extension " + "is disabled by default\n"); + } else if (ipv6_default_privacy == 1) { + printk(KERN_INFO "IPv6 Privacy Extension " + "is enabled by default\n"); + all->use_tempaddr = ipv6_default_privacy; + dflt->use_tempaddr = ipv6_default_privacy; + } else if (ipv6_default_privacy >= 2) { + printk(KERN_INFO "IPv6 Privacy Extension " + "is enabled and used by default\n"); + all->use_tempaddr = ipv6_default_privacy; + dflt->use_tempaddr = ipv6_default_privacy; + } else { + printk(KERN_WARNING "IPv6 Privacy Extension " + "is disabled by default (invalid value %d)\n", ipv6_default_privacy); + } +#endif + if (!net_eq(net, &init_net)) { all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL); if (all == NULL)