diff options
author | Thomas Haller <thaller@redhat.com> | 2017-04-13 18:47:18 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-04-15 00:35:25 +0200 |
commit | 11d8c41898e43236476dd5f5f26736e2a3fdbea5 (patch) | |
tree | 0d12ed272475d1a07a410ac3e7c04b31639a4dad | |
parent | 6e67f7f30bb68733f7d1ec65aa64b6d72f064a49 (diff) | |
download | NetworkManager-11d8c41898e43236476dd5f5f26736e2a3fdbea5.tar.gz |
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.
-rw-r--r-- | src/platform/nm-linux-platform.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 7369aaf045..c3af263040 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -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, 0, AF_INET6, |