platform: fix lookup addresses and routes for any ifindex and refactor NMPCacheIdType
After refactoring platform, nm_platform_ipx_route_get_all() and
nm_platform_ipx_address_get_all() was broken for calling with a
non-posititive ifindex (which has the meaning: ignore ifindex).
While fixing that, also refactor the NMPCacheIdType so that it matches
better the supported id-types.
Fixes: 470bcefa5f
This commit is contained in:
@@ -1624,7 +1624,7 @@ cache_prune_candidates_record_all (NMPlatform *platform, ObjectType obj_type)
|
|||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
|
||||||
priv->prune_candidates = nmp_cache_lookup_all_to_hash (priv->cache,
|
priv->prune_candidates = nmp_cache_lookup_all_to_hash (priv->cache,
|
||||||
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, obj_type),
|
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, obj_type, FALSE),
|
||||||
priv->prune_candidates);
|
priv->prune_candidates);
|
||||||
_LOGT ("cache-prune: record %s (now %u candidates)", nmp_class_from_type (obj_type)->obj_type_name,
|
_LOGT ("cache-prune: record %s (now %u candidates)", nmp_class_from_type (obj_type)->obj_type_name,
|
||||||
priv->prune_candidates ? g_hash_table_size (priv->prune_candidates) : 0);
|
priv->prune_candidates ? g_hash_table_size (priv->prune_candidates) : 0);
|
||||||
@@ -2490,7 +2490,7 @@ link_get_all (NMPlatform *platform)
|
|||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
OBJECT_TYPE_LINK,
|
OBJECT_TYPE_LINK,
|
||||||
nmp_cache_id_init_links (NMP_CACHE_ID_STATIC, TRUE));
|
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, OBJECT_TYPE_LINK, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -4009,26 +4009,29 @@ link_get_driver_info (NMPlatform *platform,
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ipx_address_get_all (NMPlatform *platform, int ifindex, gboolean is_v4)
|
ipx_address_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
ObjectType obj_type = is_v4 ? OBJECT_TYPE_IP4_ADDRESS : OBJECT_TYPE_IP6_ADDRESS;
|
|
||||||
|
nm_assert (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ADDRESS, OBJECT_TYPE_IP6_ADDRESS));
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
obj_type,
|
obj_type,
|
||||||
nmp_cache_id_init_addrroute_by_ifindex (NMP_CACHE_ID_STATIC, obj_type, ifindex));
|
nmp_cache_id_init_addrroute_visible_by_ifindex (NMP_CACHE_ID_STATIC,
|
||||||
|
obj_type,
|
||||||
|
ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip4_address_get_all (NMPlatform *platform, int ifindex)
|
ip4_address_get_all (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return ipx_address_get_all (platform, ifindex, TRUE);
|
return ipx_address_get_all (platform, ifindex, OBJECT_TYPE_IP4_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_address_get_all (NMPlatform *platform, int ifindex)
|
ip6_address_get_all (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return ipx_address_get_all (platform, ifindex, FALSE);
|
return ipx_address_get_all (platform, ifindex, OBJECT_TYPE_IP6_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
||||||
@@ -4273,35 +4276,42 @@ check_for_route:
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ipx_route_get_all (NMPlatform *platform, int ifindex, gboolean is_v4, NMPlatformGetRouteMode mode)
|
ipx_route_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
NMPCacheIdType id_type;
|
gboolean with_default = FALSE, with_non_default = FALSE;
|
||||||
|
|
||||||
if (mode == NM_PLATFORM_GET_ROUTE_MODE_ALL)
|
nm_assert (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ROUTE, OBJECT_TYPE_IP6_ROUTE));
|
||||||
id_type = NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL;
|
|
||||||
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
if (mode == NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
||||||
id_type = NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT;
|
with_non_default = TRUE;
|
||||||
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT)
|
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT)
|
||||||
id_type = NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT;
|
with_default = TRUE;
|
||||||
else
|
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_ALL) {
|
||||||
|
with_non_default = TRUE;
|
||||||
|
with_default = TRUE;
|
||||||
|
} else
|
||||||
g_return_val_if_reached (NULL);
|
g_return_val_if_reached (NULL);
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
is_v4 ? OBJECT_TYPE_IP4_ROUTE : OBJECT_TYPE_IP6_ROUTE,
|
obj_type,
|
||||||
nmp_cache_id_init_routes_visible (NMP_CACHE_ID_STATIC, id_type, is_v4, ifindex));
|
nmp_cache_id_init_routes_visible (NMP_CACHE_ID_STATIC,
|
||||||
|
obj_type,
|
||||||
|
with_default,
|
||||||
|
with_non_default,
|
||||||
|
ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, TRUE, mode);
|
return ipx_route_get_all (platform, ifindex, OBJECT_TYPE_IP4_ROUTE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, FALSE, mode);
|
return ipx_route_get_all (platform, ifindex, OBJECT_TYPE_IP6_ROUTE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -873,8 +873,8 @@ nmp_cache_id_destroy (NMPCacheId *id)
|
|||||||
|
|
||||||
NMPCacheId _nmp_cache_id_static;
|
NMPCacheId _nmp_cache_id_static;
|
||||||
|
|
||||||
NMPCacheId *
|
static NMPCacheId *
|
||||||
nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
_nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
||||||
{
|
{
|
||||||
memset (id, 0, sizeof (NMPCacheId));
|
memset (id, 0, sizeof (NMPCacheId));
|
||||||
id->_id_type = id_type;
|
id->_id_type = id_type;
|
||||||
@@ -882,38 +882,57 @@ nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type)
|
nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type, gboolean visible_only)
|
||||||
{
|
{
|
||||||
nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_OBJECT_TYPE);
|
_nmp_cache_id_init (id, visible_only
|
||||||
|
? NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY
|
||||||
|
: NMP_CACHE_ID_TYPE_OBJECT_TYPE);
|
||||||
id->object_type.obj_type = obj_type;
|
id->object_type.obj_type = obj_type;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_links (NMPCacheId *id, gboolean visible_only)
|
nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id,
|
||||||
|
ObjectType obj_type,
|
||||||
|
int ifindex)
|
||||||
{
|
{
|
||||||
if (visible_only)
|
g_return_val_if_fail (NM_IN_SET (obj_type,
|
||||||
return nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY);
|
OBJECT_TYPE_IP4_ADDRESS, OBJECT_TYPE_IP4_ROUTE,
|
||||||
else
|
OBJECT_TYPE_IP6_ADDRESS, OBJECT_TYPE_IP6_ROUTE), NULL);
|
||||||
return nmp_cache_id_init_object_type (id, OBJECT_TYPE_LINK);
|
|
||||||
}
|
|
||||||
|
|
||||||
NMPCacheId *
|
if (ifindex <= 0)
|
||||||
nmp_cache_id_init_addrroute_by_ifindex (NMPCacheId *id, ObjectType obj_type, int ifindex)
|
return nmp_cache_id_init_object_type (id, obj_type, TRUE);
|
||||||
{
|
|
||||||
nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX);
|
_nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX);
|
||||||
id->addrroute_by_ifindex.obj_type = obj_type;
|
id->object_type_by_ifindex.obj_type = obj_type;
|
||||||
id->addrroute_by_ifindex.ifindex = ifindex;
|
id->object_type_by_ifindex.ifindex = ifindex;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_routes_visible (NMPCacheId *id, NMPCacheIdType id_type, gboolean is_v4, int ifindex)
|
nmp_cache_id_init_routes_visible (NMPCacheId *id,
|
||||||
|
ObjectType obj_type,
|
||||||
|
gboolean with_default,
|
||||||
|
gboolean with_non_default,
|
||||||
|
int ifindex)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IN_SET (id_type, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT), NULL);
|
g_return_val_if_fail (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ROUTE, OBJECT_TYPE_IP6_ROUTE), NULL);
|
||||||
nmp_cache_id_init (id, id_type);
|
|
||||||
id->routes_visible.is_v4 = !!is_v4;
|
if (with_default && with_non_default) {
|
||||||
id->routes_visible.ifindex = ifindex;
|
if (ifindex <= 0)
|
||||||
|
return nmp_cache_id_init_object_type (id, obj_type, TRUE);
|
||||||
|
return nmp_cache_id_init_addrroute_visible_by_ifindex (id, obj_type, ifindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (with_default)
|
||||||
|
_nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT);
|
||||||
|
else if (with_non_default)
|
||||||
|
_nmp_cache_id_init (id, NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT);
|
||||||
|
else
|
||||||
|
g_return_val_if_reached (NULL);
|
||||||
|
|
||||||
|
id->object_type_by_ifindex.obj_type = obj_type;
|
||||||
|
id->object_type_by_ifindex.ifindex = ifindex;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,37 +943,35 @@ _nmp_object_init_cache_id (const NMPObject *obj, NMPCacheIdType id_type, NMPCach
|
|||||||
{
|
{
|
||||||
const NMPClass *klass = NMP_OBJECT_GET_CLASS (obj);
|
const NMPClass *klass = NMP_OBJECT_GET_CLASS (obj);
|
||||||
|
|
||||||
if (id_type == NMP_CACHE_ID_TYPE_OBJECT_TYPE) {
|
switch (id_type) {
|
||||||
*out_id = nmp_cache_id_init_object_type (id, klass->obj_type);
|
case NMP_CACHE_ID_TYPE_OBJECT_TYPE:
|
||||||
|
*out_id = nmp_cache_id_init_object_type (id, klass->obj_type, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
case NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY:
|
||||||
|
if (nmp_object_is_visible (obj))
|
||||||
|
*out_id = nmp_cache_id_init_object_type (id, klass->obj_type, TRUE);
|
||||||
|
else
|
||||||
|
*out_id = NULL;
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
return klass->cmd_obj_init_cache_id (obj, id_type, id, out_id);
|
||||||
}
|
}
|
||||||
return klass->cmd_obj_init_cache_id (obj, id_type, id, out_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_vt_cmd_obj_init_cache_id_link (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
_vt_cmd_obj_init_cache_id_link (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
||||||
{
|
{
|
||||||
switch (id_type) {
|
return FALSE;
|
||||||
case NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY:
|
|
||||||
if (_vt_cmd_obj_is_visible_link (obj)) {
|
|
||||||
*out_id = nmp_cache_id_init_links (id, TRUE);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*out_id = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_vt_cmd_obj_init_cache_id_ip4_address (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
_vt_cmd_obj_init_cache_id_ipx_address (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
||||||
{
|
{
|
||||||
switch (id_type) {
|
switch (id_type) {
|
||||||
case NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX:
|
case NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX:
|
||||||
if (_vt_cmd_obj_is_visible_ipx_address (obj)) {
|
if (_vt_cmd_obj_is_visible_ipx_address (obj)) {
|
||||||
*out_id = nmp_cache_id_init_addrroute_by_ifindex (id, OBJECT_TYPE_IP4_ADDRESS, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
|
*out_id = nmp_cache_id_init_addrroute_visible_by_ifindex (id, NMP_OBJECT_GET_TYPE (obj), obj->object.ifindex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -966,83 +983,45 @@ _vt_cmd_obj_init_cache_id_ip4_address (const NMPObject *obj, NMPCacheIdType id_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_vt_cmd_obj_init_cache_id_ip6_address (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
_vt_cmd_obj_init_cache_id_ipx_route (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
||||||
{
|
{
|
||||||
switch (id_type) {
|
switch (id_type) {
|
||||||
case NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX:
|
case NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX:
|
||||||
if (_vt_cmd_obj_is_visible_ipx_address (obj)) {
|
|
||||||
*out_id = nmp_cache_id_init_addrroute_by_ifindex (id, OBJECT_TYPE_IP6_ADDRESS, obj->object.ifindex);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*out_id = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_vt_cmd_obj_init_cache_id_ip4_route (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
|
||||||
{
|
|
||||||
switch (id_type) {
|
|
||||||
case NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX:
|
|
||||||
if (_vt_cmd_obj_is_visible_ipx_route (obj)) {
|
if (_vt_cmd_obj_is_visible_ipx_route (obj)) {
|
||||||
*out_id = nmp_cache_id_init_addrroute_by_ifindex (id, OBJECT_TYPE_IP4_ROUTE, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
return TRUE;
|
*out_id = nmp_cache_id_init_addrroute_visible_by_ifindex (id, NMP_OBJECT_GET_TYPE (obj), obj->object.ifindex);
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL:
|
|
||||||
if (_vt_cmd_obj_is_visible_ipx_route (obj)) {
|
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, TRUE, obj->object.ifindex);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT:
|
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT:
|
||||||
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
||||||
&& !NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
&& !NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, TRUE, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
|
*out_id = nmp_cache_id_init_routes_visible (id, NMP_OBJECT_GET_TYPE (obj), FALSE, TRUE, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT:
|
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT:
|
||||||
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
||||||
&& NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
&& NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, TRUE, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
|
*out_id = nmp_cache_id_init_routes_visible (id, NMP_OBJECT_GET_TYPE (obj), TRUE, FALSE, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT:
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*out_id = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_vt_cmd_obj_init_cache_id_ip6_route (const NMPObject *obj, NMPCacheIdType id_type, NMPCacheId *id, const NMPCacheId **out_id)
|
|
||||||
{
|
|
||||||
switch (id_type) {
|
|
||||||
case NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX:
|
|
||||||
*out_id = nmp_cache_id_init_addrroute_by_ifindex (id, OBJECT_TYPE_IP6_ROUTE, obj->object.ifindex);
|
|
||||||
return TRUE;
|
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL:
|
|
||||||
if (_vt_cmd_obj_is_visible_ipx_route (obj)) {
|
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, FALSE, obj->object.ifindex);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT:
|
|
||||||
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
||||||
&& !NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
&& !NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, FALSE, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
|
*out_id = nmp_cache_id_init_routes_visible (id, NMP_OBJECT_GET_TYPE (obj), FALSE, TRUE, obj->object.ifindex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT:
|
case NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT:
|
||||||
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
if ( _vt_cmd_obj_is_visible_ipx_route (obj)
|
||||||
&& NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
&& NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&obj->ip_route)) {
|
||||||
*out_id = nmp_cache_id_init_routes_visible (id, id_type, FALSE, obj->object.ifindex);
|
nm_assert (obj->object.ifindex > 0);
|
||||||
|
*out_id = nmp_cache_id_init_routes_visible (id, NMP_OBJECT_GET_TYPE (obj), TRUE, FALSE, obj->object.ifindex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1134,7 +1113,7 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m
|
|||||||
&& potential_slave->link.connected) {
|
&& potential_slave->link.connected) {
|
||||||
is_lower_up = TRUE;
|
is_lower_up = TRUE;
|
||||||
} else {
|
} else {
|
||||||
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_links (NMP_CACHE_ID_STATIC, FALSE), &len);
|
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, OBJECT_TYPE_LINK, FALSE), &len);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const NMPlatformLink *link = links[i];
|
const NMPlatformLink *link = links[i];
|
||||||
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
||||||
@@ -1261,12 +1240,10 @@ nmp_cache_lookup_link_full (const NMPCache *cache,
|
|||||||
} else if (!ifname && !match_fn)
|
} else if (!ifname && !match_fn)
|
||||||
return NULL;
|
return NULL;
|
||||||
else {
|
else {
|
||||||
list = nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, OBJECT_TYPE_LINK), &len);
|
list = nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, OBJECT_TYPE_LINK, visible_only), &len);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
obj = NMP_OBJECT_UP_CAST (list[i]);
|
obj = NMP_OBJECT_UP_CAST (list[i]);
|
||||||
|
|
||||||
if (visible_only && !nmp_object_is_visible (obj))
|
|
||||||
continue;
|
|
||||||
if (link_type != NM_LINK_TYPE_NONE && obj->link.type != link_type)
|
if (link_type != NM_LINK_TYPE_NONE && obj->link.type != link_type)
|
||||||
continue;
|
continue;
|
||||||
if (ifname && strcmp (ifname, obj->link.name))
|
if (ifname && strcmp (ifname, obj->link.name))
|
||||||
@@ -1850,7 +1827,7 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.addr_family = AF_INET,
|
.addr_family = AF_INET,
|
||||||
.rtm_gettype = RTM_GETADDR,
|
.rtm_gettype = RTM_GETADDR,
|
||||||
.signal_type = NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED,
|
.signal_type = NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED,
|
||||||
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ip4_address,
|
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ipx_address,
|
||||||
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
||||||
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
||||||
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip4_address,
|
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip4_address,
|
||||||
@@ -1874,7 +1851,7 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.addr_family = AF_INET6,
|
.addr_family = AF_INET6,
|
||||||
.rtm_gettype = RTM_GETADDR,
|
.rtm_gettype = RTM_GETADDR,
|
||||||
.signal_type = NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED,
|
.signal_type = NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED,
|
||||||
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ip6_address,
|
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ipx_address,
|
||||||
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
||||||
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
||||||
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip6_address,
|
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip6_address,
|
||||||
@@ -1898,7 +1875,7 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.addr_family = AF_INET,
|
.addr_family = AF_INET,
|
||||||
.rtm_gettype = RTM_GETROUTE,
|
.rtm_gettype = RTM_GETROUTE,
|
||||||
.signal_type = NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED,
|
.signal_type = NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED,
|
||||||
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ip4_route,
|
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ipx_route,
|
||||||
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
||||||
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
||||||
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip4_route,
|
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip4_route,
|
||||||
@@ -1922,7 +1899,7 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.addr_family = AF_INET6,
|
.addr_family = AF_INET6,
|
||||||
.rtm_gettype = RTM_GETROUTE,
|
.rtm_gettype = RTM_GETROUTE,
|
||||||
.signal_type = NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED,
|
.signal_type = NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED,
|
||||||
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ip6_route,
|
.cmd_obj_init_cache_id = _vt_cmd_obj_init_cache_id_ipx_route,
|
||||||
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
.cmd_obj_equal = _vt_cmd_obj_equal_plain,
|
||||||
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
.cmd_obj_copy = _vt_cmd_obj_copy_plain,
|
||||||
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip6_route,
|
.cmd_obj_stackinit_id = _vt_cmd_obj_stackinit_id_ip6_route,
|
||||||
|
@@ -60,33 +60,35 @@ typedef enum { /*< skip >*/
|
|||||||
* An object of a certain object-type, can be candidate to being
|
* An object of a certain object-type, can be candidate to being
|
||||||
* indexed by a certain NMPCacheIdType or not. For example, all
|
* indexed by a certain NMPCacheIdType or not. For example, all
|
||||||
* objects are indexed via an index of type NMP_CACHE_ID_TYPE_OBJECT_TYPE,
|
* objects are indexed via an index of type NMP_CACHE_ID_TYPE_OBJECT_TYPE,
|
||||||
* but only route objects are indexed by NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL.
|
* but only route objects can be indexed by NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT.
|
||||||
*
|
*
|
||||||
* Of one index type, there can be different indexes or not.
|
* Of one index type, there can be multiple indexes or not.
|
||||||
* For example, there is only one single instance of
|
* For example, of the index type NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX there
|
||||||
* NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY, because this instance is
|
* are multiple instances (for different route/addresses, v4/v6, per-ifindex).
|
||||||
* applicable for all link objects.
|
|
||||||
* But there are different instances of NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX
|
|
||||||
* type index, which differ in v4/v6, the ifindex, and whether the index
|
|
||||||
* is for routes or address instances.
|
|
||||||
*
|
*
|
||||||
* But one object, can only be indexed by one particular index of one
|
* But one object, can only be indexed by one particular index of a
|
||||||
* type. For example, a certain address instance is only indexed by
|
* type. For example, a certain address instance is only indexed by
|
||||||
* the index NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX with matching v4/v6
|
* the index NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX with
|
||||||
* and ifindex.
|
* matching v4/v6 and ifindex -- or maybe not at all if it isn't visible.
|
||||||
* */
|
* */
|
||||||
typedef enum { /*< skip >*/
|
typedef enum { /*< skip >*/
|
||||||
|
/* all the objects of a certain type */
|
||||||
NMP_CACHE_ID_TYPE_OBJECT_TYPE,
|
NMP_CACHE_ID_TYPE_OBJECT_TYPE,
|
||||||
|
|
||||||
NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY,
|
/* all the visible objects of a certain type */
|
||||||
|
NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY,
|
||||||
|
|
||||||
NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX,
|
/* indeces for the visible routes, ignoring ifindex. */
|
||||||
|
|
||||||
/* three indeces for the visibile routes. */
|
|
||||||
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL,
|
|
||||||
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT,
|
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT,
|
||||||
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT,
|
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT,
|
||||||
|
|
||||||
|
/* all the visible addresses/routes (by object-type) for an ifindex. */
|
||||||
|
NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX,
|
||||||
|
|
||||||
|
/* three indeces for the visible routes, per ifindex. */
|
||||||
|
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT,
|
||||||
|
NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT,
|
||||||
|
|
||||||
__NMP_CACHE_ID_TYPE_MAX,
|
__NMP_CACHE_ID_TYPE_MAX,
|
||||||
NMP_CACHE_ID_TYPE_MAX = __NMP_CACHE_ID_TYPE_MAX - 1,
|
NMP_CACHE_ID_TYPE_MAX = __NMP_CACHE_ID_TYPE_MAX - 1,
|
||||||
} NMPCacheIdType;
|
} NMPCacheIdType;
|
||||||
@@ -99,31 +101,20 @@ typedef struct {
|
|||||||
guint8 _id_type; /* NMPCacheIdType as guint8 */
|
guint8 _id_type; /* NMPCacheIdType as guint8 */
|
||||||
struct {
|
struct {
|
||||||
/* NMP_CACHE_ID_TYPE_OBJECT_TYPE */
|
/* NMP_CACHE_ID_TYPE_OBJECT_TYPE */
|
||||||
|
/* NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY */
|
||||||
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT */
|
||||||
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT */
|
||||||
guint8 _id_type;
|
guint8 _id_type;
|
||||||
guint8 obj_type; /* ObjectType as guint8 */
|
guint8 obj_type; /* ObjectType as guint8 */
|
||||||
} object_type;
|
} object_type;
|
||||||
struct {
|
struct {
|
||||||
/* NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY */
|
/* NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX */
|
||||||
guint8 _id_type;
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT */
|
||||||
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT */
|
||||||
/* the @_global_id is only defined by it's type and has no arguments.
|
|
||||||
* It is used by NMP_CACHE_ID_TYPE_LINKS_VISIBLE_ONLY. There is only
|
|
||||||
* one single occurence of an index of this type. */
|
|
||||||
} _global_id;
|
|
||||||
struct {
|
|
||||||
/* NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX */
|
|
||||||
guint8 _id_type;
|
guint8 _id_type;
|
||||||
guint8 obj_type; /* ObjectType as guint8 */
|
guint8 obj_type; /* ObjectType as guint8 */
|
||||||
int ifindex;
|
int ifindex;
|
||||||
} addrroute_by_ifindex;
|
} object_type_by_ifindex;
|
||||||
struct {
|
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ALL */
|
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT */
|
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT */
|
|
||||||
guint8 _id_type;
|
|
||||||
guint8 is_v4;
|
|
||||||
int ifindex;
|
|
||||||
} routes_visible;
|
|
||||||
};
|
};
|
||||||
} NMPCacheId;
|
} NMPCacheId;
|
||||||
|
|
||||||
@@ -323,11 +314,9 @@ guint nmp_cache_id_hash (const NMPCacheId *id);
|
|||||||
NMPCacheId *nmp_cache_id_clone (const NMPCacheId *id);
|
NMPCacheId *nmp_cache_id_clone (const NMPCacheId *id);
|
||||||
void nmp_cache_id_destroy (NMPCacheId *id);
|
void nmp_cache_id_destroy (NMPCacheId *id);
|
||||||
|
|
||||||
NMPCacheId *nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type);
|
NMPCacheId *nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type, gboolean visible_only);
|
||||||
NMPCacheId *nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type);
|
NMPCacheId *nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id, ObjectType obj_type, int ifindex);
|
||||||
NMPCacheId *nmp_cache_id_init_links (NMPCacheId *id, gboolean visible_only);
|
NMPCacheId *nmp_cache_id_init_routes_visible (NMPCacheId *id, ObjectType obj_type, gboolean with_default, gboolean with_non_default, int ifindex);
|
||||||
NMPCacheId *nmp_cache_id_init_addrroute_by_ifindex (NMPCacheId *id, ObjectType obj_type, int ifindex);
|
|
||||||
NMPCacheId *nmp_cache_id_init_routes_visible (NMPCacheId *id, NMPCacheIdType id_type, gboolean is_v4, int ifindex);
|
|
||||||
|
|
||||||
const NMPlatformObject *const *nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint *out_len);
|
const NMPlatformObject *const *nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint *out_len);
|
||||||
GArray *nmp_cache_lookup_multi_to_array (const NMPCache *cache, ObjectType obj_type, const NMPCacheId *cache_id);
|
GArray *nmp_cache_lookup_multi_to_array (const NMPCache *cache, ObjectType obj_type, const NMPCacheId *cache_id);
|
||||||
|
@@ -250,8 +250,8 @@ test_cache_link ()
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
@@ -290,8 +290,8 @@ test_cache_link ()
|
|||||||
g_assert (!was_visible);
|
g_assert (!was_visible);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,8 +306,8 @@ test_cache_link ()
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
@@ -323,8 +323,8 @@ test_cache_link ()
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
} else {
|
} else {
|
||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == NULL);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == NULL);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == NULL);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == NULL);
|
||||||
@@ -343,8 +343,8 @@ test_cache_link ()
|
|||||||
g_assert (!was_visible);
|
g_assert (!was_visible);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, FALSE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, FALSE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, FALSE);
|
g_assert_cmpint (obj2->link.initialized, ==, FALSE);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
@@ -361,8 +361,8 @@ test_cache_link ()
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, TRUE);
|
g_assert_cmpint (obj2->link.initialized, ==, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
@@ -375,8 +375,8 @@ test_cache_link ()
|
|||||||
g_assert (was_visible);
|
g_assert (was_visible);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_links (&cache_id_storage, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, !nmp_cache_use_udev_get (cache));
|
g_assert_cmpint (obj2->link.initialized, ==, !nmp_cache_use_udev_get (cache));
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
Reference in New Issue
Block a user