diff --git a/src/nm-types.h b/src/nm-types.h index 997723e60..db0b944e0 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -56,9 +56,6 @@ typedef enum { /* In priority order; higher number == higher priority */ NM_IP_CONFIG_SOURCE_UNKNOWN, - /* platform internal flag used to mark routes with RTM_F_CLONED. */ - _NM_IP_CONFIG_SOURCE_RTM_F_CLONED, - /* routes from platform with protocol RTPROT_KERNEL. */ NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 5d32a95be..c50518c8a 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1882,9 +1882,10 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only) * * This happens, because this route is not nmp_object_is_alive(). * */ - obj->ip_route.rt_source = _NM_IP_CONFIG_SOURCE_RTM_F_CLONED; - } else - obj->ip_route.rt_source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol); + obj->ip_route.rt_cloned = TRUE; + } + + obj->ip_route.rt_source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol); obj_result = obj; obj = NULL; diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 7b7829539..36fe69938 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -475,7 +475,6 @@ nmp_utils_ip_config_source_from_rtprot (guint rtprot) NM_UTILS_ENUM2STR_DEFINE (nmp_utils_ip_config_source_to_string, NMIPConfigSource, NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_UNKNOWN, "unknown"), NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, "rtprot-kernel"), - NM_UTILS_ENUM2STR (_NM_IP_CONFIG_SOURCE_RTM_F_CLONED, "rtm-f-cloned"), NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_KERNEL, "kernel"), NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_SHARED, "shared"), NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_IP4LL, "ipv4ll"), diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index abf1125d2..b6aae3495 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -3642,6 +3642,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi " metric %"G_GUINT32_FORMAT " mss %"G_GUINT32_FORMAT " src %s" /* source */ + "%s" /* cloned */ "%s%s" /* scope */ "%s%s" /* pref-src */ "", @@ -3652,6 +3653,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi route->metric, route->mss, nmp_utils_ip_config_source_to_string (route->rt_source, s_source, sizeof (s_source)), + route->rt_cloned ? " cloned" : "", route->scope_inv ? " scope " : "", route->scope_inv ? (nm_platform_route_scope2str (nm_platform_route_scope_inv (route->scope_inv), str_scope, sizeof (str_scope))) : "", route->pref_src ? " pref-src " : "", @@ -3692,6 +3694,7 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi " metric %"G_GUINT32_FORMAT " mss %"G_GUINT32_FORMAT " src %s" /* source */ + "%s" /* cloned */ "", s_network, route->plen, @@ -3699,7 +3702,8 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi str_dev, route->metric, route->mss, - nmp_utils_ip_config_source_to_string (route->rt_source, s_source, sizeof (s_source))); + nmp_utils_ip_config_source_to_string (route->rt_source, s_source, sizeof (s_source)), + route->rt_cloned ? " cloned" : ""); return buf; } @@ -3968,6 +3972,7 @@ nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route _CMP_FIELD (a, b, mss); _CMP_FIELD (a, b, scope_inv); _CMP_FIELD (a, b, pref_src); + _CMP_FIELD (a, b, rt_cloned); return 0; } @@ -3982,6 +3987,7 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route _CMP_FIELD_MEMCMP (a, b, gateway); _CMP_FIELD (a, b, metric); _CMP_FIELD (a, b, mss); + _CMP_FIELD (a, b, rt_cloned); return 0; } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 385aacf46..aad20b66d 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -305,6 +305,13 @@ typedef union { __NMPlatformObject_COMMON; \ NMIPConfigSource rt_source; \ guint8 plen; \ + \ + /* the route has rtm_flags set to RTM_F_CLONED. Such a route + * is hidden by platform and does not exist from the point-of-view + * of platform users. This flag is internal to track those hidden + * routes. Such a route is not alive, according to nmp_object_is_alive(). */ \ + bool rt_cloned:1; \ + \ guint32 metric; \ guint32 mss; \ ; diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index e37ea33ec..55ffd7cff 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -915,12 +915,12 @@ _vt_cmd_obj_is_alive_ipx_route (const NMPObject *obj) * * If nmp_object_from_nl() would just return NULL, we couldn't look * into the cache to see if it contains a route that now disappears - * (because it is cloned). + * (because it changed to be cloned). * * Instead we create a dead object, and nmp_cache_update_netlink() * will remove the old version of the update. **/ - return obj->object.ifindex > 0 && (obj->ip_route.rt_source != _NM_IP_CONFIG_SOURCE_RTM_F_CLONED); + return obj->object.ifindex > 0 && !obj->ip_route.rt_cloned; } gboolean