summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-ndisc.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-04-09 04:26:16 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-04-09 05:06:32 +0200
commite700e482576ad9982da3bab62f613d1b7b52516f (patch)
tree53eafdf0cf61613a044b99ea3b9ce21f2a8f2782 /src/network/networkd-ndisc.c
parentnetwork/address: make Address object optionally take reference to IPv6Token (diff)
downloadsystemd-e700e482576ad9982da3bab62f613d1b7b52516f.tar.xz
systemd-e700e482576ad9982da3bab62f613d1b7b52516f.zip
network/address-generation: also provide used tokens when generating address
Then, assign the token to the corresponding Address object.
Diffstat (limited to 'src/network/networkd-ndisc.c')
-rw-r--r--src/network/networkd-ndisc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 487a1e6309..e160014c5a 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -1028,8 +1028,7 @@ static int ndisc_router_process_hop_limit(Link *link, sd_ndisc_router *rt) {
static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *rt) {
usec_t lifetime_valid_usec, lifetime_preferred_usec;
- _cleanup_set_free_ Set *addresses = NULL;
- struct in6_addr prefix, *a;
+ struct in6_addr prefix;
uint8_t prefixlen;
int r;
@@ -1067,11 +1066,14 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
if (lifetime_preferred_usec > lifetime_valid_usec)
return 0;
- r = ndisc_generate_addresses(link, &prefix, prefixlen, &addresses);
+ _cleanup_hashmap_free_ Hashmap *tokens_by_address = NULL;
+ r = ndisc_generate_addresses(link, &prefix, prefixlen, &tokens_by_address);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to generate SLAAC addresses: %m");
- SET_FOREACH(a, addresses) {
+ IPv6Token *token;
+ struct in6_addr *a;
+ HASHMAP_FOREACH_KEY(token, a, tokens_by_address) {
_cleanup_(address_unrefp) Address *address = NULL;
r = address_new(&address);
@@ -1084,6 +1086,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
address->flags = IFA_F_NOPREFIXROUTE|IFA_F_MANAGETEMPADDR;
address->lifetime_valid_usec = lifetime_valid_usec;
address->lifetime_preferred_usec = lifetime_preferred_usec;
+ address->token = ipv6_token_ref(token);
/* draft-ietf-6man-slaac-renum-07 section 4.2
* https://datatracker.ietf.org/doc/html/draft-ietf-6man-slaac-renum-07#section-4.2