diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-24 23:49:51 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-05-25 01:26:00 +0200 |
commit | 3e0eeb8e33070616adf090acb656d97c716e00b3 (patch) | |
tree | 9e1d38203c5a8241c9fe0e5893c4423e6ef8c8fa /src | |
parent | sd-netlink: do not set action for RTM_GETRULE message (diff) | |
download | systemd-3e0eeb8e33070616adf090acb656d97c716e00b3.tar.xz systemd-3e0eeb8e33070616adf090acb656d97c716e00b3.zip |
sd-netlink: do not set route type and table by default for RTM_GETROUTE or friends
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-netlink/rtnl-message.c | 3 | ||||
-rw-r--r-- | src/network/networkd-route.c | 26 | ||||
-rw-r--r-- | src/shared/local-addresses.c | 8 |
3 files changed, 20 insertions, 17 deletions
diff --git a/src/libsystemd/sd-netlink/rtnl-message.c b/src/libsystemd/sd-netlink/rtnl-message.c index 5dba9c5734..e771b95e08 100644 --- a/src/libsystemd/sd-netlink/rtnl-message.c +++ b/src/libsystemd/sd-netlink/rtnl-message.c @@ -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; diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 257255d4e6..7d93825813 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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) { diff --git a/src/shared/local-addresses.c b/src/shared/local-addresses.c index f037c5281f..29ab9241e9 100644 --- a/src/shared/local-addresses.c +++ b/src/shared/local-addresses.c @@ -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; |