ipv6: stable privacy addresses
Subsystems (4)
RFC PATCH 1/1 ipv6: stable privacy addresses
Hi!
This is a preview for the interface I envison for IPv6 stable privacy addresses. This patch has still issues: I experience some problems with dev_mc_add mc-addresses not forwarded to macvtaps here on my VM.
-- >8 --
This patch implements stable privacy addresses as currently specified as a draft by Fernando Gont:
<http://tools.ietf.org/html/draft-ietf-6man-stable-privacy-addresses-16>
One can assume this will become a RFC any time soon. Recent updates had only minor changes. For details please have a look at the draft.
Some time ago <http://tools.ietf.org/html/draft-iesg-serno-privacy-00>
stated that
" Protocols intended to be used over the global Internet SHOULD NOT
depend on the inclusion of hardware serial numbers. Protocols intended to be used only in a local IP-based network, which use hardware serial numbers, SHOULD define a means to keep those serial numbers from escaping into the global Internet.
".
Despite the existence of Privacy Extensions Fernando Gont tries to abandon EUI-64 based address for link-local as well as for global address scope as it is too easy that the old EUI-64 based addresses could leak.
This patch currently only implements the switch of the address generation mode at compile- or boot-time (as the patch already includes documentation on how to use it, I'll leave it out here). The stable secret will get loaded via procfs.
The draft offers more than one version which attributes to hash to get a stable host identifier. I decided to pick SHA-1 as the hashing function and use the device address as the Net_Iface identifier. I did not implement the optional Network_ID yet.
Futher algorithms can be easily implemented and can be distinguished by the address generation mode.
--- Documentation/kernel-parameters.txt | 10 + Documentation/networking/ip-sysctl.txt | 16 ++ include/linux/ipv6.h | 2 + include/net/addrconf.h | 4 + include/net/if_inet6.h | 1 + include/net/netns/ipv6.h | 3 + include/uapi/linux/if_addr.h | 1 + include/uapi/linux/ipv6.h | 2 + kernel/x509_certificate_list | 0 net/ipv6/Kconfig | 41 ++++ net/ipv6/addrconf.c | 341 +++++++++++++++++++++++++++++++-- net/ipv6/sysctl_net_ipv6.c | 22 +++ 12 files changed, 425 insertions(+), 18 deletions(-) create mode 100644 kernel/x509_certificate_list
Documentation/kernel-parameters.txt +10 -0
@@ -346,6 +346,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. add_efi_memmap [EFI; X86] Include EFI memory map in kernel's map of available physical RAM. + address_generation_mode= [IPV6] Method of address + generation. Following modes are + currently supported: + + 0 EUI-64 address generation + 1 stable privacy generation v1 + agp= [AGP] { off | try_unsupported } off: disable AGP support
@@ -2995,6 +3002,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted. spia_pedr= spia_peddr= + stable_privacy_address_secret= [IPV6] Secret for stable + privacy address generation. + stacktrace [FTRACE] Enabled the stack tracer on boot up.
Documentation/networking/ip-sysctl.txt +16 -0
@@ -1084,6 +1084,13 @@ bindv6only - BOOLEAN Default: FALSE (as specified in RFC3493) +stable_address_secret - UNSIGNED LONG + If stable privacy addresses are enabled then on the first + write to this file link-local addresses are generated and + router solicitions are send out. The generated addresses are + based on this secret. If the same secret is reused across + reboots the generated addresses will be the same. + IPv6 Fragmentation: ip6frag_high_thresh - INTEGER
@@ -1365,6 +1372,15 @@ suppress_frag_ndisc - INTEGER 1 - (default) discard fragmented neighbor discovery packets 0 - allow fragmented neighbor discovery packets +idgen_retries - INTEGER + Number of retries to generate a stable privacy address in case + of a duplicate address. + Default: 3 + +idgen_delay - INTEGER + Seconds to delay another attempt to generate a stable privacy address. + Default: 1000 (1 second) + icmp/*: ratelimit - INTEGER Limit the maximal rates for sending ICMPv6 packets.
include/linux/ipv6.h +2 -0
@@ -50,6 +50,8 @@ struct ipv6_devconf {__s32 force_tllao;__s32 ndisc_notify;__s32 suppress_frag_ndisc; +__s32 idgen_retries; +__s32 idgen_delay;void *sysctl; };
include/net/addrconf.h +4 -0
@@ -216,6 +216,10 @@ int inet6addr_notifier_call_chain(unsigned long val, void *v);void inet6_netconf_notify_devconf (struct net *net,int type,int ifindex,struct ipv6_devconf *devconf); +int addrconf_sysctl_stbladdr_secret_change (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos); +/** * __in6_dev_get - get inet6_dev pointer from netdevice * @dev: network device
include/net/if_inet6.h +1 -0
@@ -52,6 +52,7 @@ struct inet6_ifaddr {__u32 flags;__u8 dad_probes; +__u8 dad_retry_cnt;__u16 scope;
include/net/netns/ipv6.h +3 -0
@@ -73,6 +73,9 @@ struct netns_ipv6 {#endif atomic_t dev_addr_genid;atomic_t rt_genid; + +int addrgen_mode; +unsigned long stbladdr_secret; };#if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 )
include/uapi/linux/if_addr.h +1 -0
@@ -49,6 +49,7 @@ enum {#define IFA_F_TENTATIVE 0x40#define IFA_F_PERMANENT 0x80#define IFA_F_MANAGETEMPADDR 0x100 +#define IFA_F_PRIVSTBLADDR 0x200struct ifa_cacheinfo {__u32 ifa_prefered;
include/uapi/linux/ipv6.h +2 -0
@@ -163,6 +163,8 @@ enum {DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL ,DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL ,DEVCONF_SUPPRESS_FRAG_NDISC , +DEVCONF_IDGEN_RETRIES , +DEVCONF_IDGEN_DELAY , DEVCONF_MAX };
kernel/x509_certificate_list new file +0 -0
net/ipv6/Kconfig +41 -0
47 lines not on this page · raw message
net/ipv6/addrconf.c +323 -18
531 lines not on this page · raw message
net/ipv6/sysctl_net_ipv6.c +22 -0
@@ -24,6 +24,21 @@ static struct ctl_table ipv6_table_template[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .procname = "stable_address_secret", + .data = &init_net.ipv6.stbladdr_secret, + .maxlen = sizeof(unsigned long), + .mode = 0600, + .proc_handler = addrconf_sysctl_stbladdr_secret_change, + .extra2 = &init_net + }, + { + .procname = "address_generation_mode", + .data = &init_net.ipv6.addrgen_mode, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = proc_dointvec, + }, { } };
@@ -52,6 +67,13 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) goto out; ipv6_table[0 ].data = &net->ipv6.sysctl.bindv6only; +/* new namespaces do not inherit the stbladdr_secret */ + net->ipv6.stbladdr_secret =0UL ; + ipv6_table[1 ].data = &net->ipv6.stbladdr_secret; + ipv6_table[1 ].extra2 = net; + + ipv6_table[2 ].data = &net->ipv6.addrgen_mode; + ipv6_route_table =ipv6_route_sysctl_init (net);if (!ipv6_route_table) goto out_ipv6_table;
Signature · 1 line
1.8.3.1
Quoted 3 lines
This is a preview for the interface I envison for IPv6 stable privacy addresses.
Great!
Documentation/networking/ip-sysctl.txt bindv6only - BOOLEAN · line 1090
Quoted 4 lines
Documentation/networking/ip-sysctl.txt +4
-0+stable_address_secret - UNSIGNED LONG + If stable privacy addresses are enabled then on the first + write to this file link-local addresses are generated and + router solicitions are send out. The generated addresses are
s/solicitions/solicitations/
Documentation/networking/ip-sysctl.txt bindv6only - BOOLEAN · line 1093
Quoted 3 lines
Documentation/networking/ip-sysctl.txt +3
-0+ based on this secret. If the same secret is reused across + reboots the generated addresses will be the same. +
Do you not provide a configuration via netlink for the secret?
Documentation/networking/ip-sysctl.txt suppress_frag_ndisc - INTEGER · line 1381
Quoted 2 lines
Documentation/networking/ip-sysctl.txt +2
-0+idgen_delay - INTEGER + Seconds to delay another attempt to generate a stable privacy address.
Perhaps s/Seconds/Milliseconds/ ?
Quoted 5 lines
net/ipv6/Kconfig +5
-0+config IPV6_ADDRESS_GEN_MODE_STABLE_PRIVACY_V1 + bool "Stable privacy address generation v1" + help + Stable privacy address generation mode v1. Further + information can be found here:
net/ipv6/Kconfig menuconfig IPV6 · line 62
Quoted 10 lines
net/ipv6/Kconfig +10
-0+ http://tools.ietf.org/html/draft-ietf-6man-stable-privacy-addresses-16 + + This option may need support from distributions to install + the stable secret early at boot up (otherwise link-local + addresses will be generated too late). If you don't have + services depending on link-local addresses on boot-up you can + activate this mode and install the stable secret any time + later by hand by writing it to + /proc/sys/net/ipv6/stable_privacy_secret. +
Here is your documentation inconsistent with before. The right file is probably /proc/sys/net/ipv6/stable_address_secret
You configuration is for all interfaces the same, isn't? I would like a configuration possibility per interface, to mix EUI64 and stable privacy addresses on the same device.
In the same way, the configuration of the secret per interface could be useful (simple example: two NIC on the same LAN).
net/ipv6/addrconf.c struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add · line 1670
Quoted 3 lines
net/ipv6/addrconf.c +1
-1-static void addrconf_dad_stop (struct inet6_ifaddr *ifp,int dad_failed) +static void addrconf_dad_stop (struct inet6_ifaddr *ifp,bool dad_failed)
The passage of dad_failed from int to bool is not directly connected with this feature, can you maybe split it in another patch?
Florent.
Quoted 1 line · Florent Fourcot
Do you not provide a configuration via netlink for the secret?
I definitely will provide a netlink interface. I already have a patch here but I am not sure how the interface will work out in the end. See below.
Quoted 19 lines
Quoted 5 lines
net/ipv6/Kconfig +5
-0+config IPV6_ADDRESS_GEN_MODE_STABLE_PRIVACY_V1 + bool "Stable privacy address generation v1" + help + Stable privacy address generation mode v1. Further + information can be found here:net/ipv6/Kconfig menuconfig IPV6 · line 62
Quoted 10 lines
net/ipv6/Kconfig +10
-0+ http://tools.ietf.org/html/draft-ietf-6man-stable-privacy-addresses-16 + + This option may need support from distributions to install + the stable secret early at boot up (otherwise link-local + addresses will be generated too late). If you don't have + services depending on link-local addresses on boot-up you can + activate this mode and install the stable secret any time + later by hand by writing it to + /proc/sys/net/ipv6/stable_privacy_secret. +Here is your documentation inconsistent with before. The right file is probably
/proc/sys/net/ipv6/stable_address_secret
Quoted 3 lines
You configuration is for all interfaces the same, isn't? I would like a configuration possibility per interface, to mix EUI64 and stable privacy addresses on the same device.
You mean like EUI-64 link-local and privacy-stable ones for global scope? This indeed does sound useful.
Quoted 2 lines
In the same way, the configuration of the secret per interface could be useful (simple example: two NIC on the same LAN).
Hmm, I thought about that too, but have not found a valid reason to support it yet, given the numerous other configuration possibilities.
My current problem is how to make this interface as robust as possible to use so that distributions can support it.
I just started coding support for tracking DAD-errors accross reboots so e.g. if a privstbl address has two DAD conflicts before it stabilzes, it should get the same one after reboot. Ideally we would serialize this information into user-space and apply it on next boot. But what key should we use to store the dad-conflicts (MAC or interface name etc. or make it even configurable?). Should we store information on interfaces which are not yet registered too, or always kick link-local generation by hand? When should we store those numbers? If we only do that at shutdown time we may have lost some manually destroyed interfaces already.
I have a similar problem with virtual interfaces. It would be better to identify them by name and not by mac-address. Also we should include the name in the hash, so we could have different kind of hashes per interface.
The hash itself needs to be stable and one particular hash version must not get touched after release, otherwise we could change people's IPv6 addresses accross upgrades.
The combination of all those options call for a very complex interface. In the end I hoped to get basic support into the kernel and leave complex policies to user-space (that's out of scope for this patch but I already have some ideas).
Quoted 6 lines
net/ipv6/addrconf.c struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add · line 1670
Quoted 3 lines
net/ipv6/addrconf.c +1
-1-static void addrconf_dad_stop (struct inet6_ifaddr *ifp,int dad_failed) +static void addrconf_dad_stop (struct inet6_ifaddr *ifp,bool dad_failed)The passage of
dad_failedfrom int to bool is not directly connected with this feature, can you maybe split it in another patch?
I guess I should do that. But in the end I am almost always too lazy to submit such patches then. ;)
I'll also improve the documentation in the next versions, thanks for the corrections! It seems I did not update it regullary enough every time I did change in the code.
Thanks for review,
Hannes
Quoted 7 lines
Quoted 3 lines
You configuration is for all interfaces the same, isn't? I would like a configuration possibility per interface, to mix EUI64 and stable privacy addresses on the same device.
You mean like EUI-64 link-local and privacy-stable ones for global scope? This indeed does sound useful.
Yes, and to mix configuration with several interfaces. One can set the eth0 interface with EUI-64 for global scope, and wlan0 with privacy-stable for global scope.
Regards,
Florent.