Commit 11d8c418 authored by Thomas Haller's avatar Thomas Haller

platform: cleanup possibly non-zero host part for route operations

Platform's add/remove operations accept a "network" argument.
Kernel requires that the host part (based on plen) is all zero.
For NetworkManager we are more resilient to user configuration.

Cleanup the input argument already before calling _nl_msg_new_route().
Note that we use the same "network" argument to construct a obj_id
instance and to find the route in the cache (do_add_addrroute()).
Without cleaning the host part, the added object cannot be found
and the add-route command seemingly fails.
parent 6e67f7f3
......@@ -2416,7 +2416,6 @@ _nl_msg_new_route (int nlmsg_type,
.rtm_dst_len = plen,
.rtm_src_len = src ? src_plen : 0,
NMIPAddr network_clean;
gsize addr_len;
......@@ -2433,8 +2432,7 @@ _nl_msg_new_route (int nlmsg_type,
addr_len = family == AF_INET ? sizeof (in_addr_t) : sizeof (struct in6_addr);
nm_utils_ipx_address_clear_host_address (family, &network_clean, network, plen);
NLA_PUT (msg, RTA_DST, addr_len, &network_clean);
NLA_PUT (msg, RTA_DST, addr_len, network);
if (src)
NLA_PUT (msg, RTA_SRC, addr_len, src);
......@@ -6030,6 +6028,8 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, guint8 p
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
NMPObject obj_id;
network = nm_utils_ip4_address_clear_host_address (network, plen);
nmp_object_stackinit_id_ip4_route (&obj_id, ifindex, network, plen, metric);
if (metric == 0) {
......@@ -6096,6 +6096,8 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, gu
metric = nm_utils_ip6_route_metric_normalize (metric);
nm_utils_ip6_address_clear_host_address (&network, &network, plen);
nlmsg = _nl_msg_new_route (RTM_DELROUTE,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment