From 95eb38c8d0df10b100d37e3be24a7eaf75b76adc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 5 Dec 2021 05:01:30 +0900 Subject: [PATCH] network: route: make route_cancel_request() take Link* As the Route object may be managed by Manager. --- src/network/networkd-dhcp-prefix-delegation.c | 2 +- src/network/networkd-dhcp4.c | 2 +- src/network/networkd-dhcp6.c | 2 +- src/network/networkd-ndisc.c | 2 +- src/network/networkd-route.c | 13 +++++++------ src/network/networkd-route.h | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c index 85de6757f6..2b2f787795 100644 --- a/src/network/networkd-dhcp-prefix-delegation.c +++ b/src/network/networkd-dhcp-prefix-delegation.c @@ -184,7 +184,7 @@ int dhcp6_pd_remove(Link *link, bool only_marked) { if (k < 0) r = k; - route_cancel_request(route); + route_cancel_request(route, link); } } else { Address *address; diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 1ee0052a75..cd30cae7c9 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -71,7 +71,7 @@ static int dhcp4_remove_address_and_routes(Link *link, bool only_marked) { if (k < 0) r = k; - route_cancel_request(route); + route_cancel_request(route, link); } SET_FOREACH(address, link->addresses) { diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index f86efca5c7..b9831e7fa1 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -63,7 +63,7 @@ static int dhcp6_remove(Link *link, bool only_marked) { if (k < 0) r = k; - route_cancel_request(route); + route_cancel_request(route, link); } SET_FOREACH(address, link->addresses) { diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 470c969329..df5e580aef 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -90,7 +90,7 @@ static int ndisc_remove(Link *link, struct in6_addr *router) { if (k < 0) r = k; - route_cancel_request(route); + route_cancel_request(route, link); } SET_FOREACH(address, link->addresses) { diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 20d6aa47f6..0995402bc5 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -1260,24 +1260,25 @@ static int route_configure( return 0; } -void route_cancel_request(Route *route) { +void route_cancel_request(Route *route, Link *link) { Request req; assert(route); + link = route->link ?: link; + + assert(link); + if (!route_is_requesting(route)) return; - if (!route->link) - return; - req = (Request) { - .link = route->link, + .link = link, .type = REQUEST_TYPE_ROUTE, .route = route, }; - request_drop(ordered_set_get(route->link->manager->request_queue, &req)); + request_drop(ordered_set_get(link->manager->request_queue, &req)); route_cancel_requesting(route); } diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index a3194de1ae..e3e22a5985 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -86,7 +86,7 @@ int link_drop_routes(Link *link); int link_drop_foreign_routes(Link *link); void link_foreignize_routes(Link *link); -void route_cancel_request(Route *route); +void route_cancel_request(Route *route, Link *link); int link_request_route( Link *link, Route *route,