platform: refactor marking cloned routes in platform
We handle cloned routes (that have rtm_flags RTM_F_CLONED) differently. We used to mark such routes by hacking NMIPConfigSource to have a special value. No longer do this, because it mixes different concepts. Note that the rt_cloned filed fits into a hole in the aligment of NMPlatformIPRoute. Thus there is almost no overhead to this change.
This commit is contained in:
@@ -56,9 +56,6 @@ typedef enum {
|
|||||||
/* In priority order; higher number == higher priority */
|
/* In priority order; higher number == higher priority */
|
||||||
NM_IP_CONFIG_SOURCE_UNKNOWN,
|
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. */
|
/* routes from platform with protocol RTPROT_KERNEL. */
|
||||||
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL,
|
NM_IP_CONFIG_SOURCE_RTPROT_KERNEL,
|
||||||
|
|
||||||
|
@@ -1882,8 +1882,9 @@ _new_from_nl_route (struct nlmsghdr *nlh, gboolean id_only)
|
|||||||
*
|
*
|
||||||
* This happens, because this route is not nmp_object_is_alive().
|
* This happens, because this route is not nmp_object_is_alive().
|
||||||
* */
|
* */
|
||||||
obj->ip_route.rt_source = _NM_IP_CONFIG_SOURCE_RTM_F_CLONED;
|
obj->ip_route.rt_cloned = TRUE;
|
||||||
} else
|
}
|
||||||
|
|
||||||
obj->ip_route.rt_source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol);
|
obj->ip_route.rt_source = nmp_utils_ip_config_source_from_rtprot (rtm->rtm_protocol);
|
||||||
|
|
||||||
obj_result = obj;
|
obj_result = obj;
|
||||||
|
@@ -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_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_UNKNOWN, "unknown"),
|
||||||
NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_RTPROT_KERNEL, "rtprot-kernel"),
|
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_KERNEL, "kernel"),
|
||||||
NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_SHARED, "shared"),
|
NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_SHARED, "shared"),
|
||||||
NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_IP4LL, "ipv4ll"),
|
NM_UTILS_ENUM2STR (NM_IP_CONFIG_SOURCE_IP4LL, "ipv4ll"),
|
||||||
|
@@ -3642,6 +3642,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi
|
|||||||
" metric %"G_GUINT32_FORMAT
|
" metric %"G_GUINT32_FORMAT
|
||||||
" mss %"G_GUINT32_FORMAT
|
" mss %"G_GUINT32_FORMAT
|
||||||
" src %s" /* source */
|
" src %s" /* source */
|
||||||
|
"%s" /* cloned */
|
||||||
"%s%s" /* scope */
|
"%s%s" /* scope */
|
||||||
"%s%s" /* pref-src */
|
"%s%s" /* pref-src */
|
||||||
"",
|
"",
|
||||||
@@ -3652,6 +3653,7 @@ nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route, char *buf, gsi
|
|||||||
route->metric,
|
route->metric,
|
||||||
route->mss,
|
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" : "",
|
||||||
route->scope_inv ? " scope " : "",
|
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->scope_inv ? (nm_platform_route_scope2str (nm_platform_route_scope_inv (route->scope_inv), str_scope, sizeof (str_scope))) : "",
|
||||||
route->pref_src ? " pref-src " : "",
|
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
|
" metric %"G_GUINT32_FORMAT
|
||||||
" mss %"G_GUINT32_FORMAT
|
" mss %"G_GUINT32_FORMAT
|
||||||
" src %s" /* source */
|
" src %s" /* source */
|
||||||
|
"%s" /* cloned */
|
||||||
"",
|
"",
|
||||||
s_network,
|
s_network,
|
||||||
route->plen,
|
route->plen,
|
||||||
@@ -3699,7 +3702,8 @@ nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route, char *buf, gsi
|
|||||||
str_dev,
|
str_dev,
|
||||||
route->metric,
|
route->metric,
|
||||||
route->mss,
|
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;
|
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, mss);
|
||||||
_CMP_FIELD (a, b, scope_inv);
|
_CMP_FIELD (a, b, scope_inv);
|
||||||
_CMP_FIELD (a, b, pref_src);
|
_CMP_FIELD (a, b, pref_src);
|
||||||
|
_CMP_FIELD (a, b, rt_cloned);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3982,6 +3987,7 @@ nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route
|
|||||||
_CMP_FIELD_MEMCMP (a, b, gateway);
|
_CMP_FIELD_MEMCMP (a, b, gateway);
|
||||||
_CMP_FIELD (a, b, metric);
|
_CMP_FIELD (a, b, metric);
|
||||||
_CMP_FIELD (a, b, mss);
|
_CMP_FIELD (a, b, mss);
|
||||||
|
_CMP_FIELD (a, b, rt_cloned);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -305,6 +305,13 @@ typedef union {
|
|||||||
__NMPlatformObject_COMMON; \
|
__NMPlatformObject_COMMON; \
|
||||||
NMIPConfigSource rt_source; \
|
NMIPConfigSource rt_source; \
|
||||||
guint8 plen; \
|
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 metric; \
|
||||||
guint32 mss; \
|
guint32 mss; \
|
||||||
;
|
;
|
||||||
|
@@ -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
|
* 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
|
* 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()
|
* Instead we create a dead object, and nmp_cache_update_netlink()
|
||||||
* will remove the old version of the update.
|
* 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
|
gboolean
|
||||||
|
Reference in New Issue
Block a user