1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 14:55:37 +03:00

Merge pull request #3990 from AnchorCat/networkd-fixes

networkd: various fixes for route configuration
This commit is contained in:
Lennart Poettering 2016-08-19 10:43:58 +02:00 committed by GitHub
commit b55a6f0812

View File

@ -41,7 +41,7 @@ int route_new(Route **ret) {
route->family = AF_UNSPEC; route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE; route->scope = RT_SCOPE_UNIVERSE;
route->protocol = RTPROT_UNSPEC; route->protocol = RTPROT_UNSPEC;
route->table = RT_TABLE_DEFAULT; route->table = RT_TABLE_MAIN;
route->lifetime = USEC_INFINITY; route->lifetime = USEC_INFINITY;
*ret = route; *ret = route;
@ -322,7 +322,8 @@ int route_add(
} else } else
return r; return r;
*ret = route; if (ret)
*ret = route;
return 0; return 0;
} }
@ -440,20 +441,14 @@ static int route_expire_callback(sd_netlink *rtnl, sd_netlink_message *m, void *
assert(m); assert(m);
assert(link); assert(link);
assert(link->ifname); assert(link->ifname);
assert(link->link_messages > 0);
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
return 1; return 1;
link->link_messages--;
r = sd_netlink_message_get_errno(m); r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST) if (r < 0 && r != -EEXIST)
log_link_warning_errno(link, r, "could not remove route: %m"); log_link_warning_errno(link, r, "could not remove route: %m");
if (link->link_messages == 0)
log_link_debug(link, "route removed");
return 1; return 1;
} }
@ -466,11 +461,8 @@ int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
r = route_remove(route, route->link, route_expire_callback); r = route_remove(route, route->link, route_expire_callback);
if (r < 0) if (r < 0)
log_warning_errno(r, "Could not remove route: %m"); log_warning_errno(r, "Could not remove route: %m");
else { else
/* route may not be exist in kernel. If we fail still remove it */
route->link->link_messages++;
route_free(route); route_free(route);
}
return 1; return 1;
} }
@ -557,14 +549,12 @@ int route_configure(
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set flags: %m"); return log_error_errno(r, "Could not set flags: %m");
if (route->table != RT_TABLE_DEFAULT) { if (route->table != RT_TABLE_MAIN) {
if (route->table < 256) { if (route->table < 256) {
r = sd_rtnl_message_route_set_table(req, route->table); r = sd_rtnl_message_route_set_table(req, route->table);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set route table: %m"); return log_error_errno(r, "Could not set route table: %m");
} else { } else {
r = sd_rtnl_message_route_set_table(req, RT_TABLE_UNSPEC); r = sd_rtnl_message_route_set_table(req, RT_TABLE_UNSPEC);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set route table: %m"); return log_error_errno(r, "Could not set route table: %m");