From 8ae3a4f5e282a1fb024e7bb5d6cf1b83037a2395 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 23 Dec 2023 01:21:22 +0900 Subject: [PATCH 1/2] network/address: also drop reference for DHCP server address The Address object should never freed after it is referenced. So, this should not change any behavior. Just for safety. --- src/network/networkd-address.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index bcd3ae66213..629c4d697f9 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -201,6 +201,9 @@ Address *address_free(Address *address) { if (address->network) { assert(address->section); ordered_hashmap_remove(address->network->addresses_by_section, address->section); + + if (address->network->dhcp_server_address == address) + address->network->dhcp_server_address = NULL; } if (address->link) { From f089d3ebd59e6fb02fc178643a7342c058f207f3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 23 Dec 2023 01:32:44 +0900 Subject: [PATCH 2/2] network/address: move post-processes on address removal to address_drop() For consistency with other follow-up processes after address removal. No functional change, just refactoring and preparation for later commits. --- src/network/networkd-address.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 629c4d697f9..f95a138a2e3 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -206,16 +206,9 @@ Address *address_free(Address *address) { address->network->dhcp_server_address = NULL; } - if (address->link) { + if (address->link) set_remove(address->link->addresses, address); - if (address->family == AF_INET6 && - in6_addr_equal(&address->in_addr.in6, &address->link->ipv6ll_address)) - memzero(&address->link->ipv6ll_address, sizeof(struct in6_addr)); - - ipv4acd_detach(address->link, address); - } - config_section_free(address->section); free(address->label); free(address->netlabel); @@ -781,6 +774,13 @@ static int address_drop(Address *address) { address_del_netlabel(address); + /* FIXME: if the IPv6LL address is dropped, stop DHCPv6, NDISC, RADV. */ + if (address->family == AF_INET6 && + in6_addr_equal(&address->in_addr.in6, &link->ipv6ll_address)) + link->ipv6ll_address = (const struct in6_addr) {}; + + ipv4acd_detach(link, address); + address_free(address); link_update_operstate(link, /* also_update_master = */ true);