networkd: Routes should take the gateway into account

Otherwise, changing the default gateway doesn't purge old gateway routes
left on the system during daemon restart. This also fixes removing other
foreign gateway routes that don't match the expected configuration.

Tested:
    Changed gateway addresses prior to the patch and they lingered on
    the system during each reconfiguration. Applied this patch and
    reconfigured gateways and other routes multiple times and it removed
    the foreign routes that had gateways that didn't match.

Signed-off-by: William A. Kennington III <william@wkennington.com>
This commit is contained in:
William A. Kennington III
2019-08-07 20:32:36 +09:00
committed by Yu Watanabe
parent 9f4f7fe3b5
commit 0b1cd3e25a
8 changed files with 62 additions and 17 deletions
+2 -2
View File
@@ -2441,7 +2441,7 @@ static int link_drop_foreign_config(Link *link) {
continue;
if (link_is_static_route_configured(link, route)) {
r = route_add(link, route->family, &route->dst, route->dst_prefixlen, route->tos, route->priority, route->table, NULL);
r = route_add(link, route->family, &route->dst, route->dst_prefixlen, &route->gw, route->tos, route->priority, route->table, NULL);
if (r < 0)
return r;
} else {
@@ -3014,7 +3014,7 @@ network_file_fail:
continue;
}
r = route_add(link, family, &route_dst, prefixlen, tos, priority, table, &route);
r = route_add(link, family, &route_dst, prefixlen, NULL, tos, priority, table, &route);
if (r < 0)
return log_link_error_errno(link, r, "Failed to add route: %m");