diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-02 02:40:31 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-06 19:44:42 +0200 |
commit | 62f0ea5fae2371795fd7a49daeda7c398f89aea0 (patch) | |
tree | f9f6f3a406cee01ca2e361a8baf8b4a595949367 /src | |
parent | network: introduce link_drop_foreign_routes() (diff) | |
download | systemd-62f0ea5fae2371795fd7a49daeda7c398f89aea0.tar.xz systemd-62f0ea5fae2371795fd7a49daeda7c398f89aea0.zip |
network: introduce link_drop_routes()
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-link.c | 13 | ||||
-rw-r--r-- | src/network/networkd-route.c | 19 | ||||
-rw-r--r-- | src/network/networkd-route.h | 1 |
3 files changed, 23 insertions, 10 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index b9053ad659..dea1e723c3 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2637,7 +2637,6 @@ static int remove_static_address_handler(sd_netlink *rtnl, sd_netlink_message *m static int link_drop_config(Link *link) { Address *address, *pool_address; - Route *route; int r; SET_FOREACH(address, link->addresses) { @@ -2664,15 +2663,9 @@ static int link_drop_config(Link *link) { if (r < 0) return r; - SET_FOREACH(route, link->routes) { - /* do not touch routes managed by the kernel */ - if (route->protocol == RTPROT_KERNEL) - continue; - - r = route_remove(route, link, NULL); - if (r < 0) - return r; - } + r = link_drop_routes(link); + if (r < 0) + return r; ndisc_flush(link); diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index d7ec9097b3..87006a6c44 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -566,6 +566,25 @@ int link_drop_foreign_routes(Link *link) { return r; } +int link_drop_routes(Link *link) { + Route *route; + int k, r = 0; + + assert(link); + + SET_FOREACH(route, link->routes) { + /* do not touch routes managed by the kernel */ + if (route->protocol == RTPROT_KERNEL) + continue; + + k = route_remove(route, link, NULL); + if (k < 0 && r >= 0) + r = k; + } + + return r; +} + int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) { Route *route = userdata; int r; diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index d362298294..d5760a96a6 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -72,6 +72,7 @@ int route_configure(Route *route, Link *link, link_netlink_message_handler_t cal int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback); int link_set_routes(Link *link); +int link_drop_routes(Link *link); int link_drop_foreign_routes(Link *link); int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m); |