network: Improve variable name for address generation

The logic which can produce an IPv6 address using SLAAC produces an
address, not a prefix, so the boolean variable used to detect whether
it succeeded should reflect that.
This commit is contained in:
Kevin P. Fleming 2020-02-08 15:34:35 -05:00 committed by Yu Watanabe
parent a0be538616
commit 87f9d6ea8e

View file

@ -255,7 +255,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
} }
static int ndisc_router_generate_address(Link *link, unsigned prefixlen, uint32_t lifetime_preferred, Address *address) { static int ndisc_router_generate_address(Link *link, unsigned prefixlen, uint32_t lifetime_preferred, Address *address) {
bool prefix = false; bool have_address = false;
struct in6_addr addr; struct in6_addr addr;
IPv6Token *j; IPv6Token *j;
Iterator i; Iterator i;
@ -274,18 +274,18 @@ static int ndisc_router_generate_address(Link *link, unsigned prefixlen, uint32_
return r; return r;
if (stableprivate_address_is_valid(&address->in_addr.in6)) { if (stableprivate_address_is_valid(&address->in_addr.in6)) {
prefix = true; have_address = true;
break; break;
} }
} }
} else if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_STATIC) { } else if (j->address_generation_type == IPV6_TOKEN_ADDRESS_GENERATION_STATIC) {
memcpy(((uint8_t *)&address->in_addr.in6) + 8, ((uint8_t *) &j->prefix) + 8, 8); memcpy(((uint8_t *)&address->in_addr.in6) + 8, ((uint8_t *) &j->prefix) + 8, 8);
prefix = true; have_address = true;
break; break;
} }
/* fallback to eui64 if prefixstable or static do not match */ /* fall back to EUI-64 if neither prefixstable nor static provide an address */
if (!prefix) { if (!have_address) {
/* see RFC4291 section 2.5.1 */ /* see RFC4291 section 2.5.1 */
address->in_addr.in6.s6_addr[8] = link->mac.ether_addr_octet[0]; address->in_addr.in6.s6_addr[8] = link->mac.ether_addr_octet[0];
address->in_addr.in6.s6_addr[8] ^= 1 << 1; address->in_addr.in6.s6_addr[8] ^= 1 << 1;