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

sd-netlink: do not set route type and table by default for RTM_GETROUTE or friends

This commit is contained in:
Yu Watanabe 2021-05-25 06:49:51 +09:00
parent 3ca619061d
commit 3e0eeb8e33
3 changed files with 20 additions and 17 deletions

View File

@ -265,9 +265,6 @@ int sd_rtnl_message_new_route(sd_netlink *rtnl, sd_netlink_message **ret,
rtm = NLMSG_DATA((*ret)->hdr);
rtm->rtm_family = rtm_family;
rtm->rtm_scope = RT_SCOPE_UNIVERSE;
rtm->rtm_type = RTN_UNICAST;
rtm->rtm_table = RT_TABLE_MAIN;
rtm->rtm_protocol = rtm_protocol;
return 0;

View File

@ -893,21 +893,19 @@ static int route_set_netlink_message(const Route *route, sd_netlink_message *req
if (r < 0)
return log_link_error_errno(link, r, "Could not set flags: %m");
if (route->table != RT_TABLE_MAIN) {
if (route->table < 256) {
r = sd_rtnl_message_route_set_table(req, route->table);
if (r < 0)
return log_link_error_errno(link, r, "Could not set route table: %m");
} else {
r = sd_rtnl_message_route_set_table(req, RT_TABLE_UNSPEC);
if (r < 0)
return log_link_error_errno(link, r, "Could not set route table: %m");
if (route->table < 256) {
r = sd_rtnl_message_route_set_table(req, route->table);
if (r < 0)
return log_link_error_errno(link, r, "Could not set route table: %m");
} else {
r = sd_rtnl_message_route_set_table(req, RT_TABLE_UNSPEC);
if (r < 0)
return log_link_error_errno(link, r, "Could not set route table: %m");
/* Table attribute to allow more than 256. */
r = sd_netlink_message_append_data(req, RTA_TABLE, &route->table, sizeof(route->table));
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_TABLE attribute: %m");
}
/* Table attribute to allow more than 256. */
r = sd_netlink_message_append_data(req, RTA_TABLE, &route->table, sizeof(route->table));
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_TABLE attribute: %m");
}
if (!route_type_is_reject(route) && route->nexthop_id == 0) {

View File

@ -228,6 +228,14 @@ int local_gateways(
if (r < 0)
return r;
r = sd_rtnl_message_route_set_type(req, RTN_UNICAST);
if (r < 0)
return r;
r = sd_rtnl_message_route_set_table(req, RT_TABLE_MAIN);
if (r < 0)
return r;
r = sd_netlink_message_request_dump(req, true);
if (r < 0)
return r;