Skip to content

Commit 31ec8b6

Browse files
committed
sys/netinet6: Implement RFC 7217
Implement RFC 7217 (A Method for Generating Semantically Opaque Interface Identifiers with IPv6 Stateless Address Autoconfiguration (SLAAC)) in our IPv6 stack. A new ifconfig `stableaddr` flag is added to enable the feature on interfaces, which defaults to on or off for new interfaces based on the sysctl `net.inet6.ip6.use_stableaddr` (off by default, so this commit causes no change in behavior with default settings). The algorithm follows the RFC in its logic, using SHA256-HMAC as the algorithm to derive addresses so as to provide code that can be leveraged by future implentations of RFC 8981, leveraging the `hostuuid` as the secret. The source of the hostidentifier can be configured using the sysctl `net.inet6.ip6.stableaddr_netifsource`, while the number of retries generating a new address in case of collision can be configured using the `net.inet6.ip6.stableaddr_maxretries` sysctl (default 3). Documentation about all these flags is added to the ifconfig(8) man page. Reviewed by: cognet, glebius, hrs Tested by: [email protected] Approved by: cognet, glebius Relnotes: yes Differential Revision: https://reviews.freebsd.org/D49681
1 parent 174d5d9 commit 31ec8b6

File tree

14 files changed

+423
-94
lines changed

14 files changed

+423
-94
lines changed

sbin/ifconfig/af_inet6.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ static struct cmd inet6_cmds[] = {
726726
DEF_CMD_ARG("pltime", setip6pltime),
727727
DEF_CMD_ARG("vltime", setip6vltime),
728728
DEF_CMD("eui64", 0, setip6eui64),
729+
DEF_CMD("stableaddr", ND6_IFF_STABLEADDR, setnd6flags),
730+
DEF_CMD("-stableaddr", -ND6_IFF_STABLEADDR, setnd6flags),
729731
#ifdef EXPERIMENTAL
730732
DEF_CMD("ipv6_only", ND6_IFF_IPV6_ONLY_MANUAL,setnd6flags),
731733
DEF_CMD("-ipv6_only", -ND6_IFF_IPV6_ONLY_MANUAL,setnd6flags),

sbin/ifconfig/af_nd6.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static const char *ND6BITS[] = {
6666
[9] = "IPV6_ONLY",
6767
[10] = "IPV6_ONLY_MANUAL",
6868
#endif
69+
[11] = "STABLEADDR",
6970
[15] = "DEFAULTIF",
7071
};
7172

sbin/ifconfig/ifconfig.8

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,36 @@ Set a flag to disable Duplicate Address Detection.
10041004
.It Cm -no_dad
10051005
Clear a flag
10061006
.Cm no_dad .
1007+
.It Cm stableaddr
1008+
Set a flag to create SLAAC addresses using a stable algorithm according to RFC 7217
1009+
The
1010+
.Xr sysctl 8
1011+
variable
1012+
.Va net.inet6.ip6.use_stableaddr
1013+
controls whether this flag is set by default or not for newly created interfaces.
1014+
To get consistent defaults for interfaces created at boot it should be set as a tunable via loader.conf(8).
1015+
The
1016+
.Xr sysctl 8
1017+
variable
1018+
.Va net.inet6.ip6.stableaddr_maxretries
1019+
sets the maximum number of retries to generate a unique IPv6 address to be performed in case of DAD failures.
1020+
This defaults to 3 which is also the reccommended minimum value.
1021+
The interface ID source can be configured using the
1022+
.Xr sysctl 8
1023+
variable
1024+
.Va net.inet6.ip6.stableaddr_netifsource:
1025+
.Bl -tag -compact
1026+
.It Cm 0
1027+
uses the interface name string (the default)
1028+
.It Cm 1
1029+
uses the interface ID
1030+
.It Cm 2
1031+
uses the MAC address of the interface (if one can be obtained for it)
1032+
.El
1033+
.Pp
1034+
.It Cm -stableaddr
1035+
Clear the flag
1036+
.Cm stableaddr .
10071037
.El
10081038
.Ss IPv6 Parameters
10091039
The following parameters are specific for IPv6 addresses.

sys/netinet6/in6.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ struct ip6_mtuinfo {
609609
/* IPV6CTL_RTMINEXPIRE 26 deprecated */
610610
/* IPV6CTL_RTMAXCACHE 27 deprecated */
611611

612+
#define IPV6CTL_STABLEADDR_NETIFSRC 30 /* semantically opaque addresses (RFC7217) hash algo netif parameter src */
613+
#define IPV6CTL_STABLEADDR_MAXRETRIES 31 /* semantically opaque addresses (RFC7217) max DAD retries */
612614
#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */
613615
#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */
614616
#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */
@@ -617,6 +619,7 @@ struct ip6_mtuinfo {
617619
#define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */
618620
#define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */
619621
#define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */
622+
#define IPV6CTL_USESTABLEADDR 40 /* use semantically opaque addresses (RFC7217) */
620623

621624
#define IPV6CTL_MAXFRAGS 41 /* max fragments */
622625
#if 0

0 commit comments

Comments
 (0)