network: introduce Token=eui64

So, now user can explicitly request EUI-64 algorithm to generate addresses.
This commit is contained in:
Yu Watanabe 2021-09-25 04:04:09 +09:00
parent a73628e647
commit 140bf8dacc
2 changed files with 19 additions and 3 deletions

View file

@ -2193,8 +2193,11 @@ Table=1234</programlisting></para>
<term><varname>Token=</varname></term>
<listitem>
<para>Specifies an optional address generation mode for the Stateless Address
Autoconfiguration (SLAAC). Supported modes are <literal>static</literal> and
<literal>prefixstable</literal>.</para>
Autoconfiguration (SLAAC). Supported modes are <literal>eui64</literal>,
<literal>static</literal>, and <literal>prefixstable</literal>.</para>
<para>When the mode is set to <literal>eui64</literal>, then the EUI-64 algorithm will be
used to generate an address for that prefix.</para>
<para>When the mode is set to <literal>static</literal>, an IPv6 address must be
specified after a colon (<literal>:</literal>), and the lower bits of the supplied
@ -2229,7 +2232,8 @@ Table=1234</programlisting></para>
the all previous assignments are cleared.</para>
<para>Examples:
<programlisting>Token=::1a:2b:3c:4d
<programlisting>Token=eui64
Token=::1a:2b:3c:4d
Token=static:::1a:2b:3c:4d
Token=prefixstable
Token=prefixstable:2002:da8:1::</programlisting></para>

View file

@ -23,6 +23,7 @@
#define NDISC_APP_ID SD_ID128_MAKE(13,ac,81,a7,d5,3f,49,78,92,79,5d,0c,29,3a,bc,7e)
typedef enum AddressGenerationType {
ADDRESS_GENERATION_EUI64,
ADDRESS_GENERATION_STATIC,
ADDRESS_GENERATION_PREFIXSTABLE,
_ADDRESS_GENERATION_TYPE_MAX,
@ -176,6 +177,10 @@ static int generate_addresses(
struct in6_addr addr, *copy;
switch (j->type) {
case ADDRESS_GENERATION_EUI64:
generate_eui64_address(link, &masked, &addr);
break;
case ADDRESS_GENERATION_STATIC:
memcpy(addr.s6_addr, masked.s6_addr, 8);
memcpy(addr.s6_addr + 8, j->address.s6_addr + 8, 8);
@ -309,6 +314,9 @@ int config_parse_address_generation_type(
return 0;
}
} else if (streq(rvalue, "eui64")) {
type = ADDRESS_GENERATION_EUI64;
p = NULL;
} else {
type = ADDRESS_GENERATION_STATIC;
@ -328,6 +336,10 @@ int config_parse_address_generation_type(
}
switch (type) {
case ADDRESS_GENERATION_EUI64:
assert(in6_addr_is_null(&buffer.in6));
break;
case ADDRESS_GENERATION_STATIC:
/* Only last 64 bits are used. */
memzero(buffer.in6.s6_addr, 8);