network: drop pending requests when a DHCP lease is lost or a client is stopped

When a DHCP lease is lost or a client is stopped, there may exist
requests not processed yet. We need to cancel them, otherwise an
address or route requested by the lost lease may be configured later.

(cherry picked from commit 830b60ae1f)
This commit is contained in:
Yu Watanabe
2026-10-16 11:36:32 +01:00
committed by Luca Boccassi
parent ae6dc22b40
commit 64f2911bac
4 changed files with 15 additions and 0 deletions
@@ -271,6 +271,10 @@ int dhcp_pd_remove(Link *link, bool only_marked) {
}
}
if (!only_marked)
/* Also drop pending requests when the lease is lost or the client is stopped. */
RET_GATHER(ret, link_drop_requests(link, NETWORK_CONFIG_SOURCE_DHCP_PD));
return ret;
}
+4
View File
@@ -272,6 +272,10 @@ static int dhcp4_remove_address_and_routes(Link *link, bool only_marked) {
RET_GATHER(ret, address_remove_and_cancel(address, link));
}
if (!only_marked)
/* Also drop pending requests when the lease is lost or the client is stopped. */
RET_GATHER(ret, link_drop_requests(link, NETWORK_CONFIG_SOURCE_DHCP4));
return ret;
}
+4
View File
@@ -83,6 +83,10 @@ static int dhcp6_remove(Link *link, bool only_marked) {
RET_GATHER(ret, address_remove_and_cancel(address, link));
}
if (!only_marked)
/* Also drop pending requests when the lease is lost or the client is stopped. */
RET_GATHER(ret, link_drop_requests(link, NETWORK_CONFIG_SOURCE_DHCP6));
return ret;
}
+3
View File
@@ -3194,6 +3194,9 @@ int ndisc_stop(Link *link) {
void ndisc_flush(Link *link) {
assert(link);
/* First, drop pending requests. */
(void) link_drop_requests(link, NETWORK_CONFIG_SOURCE_NDISC);
/* Remove all addresses, routes, RDNSS, DNSSL, DNR, and Captive Portal entries, without exception. */
(void) ndisc_drop_outdated(link, /* router= */ NULL, /* timestamp_usec= */ USEC_INFINITY);
(void) ndisc_drop_redirect(link, /* router= */ NULL);