platform/trivial: s/ADDRROUTE/OBJECT/ for the cache lookup

It's going to be useful for other objects that have a type (of course)
and an ifindex.
This commit is contained in:
Lubomir Rintel
2017-11-23 15:41:57 +01:00
parent 18dd937b81
commit 93ac0e455b
11 changed files with 98 additions and 98 deletions

View File

@@ -3020,7 +3020,7 @@ _v4_has_shadowed_routes_detect (NMDevice *self)
platform = nm_device_get_platform (self);
head_entry = nm_platform_lookup (platform,
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP4_ROUTE,
ifindex));
if (!head_entry)

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2005 - 2014 Red Hat, Inc.
* Copyright (C) 2005 - 2017 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
@@ -611,7 +611,7 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
self = nm_ip4_config_new (multi_idx, ifindex);
priv = NM_IP4_CONFIG_GET_PRIVATE (self);
head_entry = nm_platform_lookup_addrroute (platform,
head_entry = nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP4_ADDRESS,
ifindex);
if (head_entry) {
@@ -636,7 +636,7 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
_notify_addresses (self);
}
head_entry = nm_platform_lookup_addrroute (platform,
head_entry = nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP4_ROUTE,
ifindex);

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2005 - 2013 Red Hat, Inc.
* Copyright (C) 2005 - 2017 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
@@ -395,7 +395,7 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
self = nm_ip6_config_new (multi_idx, ifindex);
priv = NM_IP6_CONFIG_GET_PRIVATE (self);
head_entry = nm_platform_lookup_addrroute (platform,
head_entry = nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP6_ADDRESS,
ifindex);
if (head_entry) {
@@ -420,7 +420,7 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
_notify_addresses (self);
}
head_entry = nm_platform_lookup_addrroute (platform,
head_entry = nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP6_ROUTE,
ifindex);

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 20122013 Red Hat, Inc.
* Copyright (C) 20122017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -1056,7 +1056,7 @@ ipx_address_delete (NMPlatform *platform,
peer_addr_i = peer_addr ? *((guint32 *) peer_addr) : 0;
nmp_cache_iter_for_each (&iter,
nm_platform_lookup_addrroute (platform,
nm_platform_lookup_object (platform,
addr_family == AF_INET
? NMP_OBJECT_TYPE_IP4_ADDRESS
: NMP_OBJECT_TYPE_IP6_ADDRESS,
@@ -1144,7 +1144,7 @@ ipx_route_delete (NMPlatform *platform,
}
nmp_cache_iter_for_each (&iter,
nm_platform_lookup_addrroute (platform,
nm_platform_lookup_object (platform,
obj_type,
ifindex),
&o) {
@@ -1254,7 +1254,7 @@ ip_route_add (NMPlatform *platform,
gboolean has_route_to_gw = FALSE;
nmp_cache_iter_for_each (&iter,
nm_platform_lookup_addrroute (platform,
nm_platform_lookup_object (platform,
NMP_OBJECT_GET_TYPE (obj),
0),
&o) {

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2012-2015 Red Hat, Inc.
* Copyright (C) 2012 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -5878,13 +5878,13 @@ link_can_assume (NMPlatform *platform, int ifindex)
if (link->link.master > 0)
return TRUE;
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP4_ADDRESS,
ifindex);
if (nmp_cache_lookup (cache, &lookup))
return TRUE;
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP6_ADDRESS,
ifindex);
nmp_cache_iter_for_each (&iter,

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2012 Red Hat, Inc.
* Copyright (C) 2012 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -3346,7 +3346,7 @@ delete_and_next:
}
plat_addresses = nm_platform_lookup_clone (self,
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP4_ADDRESS,
ifindex),
NULL, NULL);
@@ -3488,7 +3488,7 @@ nm_platform_ip6_address_sync (NMPlatform *self,
/* Delete unknown addresses */
plat_addresses = nm_platform_lookup_clone (self,
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP6_ADDRESS,
ifindex),
NULL, NULL);
@@ -3611,7 +3611,7 @@ nm_platform_ip_route_get_prune_list (NMPlatform *self,
NM_IP_ROUTE_TABLE_SYNC_MODE_FULL,
NM_IP_ROUTE_TABLE_SYNC_MODE_ALL));
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
addr_family == AF_INET
? NMP_OBJECT_TYPE_IP4_ROUTE
: NMP_OBJECT_TYPE_IP6_ROUTE,

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2015 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -186,7 +186,7 @@ _idx_obj_part (const DedupMultiIdxType *idx_type,
}
return 1;
case NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX:
case NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX:
if ( !NM_IN_SET (NMP_OBJECT_GET_TYPE (obj_a), NMP_OBJECT_TYPE_IP4_ADDRESS,
NMP_OBJECT_TYPE_IP6_ADDRESS,
NMP_OBJECT_TYPE_IP4_ROUTE,
@@ -1205,13 +1205,13 @@ static const guint8 _supported_cache_ids_link[] = {
static const guint8 _supported_cache_ids_ipx_address[] = {
NMP_CACHE_ID_TYPE_OBJECT_TYPE,
NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX,
NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX,
0,
};
static const guint8 _supported_cache_ids_ipx_route[] = {
NMP_CACHE_ID_TYPE_OBJECT_TYPE,
NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX,
NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX,
NMP_CACHE_ID_TYPE_DEFAULT_ROUTES,
NMP_CACHE_ID_TYPE_ROUTES_BY_WEAK_ID,
0,
@@ -1523,7 +1523,7 @@ nmp_lookup_init_link_by_ifname (NMPLookup *lookup,
}
const NMPLookup *
nmp_lookup_init_addrroute (NMPLookup *lookup,
nmp_lookup_init_object (NMPLookup *lookup,
NMPObjectType obj_type,
int ifindex)
{
@@ -1542,7 +1542,7 @@ nmp_lookup_init_addrroute (NMPLookup *lookup,
o = _nmp_object_stackinit_from_type (&lookup->selector_obj, obj_type);
o->object.ifindex = ifindex;
lookup->cache_id_type = NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX;
lookup->cache_id_type = NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX;
return _L (lookup);
}

View File

@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2015 - 2017 Red Hat, Inc.
*/
#ifndef __NMP_OBJECT_H__
@@ -48,12 +48,12 @@ typedef enum { /*< skip >*/
* but only route objects can be indexed by NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT.
*
* Of one index type, there can be multiple indexes or not.
* For example, of the index type NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX there
* For example, of the index type NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX there
* are multiple instances (for different route/addresses, v4/v6, per-ifindex).
*
* But one object, can only be indexed by one particular index of a
* type. For example, a certain address instance is only indexed by
* the index NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX with
* the index NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX with
* matching v4/v6 and ifindex -- or maybe not at all if it isn't visible.
* */
typedef enum { /*< skip >*/
@@ -82,8 +82,8 @@ typedef enum { /*< skip >*/
* separate for IPv4 and IPv6. */
NMP_CACHE_ID_TYPE_DEFAULT_ROUTES,
/* all the addresses/routes (by object-type) for an ifindex. */
NMP_CACHE_ID_TYPE_ADDRROUTE_BY_IFINDEX,
/* all the objects that have an ifindex (by object-type) for an ifindex. */
NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX,
/* Consider all the destination fields of a route, that is, the ID without the ifindex
* and gateway (meaning: network/plen,metric).
@@ -542,7 +542,7 @@ const NMPLookup *nmp_lookup_init_obj_type (NMPLookup *lookup,
NMPObjectType obj_type);
const NMPLookup *nmp_lookup_init_link_by_ifname (NMPLookup *lookup,
const char *ifname);
const NMPLookup *nmp_lookup_init_addrroute (NMPLookup *lookup,
const NMPLookup *nmp_lookup_init_object (NMPLookup *lookup,
NMPObjectType obj_type,
int ifindex);
const NMPLookup *nmp_lookup_init_route_default (NMPLookup *lookup,
@@ -723,18 +723,18 @@ nm_platform_lookup_link_by_ifname (NMPlatform *platform,
}
static inline const NMDedupMultiHeadEntry *
nm_platform_lookup_addrroute (NMPlatform *platform,
nm_platform_lookup_object (NMPlatform *platform,
NMPObjectType obj_type,
int ifindex)
{
NMPLookup lookup;
nmp_lookup_init_addrroute (&lookup, obj_type, ifindex);
nmp_lookup_init_object (&lookup, obj_type, ifindex);
return nm_platform_lookup (platform, &lookup);
}
static inline GPtrArray *
nm_platform_lookup_addrroute_clone (NMPlatform *platform,
nm_platform_lookup_object_clone (NMPlatform *platform,
NMPObjectType obj_type,
int ifindex,
NMPObjectPredicateFunc predicate,
@@ -742,7 +742,7 @@ nm_platform_lookup_addrroute_clone (NMPlatform *platform,
{
NMPLookup lookup;
nmp_lookup_init_addrroute (&lookup, obj_type, ifindex);
nmp_lookup_init_object (&lookup, obj_type, ifindex);
return nm_platform_lookup_clone (platform, &lookup, predicate, user_data);
}

View File

@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2016 Red Hat, Inc.
* Copyright 2016 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -77,7 +77,7 @@ _ipx_address_get_all (NMPlatform *self, int ifindex, NMPObjectType obj_type)
g_assert (NM_IS_PLATFORM (self));
g_assert (ifindex > 0);
g_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS));
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
obj_type,
ifindex);
return nmp_cache_lookup_to_array (nm_platform_lookup (self, &lookup),
@@ -107,7 +107,7 @@ nmtstp_platform_ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t n
nm_platform_process_events (platform);
nm_dedup_multi_iter_for_each (&iter,
nm_platform_lookup_addrroute (platform,
nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP4_ROUTE,
ifindex)) {
const NMPlatformIP4Route *r = NMP_OBJECT_CAST_IP4_ROUTE (iter.current->obj);
@@ -133,7 +133,7 @@ nmtstp_platform_ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_
nm_platform_process_events (platform);
nm_dedup_multi_iter_for_each (&iter,
nm_platform_lookup_addrroute (platform,
nm_platform_lookup_object (platform,
NMP_OBJECT_TYPE_IP6_ROUTE,
ifindex)) {
const NMPlatformIP6Route *r = NMP_OBJECT_CAST_IP6_ROUTE (iter.current->obj);

View File

@@ -245,7 +245,7 @@ static inline GPtrArray *
nmtstp_ip4_route_get_all (NMPlatform *platform,
int ifindex)
{
return nm_platform_lookup_addrroute_clone (platform,
return nm_platform_lookup_object_clone (platform,
NMP_OBJECT_TYPE_IP4_ROUTE,
ifindex,
nm_platform_lookup_predicate_routes_main_skip_rtprot_kernel,
@@ -256,7 +256,7 @@ static inline GPtrArray *
nmtstp_ip6_route_get_all (NMPlatform *platform,
int ifindex)
{
return nm_platform_lookup_addrroute_clone (platform,
return nm_platform_lookup_object_clone (platform,
NMP_OBJECT_TYPE_IP6_ROUTE,
ifindex,
nm_platform_lookup_predicate_routes_main_skip_rtprot_kernel,

View File

@@ -14,7 +14,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright 2016 Red Hat, Inc.
* Copyright 2016 - 2017 Red Hat, Inc.
*/
#include "nm-default.h"
@@ -47,7 +47,7 @@ _wait_for_ipv4_addr_device_route (NMPlatform *platform,
nmp_cache_iter_for_each (&iter,
nm_platform_lookup (platform,
nmp_lookup_init_addrroute (&lookup,
nmp_lookup_init_object (&lookup,
NMP_OBJECT_TYPE_IP4_ROUTE,
ifindex)),
&o) {