summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/devices/nm-device.c40
-rw-r--r--src/core/nm-l3cfg.c36
-rw-r--r--src/core/nm-l3cfg.h16
-rw-r--r--src/core/nm-netns.c46
-rw-r--r--src/core/nm-netns.h2
-rw-r--r--src/core/platform/tests/test-route.c64
-rw-r--r--src/libnm-platform/nmp-route-manager.c240
-rw-r--r--src/libnm-platform/nmp-route-manager.h100
8 files changed, 274 insertions, 270 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index 8c58453b55..915c40eea0 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -9491,13 +9491,13 @@ lldp_setup(NMDevice *self, NMTernary enabled)
static void
_routing_rules_sync(NMDevice *self, NMTernary set_mode)
{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
- NMPRouteManager *route_manager = nm_netns_get_route_manager(nm_device_get_netns(self));
- NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self);
- gboolean untrack_only_dirty = FALSE;
- gboolean keep_deleted_rules;
- gpointer user_tag_1;
- gpointer user_tag_2;
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
+ NMPGlobalTracker *global_tracker = nm_netns_get_global_tracker(nm_device_get_netns(self));
+ NMDeviceClass *klass = NM_DEVICE_GET_CLASS(self);
+ gboolean untrack_only_dirty = FALSE;
+ gboolean keep_deleted_rules;
+ gpointer user_tag_1;
+ gpointer user_tag_2;
/* take two arbitrary user-tag pointers that belong to @self. */
user_tag_1 = &priv->v4_route_table;
@@ -9529,13 +9529,13 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode)
nm_ip_routing_rule_to_platform(rule, &plrule);
/* We track this rule, but we also make it explicitly not weakly-tracked
- * (meaning to untrack NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG at
+ * (meaning to untrack NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG at
* the same time). */
- nmp_route_manager_track_rule(route_manager,
- &plrule,
- 10,
- user_tag_1,
- NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG);
+ nmp_global_tracker_track_rule(global_tracker,
+ &plrule,
+ 10,
+ user_tag_1,
+ NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG);
}
}
@@ -9545,25 +9545,25 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode)
extra_rules = klass->get_extra_rules(self);
if (extra_rules) {
for (i = 0; i < extra_rules->len; i++) {
- nmp_route_manager_track_rule(
- route_manager,
+ nmp_global_tracker_track_rule(
+ global_tracker,
NMP_OBJECT_CAST_ROUTING_RULE(extra_rules->pdata[i]),
10,
user_tag_2,
- NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG);
+ NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG);
}
}
}
}
- nmp_route_manager_untrack_all(route_manager, user_tag_1, !untrack_only_dirty, TRUE);
+ nmp_global_tracker_untrack_all(global_tracker, user_tag_1, !untrack_only_dirty, TRUE);
if (klass->get_extra_rules)
- nmp_route_manager_untrack_all(route_manager, user_tag_2, !untrack_only_dirty, TRUE);
+ nmp_global_tracker_untrack_all(global_tracker, user_tag_2, !untrack_only_dirty, TRUE);
keep_deleted_rules = FALSE;
if (set_mode == NM_TERNARY_DEFAULT) {
/* when exiting NM, we leave the device up and the rules configured.
- * We just call nmp_route_manager_sync() to forget about the synced rules,
+ * We just call nmp_global_tracker_sync() to forget about the synced rules,
* but we don't actually delete them.
*
* FIXME: that is a problem after restart of NetworkManager, because these
@@ -9577,7 +9577,7 @@ _routing_rules_sync(NMDevice *self, NMTernary set_mode)
* file and track them after restart again. */
keep_deleted_rules = TRUE;
}
- nmp_route_manager_sync(route_manager, NMP_OBJECT_TYPE_ROUTING_RULE, keep_deleted_rules);
+ nmp_global_tracker_sync(global_tracker, NMP_OBJECT_TYPE_ROUTING_RULE, keep_deleted_rules);
}
static gboolean
diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c
index 23afa1833e..f70c035cb6 100644
--- a/src/core/nm-l3cfg.c
+++ b/src/core/nm-l3cfg.c
@@ -3450,15 +3450,16 @@ nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag)
/*****************************************************************************/
-#define _NODEV_ROUTES_TAG(self, IS_IPv4) ((gconstpointer) (&(&(self)->priv.route_manager)[IS_IPv4]))
+#define _NODEV_ROUTES_TAG(self, IS_IPv4) \
+ ((gconstpointer) (&(&(self)->priv.global_tracker)[IS_IPv4]))
static gboolean
_nodev_routes_untrack(NML3Cfg *self, int addr_family)
{
- return nmp_route_manager_untrack_all(self->priv.route_manager,
- _NODEV_ROUTES_TAG(self, NM_IS_IPv4(addr_family)),
- FALSE,
- TRUE);
+ return nmp_global_tracker_untrack_all(self->priv.global_tracker,
+ _NODEV_ROUTES_TAG(self, NM_IS_IPv4(addr_family)),
+ FALSE,
+ TRUE);
}
static void
@@ -3478,12 +3479,12 @@ _nodev_routes_sync(NML3Cfg *self,
for (i = 0; i < routes_nodev->len; i++) {
const NMPObject *obj = routes_nodev->pdata[i];
- if (nmp_route_manager_track(self->priv.route_manager,
- obj_type,
- NMP_OBJECT_CAST_IP_ROUTE(obj),
- 1,
- _NODEV_ROUTES_TAG(self, IS_IPv4),
- NULL))
+ if (nmp_global_tracker_track(self->priv.global_tracker,
+ obj_type,
+ NMP_OBJECT_CAST_IP_ROUTE(obj),
+ 1,
+ _NODEV_ROUTES_TAG(self, IS_IPv4),
+ NULL))
changed = TRUE;
}
@@ -3492,7 +3493,9 @@ out_clear:
changed = TRUE;
if (changed || commit_type >= NM_L3_CFG_COMMIT_TYPE_REAPPLY)
- nmp_route_manager_sync(self->priv.route_manager, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4), FALSE);
+ nmp_global_tracker_sync(self->priv.global_tracker,
+ NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4),
+ FALSE);
}
/*****************************************************************************/
@@ -4764,7 +4767,8 @@ constructed(GObject *object)
self->priv.platform = g_object_ref(nm_netns_get_platform(self->priv.netns));
nm_assert(NM_IS_PLATFORM(self->priv.platform));
- self->priv.route_manager = nmp_route_manager_ref(nm_netns_get_route_manager(self->priv.netns));
+ self->priv.global_tracker =
+ nmp_global_tracker_ref(nm_netns_get_global_tracker(self->priv.netns));
_LOGT("created (netns=" NM_HASH_OBFUSCATE_PTR_FMT ")", NM_HASH_OBFUSCATE_PTR(self->priv.netns));
@@ -4819,13 +4823,13 @@ finalize(GObject *object)
nm_assert(c_list_is_empty(&self->priv.p->obj_state_zombie_lst_head));
if (_nodev_routes_untrack(self, AF_INET))
- nmp_route_manager_sync(self->priv.route_manager, NMP_OBJECT_TYPE_IP4_ROUTE, FALSE);
+ nmp_global_tracker_sync(self->priv.global_tracker, NMP_OBJECT_TYPE_IP4_ROUTE, FALSE);
if (_nodev_routes_untrack(self, AF_INET6))
- nmp_route_manager_sync(self->priv.route_manager, NMP_OBJECT_TYPE_IP6_ROUTE, FALSE);
+ nmp_global_tracker_sync(self->priv.global_tracker, NMP_OBJECT_TYPE_IP6_ROUTE, FALSE);
g_clear_object(&self->priv.netns);
g_clear_object(&self->priv.platform);
- nm_clear_pointer(&self->priv.route_manager, nmp_route_manager_unref);
+ nm_clear_pointer(&self->priv.global_tracker, nmp_global_tracker_unref);
nm_clear_l3cd(&self->priv.p->combined_l3cd_merged);
nm_clear_l3cd(&self->priv.p->combined_l3cd_commited);
diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h
index bead34933e..e0257623eb 100644
--- a/src/core/nm-l3cfg.h
+++ b/src/core/nm-l3cfg.h
@@ -196,18 +196,18 @@ typedef struct {
} NML3ConfigNotifyData;
struct _NML3CfgPrivate;
-struct _NMPRouteManager;
+struct _NMPGlobalTracker;
struct _NML3Cfg {
GObject parent;
struct {
- struct _NML3CfgPrivate *p;
- NMNetns *netns;
- NMPlatform *platform;
- struct _NMPRouteManager *route_manager;
- const NMPObject *plobj;
- const NMPObject *plobj_next;
- int ifindex;
+ struct _NML3CfgPrivate *p;
+ NMNetns *netns;
+ NMPlatform *platform;
+ struct _NMPGlobalTracker *global_tracker;
+ const NMPObject *plobj;
+ const NMPObject *plobj_next;
+ int ifindex;
} priv;
};
diff --git a/src/core/nm-netns.c b/src/core/nm-netns.c
index f120e43d06..774e26bd58 100644
--- a/src/core/nm-netns.c
+++ b/src/core/nm-netns.c
@@ -22,14 +22,14 @@
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PLATFORM, );
typedef struct {
- NMNetns *_self_signal_user_data;
- NMPlatform *platform;
- NMPNetns *platform_netns;
- NMPRouteManager *route_manager;
- GHashTable *l3cfgs;
- GHashTable *shared_ips;
- CList l3cfg_signal_pending_lst_head;
- GSource *signal_pending_idle_source;
+ NMNetns *_self_signal_user_data;
+ NMPlatform *platform;
+ NMPNetns *platform_netns;
+ NMPGlobalTracker *global_tracker;
+ GHashTable *l3cfgs;
+ GHashTable *shared_ips;
+ CList l3cfg_signal_pending_lst_head;
+ GSource *signal_pending_idle_source;
} NMNetnsPrivate;
struct _NMNetns {
@@ -79,10 +79,10 @@ nm_netns_get_platform(NMNetns *self)
return NM_NETNS_GET_PRIVATE(self)->platform;
}
-NMPRouteManager *
-nm_netns_get_route_manager(NMNetns *self)
+NMPGlobalTracker *
+nm_netns_get_global_tracker(NMNetns *self)
{
- return NM_NETNS_GET_PRIVATE(self)->route_manager;
+ return NM_NETNS_GET_PRIVATE(self)->global_tracker;
}
NMDedupMultiIndex *
@@ -397,14 +397,14 @@ constructed(GObject *object)
priv->platform_netns = nm_platform_netns_get(priv->platform);
- priv->route_manager = nmp_route_manager_new(priv->platform);
+ priv->global_tracker = nmp_global_tracker_new(priv->platform);
/* Weakly track the default rules with a dummy user-tag. These
* rules are always weekly tracked... */
- nmp_route_manager_track_rule_default(priv->route_manager,
- AF_UNSPEC,
- 0,
- nm_netns_parent_class /* static dummy user-tag */);
+ nmp_global_tracker_track_rule_default(priv->global_tracker,
+ AF_UNSPEC,
+ 0,
+ nm_netns_parent_class /* static dummy user-tag */);
/* Also weakly track all existing rules. These were added before NetworkManager
* starts, so they are probably none of NetworkManager's business.
@@ -414,12 +414,12 @@ constructed(GObject *object)
* of NetworkManager, we just don't know.
*
* For that reason, whenever we will touch such rules later one, we make them
- * fully owned and no longer weekly tracked. See %NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG. */
- nmp_route_manager_track_rule_from_platform(priv->route_manager,
- NULL,
- AF_UNSPEC,
- 0,
- NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG);
+ * fully owned and no longer weekly tracked. See %NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG. */
+ nmp_global_tracker_track_rule_from_platform(priv->global_tracker,
+ NULL,
+ AF_UNSPEC,
+ 0,
+ NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG);
G_OBJECT_CLASS(nm_netns_parent_class)->constructed(object);
@@ -469,7 +469,7 @@ dispose(GObject *object)
g_clear_object(&priv->platform);
nm_clear_pointer(&priv->l3cfgs, g_hash_table_unref);
- nm_clear_pointer(&priv->route_manager, nmp_route_manager_unref);
+ nm_clear_pointer(&priv->global_tracker, nmp_global_tracker_unref);
G_OBJECT_CLASS(nm_netns_parent_class)->dispose(object);
}
diff --git a/src/core/nm-netns.h b/src/core/nm-netns.h
index deb1d1f006..17c1c63743 100644
--- a/src/core/nm-netns.h
+++ b/src/core/nm-netns.h
@@ -29,7 +29,7 @@ NMNetns *nm_netns_new(struct _NMPlatform *platform);
struct _NMPlatform *nm_netns_get_platform(NMNetns *self);
NMPNetns *nm_netns_get_platform_netns(NMNetns *self);
-struct _NMPRouteManager *nm_netns_get_route_manager(NMNetns *self);
+struct _NMPGlobalTracker *nm_netns_get_global_tracker(NMNetns *self);
struct _NMDedupMultiIndex *nm_netns_get_multi_idx(NMNetns *self);
diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c
index 322293e927..e3303e05fc 100644
--- a/src/core/platform/tests/test-route.c
+++ b/src/core/platform/tests/test-route.c
@@ -1647,8 +1647,8 @@ again:
if (TEST_SYNC) {
gs_unref_hashtable GHashTable *unique_priorities = g_hash_table_new(NULL, NULL);
- nm_auto_unref_route_manager NMPRouteManager *route_manager =
- nmp_route_manager_new(platform);
+ nm_auto_unref_global_tracker NMPGlobalTracker *global_tracker =
+ nmp_global_tracker_new(platform);
gs_unref_ptrarray GPtrArray *objs_sync = NULL;
gconstpointer USER_TAG_1 = &platform;
gconstpointer USER_TAG_2 = &unique_priorities;
@@ -1670,29 +1670,29 @@ again:
}
for (i = 0; i < objs_sync->len; i++) {
- nmp_route_manager_track_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- 1,
- USER_TAG_1,
- NULL);
+ nmp_global_tracker_track_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ 1,
+ USER_TAG_1,
+ NULL);
if (nmtst_get_rand_bool()) {
/* this has no effect, because a negative priority (of same absolute value)
* has lower priority than the positive priority above. */
- nmp_route_manager_track_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- -1,
- USER_TAG_2,
- NULL);
+ nmp_global_tracker_track_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ -1,
+ USER_TAG_2,
+ NULL);
}
if (nmtst_get_rand_uint32() % objs_sync->len == 0) {
- nmp_route_manager_sync(route_manager, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
+ nmp_global_tracker_sync(global_tracker, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
g_assert_cmpint(nmtstp_platform_routing_rules_get_count(platform, AF_UNSPEC),
==,
i + 1);
}
}
- nmp_route_manager_sync(route_manager, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
+ nmp_global_tracker_sync(global_tracker, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
g_assert_cmpint(nmtstp_platform_routing_rules_get_count(platform, AF_UNSPEC),
==,
objs_sync->len);
@@ -1700,37 +1700,37 @@ again:
for (i = 0; i < objs_sync->len; i++) {
switch (nmtst_get_rand_uint32() % 3) {
case 0:
- nmp_route_manager_untrack_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- USER_TAG_1);
- nmp_route_manager_untrack_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- USER_TAG_1);
+ nmp_global_tracker_untrack_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ USER_TAG_1);
+ nmp_global_tracker_untrack_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ USER_TAG_1);
break;
case 1:
- nmp_route_manager_track_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- -1,
- USER_TAG_1,
- NULL);
+ nmp_global_tracker_track_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ -1,
+ USER_TAG_1,
+ NULL);
break;
case 2:
- nmp_route_manager_track_rule(route_manager,
- NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
- -2,
- USER_TAG_2,
- NULL);
+ nmp_global_tracker_track_rule(global_tracker,
+ NMP_OBJECT_CAST_ROUTING_RULE(objs_sync->pdata[i]),
+ -2,
+ USER_TAG_2,
+ NULL);
break;
}
if (nmtst_get_rand_uint32() % objs_sync->len == 0) {
- nmp_route_manager_sync(route_manager, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
+ nmp_global_tracker_sync(global_tracker, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
g_assert_cmpint(nmtstp_platform_routing_rules_get_count(platform, AF_UNSPEC),
==,
objs_sync->len - i - 1);
}
}
- nmp_route_manager_sync(route_manager, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
+ nmp_global_tracker_sync(global_tracker, NMP_OBJECT_TYPE_ROUTING_RULE, FALSE);
} else {
for (i = 0; i < objs->len;) {
diff --git a/src/libnm-platform/nmp-route-manager.c b/src/libnm-platform/nmp-route-manager.c
index 842301b1bd..4bf44f2778 100644
--- a/src/libnm-platform/nmp-route-manager.c
+++ b/src/libnm-platform/nmp-route-manager.c
@@ -13,7 +13,7 @@
/*****************************************************************************/
-struct _NMPRouteManager {
+struct _NMPGlobalTracker {
NMPlatform *platform;
GHashTable *by_obj;
GHashTable *by_user_tag;
@@ -25,17 +25,17 @@ struct _NMPRouteManager {
/*****************************************************************************/
#define _NMLOG_DOMAIN LOGD_PLATFORM
-#define _NMLOG_PREFIX_NAME "route-manager"
+#define _NMLOG_PREFIX_NAME "global-tracker"
#define _NMLOG(level, ...) __NMLOG_DEFAULT(level, LOGD_PLATFORM, _NMLOG_PREFIX_NAME, __VA_ARGS__)
/*****************************************************************************/
static gboolean
-NMP_IS_ROUTE_MANAGER(gpointer self)
+NMP_IS_GLOBAL_TRACKER(gpointer self)
{
- return self && ((NMPRouteManager *) self)->ref_count > 0
- && NM_IS_PLATFORM(((NMPRouteManager *) self)->platform);
+ return self && ((NMPGlobalTracker *) self)->ref_count > 0
+ && NM_IS_PLATFORM(((NMPGlobalTracker *) self)->platform);
}
/*****************************************************************************/
@@ -91,13 +91,13 @@ typedef struct {
/* indicates whether we configured/removed the rule (during sync()). We need that, so
* if the rule gets untracked, that we know to remove/restore it.
*
- * This makes NMPRouteManager stateful (beyond the configuration that indicates
+ * This makes NMPGlobalTracker stateful (beyond the configuration that indicates
* which rules are tracked).
* After a restart, NetworkManager would no longer remember which rules were added
* by us.
*
* That is partially fixed by NetworkManager taking over the rules that it
- * actively configures (see %NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG). */
+ * actively configures (see %NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG). */
ConfigState config_state;
} TrackObjData;
@@ -108,15 +108,15 @@ typedef struct {
/*****************************************************************************/
-static void _track_data_untrack(NMPRouteManager *self,
- TrackData *track_data,
- gboolean remove_user_tag_data,
- gboolean make_owned_by_us);
+static void _track_data_untrack(NMPGlobalTracker *self,
+ TrackData *track_data,
+ gboolean remove_user_tag_data,
+ gboolean make_owned_by_us);
/*****************************************************************************/
static CList *
-_by_obj_lst_head(NMPRouteManager *self, NMPObjectType obj_type)
+_by_obj_lst_head(NMPGlobalTracker *self, NMPObjectType obj_type)
{
G_STATIC_ASSERT(G_N_ELEMENTS(self->by_obj_lst_heads) == 3);
@@ -266,8 +266,8 @@ _track_data_lookup(GHashTable *by_data, const NMPObject *obj, gconstpointer user
/*****************************************************************************/
/**
- * nmp_route_manager_track:
- * @self: the #NMPRouteManager instance
+ * nmp_global_tracker_track:
+ * @self: the #NMPGlobalTracker instance
* @obj_type: the NMPObjectType of @obj that we are tracking.
* @obj: the NMPlatformObject (of type NMPObjectType) to track. Usually
* a #NMPlatformRoutingRule, #NMPlatformIP4Route or #NMPlatformIP6Route
@@ -282,20 +282,20 @@ _track_data_lookup(GHashTable *by_data, const NMPObject *obj, gconstpointer user
* @user_tag: the tag associated with tracking this rule. The same tag
* must be used to untrack the rule later.
* @user_tag_untrack: if not %NULL, at the same time untrack this user-tag
- * for the same rule. Note that this is different from a plain nmp_route_manager_untrack_rule(),
+ * for the same rule. Note that this is different from a plain nmp_global_tracker_untrack_rule(),
* because it enforces ownership of the now tracked rule. On the other hand,
- * a plain nmp_route_manager_untrack_rule() merely forgets about the tracking.
- * The purpose here is to set this to %NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG.
+ * a plain nmp_global_tracker_untrack_rule() merely forgets about the tracking.
+ * The purpose here is to set this to %NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG.
*
* Returns: %TRUE, if something changed.
*/
gboolean
-nmp_route_manager_track(NMPRouteManager *self,
- NMPObjectType obj_type,
- gconstpointer obj,
- gint32 track_priority,
- gconstpointer user_tag,
- gconstpointer user_tag_untrack)
+nmp_global_tracker_track(NMPGlobalTracker *self,
+ NMPObjectType obj_type,
+ gconstpointer obj,
+ gint32 track_priority,
+ gconstpointer user_tag,
+ gconstpointer user_tag_untrack)
{
NMPObject obj_stack;
const NMPObject *p_obj_stack;
@@ -307,7 +307,7 @@ nmp_route_manager_track(NMPRouteManager *self,
guint32 track_priority_val;
gboolean track_priority_present;
- g_return_val_if_fail(NMP_IS_ROUTE_MANAGER(self), FALSE);
+ g_return_val_if_fail(NMP_IS_GLOBAL_TRACKER(self), FALSE);
g_return_val_if_fail(obj, FALSE);
g_return_val_if_fail(user_tag, FALSE);
@@ -414,15 +414,15 @@ nmp_route_manager_track(NMPRouteManager *self,
}
static void
-_track_data_untrack(NMPRouteManager *self,
- TrackData *track_data,
- gboolean remove_user_tag_data,
- gboolean make_owned_by_us)
+_track_data_untrack(NMPGlobalTracker *self,
+ TrackData *track_data,
+ gboolean remove_user_tag_data,
+ gboolean make_owned_by_us)
{
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
TrackObjData *obj_data;
- nm_assert(NMP_IS_ROUTE_MANAGER(self));
+ nm_assert(NMP_IS_GLOBAL_TRACKER(self));
_track_data_assert(track_data, TRUE);
nm_assert(self->by_data);
nm_assert(g_hash_table_lookup(self->by_data, track_data) == track_data);
@@ -467,17 +467,17 @@ _track_data_untrack(NMPRouteManager *self,
}
gboolean
-nmp_route_manager_untrack(NMPRouteManager *self,
- NMPObjectType obj_type,
- gconstpointer obj,
- gconstpointer user_tag)
+nmp_global_tracker_untrack(NMPGlobalTracker *self,
+ NMPObjectType obj_type,
+ gconstpointer obj,
+ gconstpointer user_tag)
{
NMPObject obj_stack;
const NMPObject *p_obj_stack;
TrackData *track_data;
gboolean changed = FALSE;
- g_return_val_if_fail(NMP_IS_ROUTE_MANAGER(self), FALSE);
+ g_return_val_if_fail(NMP_IS_GLOBAL_TRACKER(self), FALSE);
nm_assert(NM_IN_SET(obj_type,
NMP_OBJECT_TYPE_IP4_ROUTE,
NMP_OBJECT_TYPE_IP6_ROUTE,
@@ -499,12 +499,12 @@ nmp_route_manager_untrack(NMPRouteManager *self,
}
void
-nmp_route_manager_set_dirty(NMPRouteManager *self, gconstpointer user_tag)
+nmp_global_tracker_set_dirty(NMPGlobalTracker *self, gconstpointer user_tag)
{
TrackData *track_data;
TrackUserTagData *user_tag_data;
- g_return_if_fail(NMP_IS_ROUTE_MANAGER(self));
+ g_return_if_fail(NMP_IS_GLOBAL_TRACKER(self));
g_return_if_fail(user_tag);
user_tag_data = g_hash_table_lookup(self->by_user_tag, &user_tag);
@@ -516,17 +516,17 @@ nmp_route_manager_set_dirty(NMPRouteManager *self, gconstpointer user_tag)
}
gboolean
-nmp_route_manager_untrack_all(NMPRouteManager *self,
- gconstpointer user_tag,
- gboolean all /* or only dirty */,
- gboolean make_survivors_dirty)
+nmp_global_tracker_untrack_all(NMPGlobalTracker *self,
+ gconstpointer user_tag,
+ gboolean all /* or only dirty */,
+ gboolean make_survivors_dirty)
{
TrackData *track_data;
TrackData *track_data_safe;
TrackUserTagData *user_tag_data;
gboolean changed = FALSE;
- g_return_val_if_fail(NMP_IS_ROUTE_MANAGER(self), FALSE);
+ g_return_val_if_fail(NMP_IS_GLOBAL_TRACKER(self), FALSE);
g_return_val_if_fail(user_tag, FALSE);
user_tag_data = g_hash_table_lookup(self->by_user_tag, &user_tag);
@@ -554,7 +554,7 @@ nmp_route_manager_untrack_all(NMPRouteManager *self,
/*****************************************************************************/
void
-nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean keep_deleted)
+nmp_global_tracker_sync(NMPGlobalTracker *self, NMPObjectType obj_type, gboolean keep_deleted)
{
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
const NMDedupMultiHeadEntry *pl_head_entry;
@@ -567,7 +567,7 @@ nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean k
guint i;
const TrackData *td_best;
- g_return_if_fail(NMP_IS_ROUTE_MANAGER(self));
+ g_return_if_fail(NMP_IS_GLOBAL_TRACKER(self));
g_return_if_fail(NM_IN_SET(obj_type,
NMP_OBJECT_TYPE_IP4_ROUTE,
NMP_OBJECT_TYPE_IP6_ROUTE,
@@ -677,18 +677,18 @@ nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean k
/*****************************************************************************/
void
-nmp_route_manager_track_rule_from_platform(NMPRouteManager *self,
- NMPlatform *platform,
- int addr_family,
- gint32 tracking_priority,
- gconstpointer user_tag)
+nmp_global_tracker_track_rule_from_platform(NMPGlobalTracker *self,
+ NMPlatform *platform,
+ int addr_family,
+ gint32 tracking_priority,
+ gconstpointer user_tag)
{
NMPLookup lookup;
const NMDedupMultiHeadEntry *head_entry;
NMDedupMultiIter iter;
const NMPObject *o;
- g_return_if_fail(NMP_IS_ROUTE_MANAGER(self));
+ g_return_if_fail(NMP_IS_GLOBAL_TRACKER(self));
if (!platform)
platform = self->platform;
@@ -705,98 +705,98 @@ nmp_route_manager_track_rule_from_platform(NMPRouteManager *self,
if (addr_family != AF_UNSPEC && rr->addr_family != addr_family)
continue;
- nmp_route_manager_track_rule(self, rr, tracking_priority, user_tag, NULL);
+ nmp_global_tracker_track_rule(self, rr, tracking_priority, user_tag, NULL);
}
}
/*****************************************************************************/
void
-nmp_route_manager_track_rule_default(NMPRouteManager *self,
- int addr_family,
- gint32 track_priority,
- gconstpointer user_tag)
+nmp_global_tracker_track_rule_default(NMPGlobalTracker *self,
+ int addr_family,
+ gint32 track_priority,
+ gconstpointer user_tag)
{
- g_return_if_fail(NMP_IS_ROUTE_MANAGER(self));
+ g_return_if_fail(NMP_IS_GLOBAL_TRACKER(self));
nm_assert(NM_IN_SET(addr_family, AF_UNSPEC, AF_INET, AF_INET6));
/* track the default rules. See also `man ip-rule`. */
if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET)) {
- nmp_route_manager_track_rule(self,
- &((NMPlatformRoutingRule){
- .addr_family = AF_INET,
- .priority = 0,
- .table = RT_TABLE_LOCAL,
- .action = FR_ACT_TO_TBL,
- .protocol = RTPROT_KERNEL,
- }),
- track_priority,
- user_tag,
- NULL);
- nmp_route_manager_track_rule(self,
- &((NMPlatformRoutingRule){
- .addr_family = AF_INET,
- .priority = 32766,
- .table = RT_TABLE_MAIN,
- .action = FR_ACT_TO_TBL,
- .protocol = RTPROT_KERNEL,
- }),
- track_priority,
- user_tag,
- NULL);
- nmp_route_manager_track_rule(self,
- &((NMPlatformRoutingRule){
- .addr_family = AF_INET,
- .priority = 32767,
- .table = RT_TABLE_DEFAULT,
- .action = FR_ACT_TO_TBL,
- .protocol = RTPROT_KERNEL,
- }),
- track_priority,
- user_tag,
- NULL);
+ nmp_global_tracker_track_rule(self,
+ &((NMPlatformRoutingRule){
+ .addr_family = AF_INET,
+ .priority = 0,
+ .table = RT_TABLE_LOCAL,
+ .action = FR_ACT_TO_TBL,
+ .protocol = RTPROT_KERNEL,
+ }),
+ track_priority,
+ user_tag,
+ NULL);
+ nmp_global_tracker_track_rule(self,
+ &((NMPlatformRoutingRule){
+ .addr_family = AF_INET,
+ .priority = 32766,
+ .table = RT_TABLE_MAIN,
+ .action = FR_ACT_TO_TBL,
+ .protocol = RTPROT_KERNEL,
+ }),
+ track_priority,
+ user_tag,
+ NULL);
+ nmp_global_tracker_track_rule(self,
+ &((NMPlatformRoutingRule){
+ .addr_family = AF_INET,
+ .priority = 32767,
+ .table = RT_TABLE_DEFAULT,
+ .action = FR_ACT_TO_TBL,
+ .protocol = RTPROT_KERNEL,
+ }),
+ track_priority,
+ user_tag,
+ NULL);
}
if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET6)) {
- nmp_route_manager_track_rule(self,
- &((NMPlatformRoutingRule){
- .addr_family = AF_INET6,
- .priority = 0,
- .table = RT_TABLE_LOCAL,
- .action = FR_ACT_TO_TBL,
- .protocol = RTPROT_KERNEL,
- }),
- track_priority,
- user_tag,
- NULL);
- nmp_route_manager_track_rule(self,
- &((NMPlatformRoutingRule){
- .addr_family = AF_INET6,
- .priority = 32766,
- .table = RT_TABLE_MAIN,
- .action = FR_ACT_TO_TBL,
- .protocol = RTPROT_KERNEL,
- }),
- track_priority,
- user_tag,
- NULL);
+ nmp_global_tracker_track_rule(self,
+ &((NMPlatformRoutingRule){
+ .addr_family = AF_INET6,
+ .priority = 0,
+ .table = RT_TABLE_LOCAL,
+ .action = FR_ACT_TO_TBL,
+ .protocol = RTPROT_KERNEL,
+ }),
+ track_priority,
+ user_tag,
+ NULL);
+ nmp_global_tracker_track_rule(self,
+ &((NMPlatformRoutingRule){
+ .addr_family = AF_INET6,
+ .priority = 32766,
+ .table = RT_TABLE_MAIN,
+ .action = FR_ACT_TO_TBL,
+ .protocol = RTPROT_KERNEL,
+ }),
+ track_priority,
+ user_tag,
+ NULL);
}
}
/*****************************************************************************/
-NMPRouteManager *
-nmp_route_manager_new(NMPlatform *platform)
+NMPGlobalTracker *
+nmp_global_tracker_new(NMPlatform *platform)
{
- NMPRouteManager *self;
+ NMPGlobalTracker *self;
g_return_val_if_fail(NM_IS_PLATFORM(platform), NULL);
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(TrackUserTagData, user_tag) == 0);
- self = g_slice_new(NMPRouteManager);
- *self = (NMPRouteManager){
+ self = g_slice_new(NMPGlobalTracker);
+ *self = (NMPGlobalTracker){
.ref_count = 1,
.platform = g_object_ref(platform),
.by_data =
@@ -816,19 +816,19 @@ nmp_route_manager_new(NMPlatform *platform)
return self;
}
-NMPRouteManager *
-nmp_route_manager_ref(NMPRouteManager *self)
+NMPGlobalTracker *
+nmp_global_tracker_ref(NMPGlobalTracker *self)
{
- g_return_val_if_fail(NMP_IS_ROUTE_MANAGER(self), NULL);
+ g_return_val_if_fail(NMP_IS_GLOBAL_TRACKER(self), NULL);
self->ref_count++;
return self;
}
void
-nmp_route_manager_unref(NMPRouteManager *self)
+nmp_global_tracker_unref(NMPGlobalTracker *self)
{
- g_return_if_fail(NMP_IS_ROUTE_MANAGER(self));
+ g_return_if_fail(NMP_IS_GLOBAL_TRACKER(self));
if (--self->ref_count > 0)
return;
diff --git a/src/libnm-platform/nmp-route-manager.h b/src/libnm-platform/nmp-route-manager.h
index 97ec3840df..61a4c1eb58 100644
--- a/src/libnm-platform/nmp-route-manager.h
+++ b/src/libnm-platform/nmp-route-manager.h
@@ -1,79 +1,79 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#ifndef __NMP_ROUTE_MANAGER_H__
-#define __NMP_ROUTE_MANAGER_H__
+#ifndef __NMP_GLOBAL_TRACKER_H__
+#define __NMP_GLOBAL_TRACKER_H__
#include "nm-platform.h"
/*****************************************************************************/
-#define NMP_ROUTE_MANAGER_EXTERN_WEAKLY_TRACKED_USER_TAG ((const void *) nmp_route_manager_new)
+#define NMP_GLOBAL_TRACKER_EXTERN_WEAKLY_TRACKED_USER_TAG ((const void *) nmp_global_tracker_new)
-typedef struct _NMPRouteManager NMPRouteManager;
+typedef struct _NMPGlobalTracker NMPGlobalTracker;
-NMPRouteManager *nmp_route_manager_new(NMPlatform *platform);
+NMPGlobalTracker *nmp_global_tracker_new(NMPlatform *platform);
-NMPRouteManager *nmp_route_manager_ref(NMPRouteManager *self);
-void nmp_route_manager_unref(NMPRouteManager *self);
+NMPGlobalTracker *nmp_global_tracker_ref(NMPGlobalTracker *self);
+void nmp_global_tracker_unref(NMPGlobalTracker *self);
-#define nm_auto_unref_route_manager nm_auto(_nmp_route_manager_unref)
-NM_AUTO_DEFINE_FCN0(NMPRouteManager *, _nmp_route_manager_unref, nmp_route_manager_unref);
+#define nm_auto_unref_global_tracker nm_auto(_nmp_global_tracker_unref)
+NM_AUTO_DEFINE_FCN0(NMPGlobalTracker *, _nmp_global_tracker_unref, nmp_global_tracker_unref);
-gboolean nmp_route_manager_track(NMPRouteManager *self,
- NMPObjectType obj_type,
- gconstpointer obj,
- gint32 track_priority,
- gconstpointer user_tag,
- gconstpointer user_tag_untrack);
+gboolean nmp_global_tracker_track(NMPGlobalTracker *self,
+ NMPObjectType obj_type,
+ gconstpointer obj,
+ gint32 track_priority,
+ gconstpointer user_tag,
+ gconstpointer user_tag_untrack);
static inline gboolean
-nmp_route_manager_track_rule(NMPRouteManager *self,
- const NMPlatformRoutingRule *routing_rule,
- gint32 track_priority,
- gconstpointer user_tag,
- gconstpointer user_tag_untrack)
+nmp_global_tracker_track_rule(NMPGlobalTracker *self,
+ const NMPlatformRoutingRule *routing_rule,
+ gint32 track_priority,
+ gconstpointer user_tag,
+ gconstpointer user_tag_untrack)
{
- return nmp_route_manager_track(self,
- NMP_OBJECT_TYPE_ROUTING_RULE,
- routing_rule,
- track_priority,
- user_tag,
- user_tag_untrack);
+ return nmp_global_tracker_track(self,
+ NMP_OBJECT_TYPE_ROUTING_RULE,
+ routing_rule,
+ track_priority,
+ user_tag,
+ user_tag_untrack);
}
-void nmp_route_manager_track_rule_default(NMPRouteManager *self,
- int addr_family,
- gint32 track_priority,
- gconstpointer user_tag);
+void nmp_global_tracker_track_rule_default(NMPGlobalTracker *self,
+ int addr_family,
+ gint32 track_priority,
+ gconstpointer user_tag);
-void nmp_route_manager_track_rule_from_platform(NMPRouteManager *self,
- NMPlatform *platform,
- int addr_family,
- gint32 tracking_priority,
- gconstpointer user_tag);
+void nmp_global_tracker_track_rule_from_platform(NMPGlobalTracker *self,
+ NMPlatform *platform,
+ int addr_family,
+ gint32 tracking_priority,
+ gconstpointer user_tag);
-gboolean nmp_route_manager_untrack(NMPRouteManager *self,
- NMPObjectType obj_type,
- gconstpointer obj,
- gconstpointer user_tag);
+gboolean nmp_global_tracker_untrack(NMPGlobalTracker *self,
+ NMPObjectType obj_type,
+ gconstpointer obj,
+ gconstpointer user_tag);
static inline gboolean
-nmp_route_manager_untrack_rule(NMPRouteManager *self,
- const NMPlatformRoutingRule *routing_rule,
- gconstpointer user_tag)
+nmp_global_tracker_untrack_rule(NMPGlobalTracker *self,
+ const NMPlatformRoutingRule *routing_rule,
+ gconstpointer user_tag)
{
- return nmp_route_manager_untrack(self, NMP_OBJECT_TYPE_ROUTING_RULE, routing_rule, user_tag);
+ return nmp_global_tracker_untrack(self, NMP_OBJECT_TYPE_ROUTING_RULE, routing_rule, user_tag);
}
-void nmp_route_manager_set_dirty(NMPRouteManager *self, gconstpointer user_tag);
+void nmp_global_tracker_set_dirty(NMPGlobalTracker *self, gconstpointer user_tag);
-gboolean nmp_route_manager_untrack_all(NMPRouteManager *self,
- gconstpointer user_tag,
- gboolean all /* or only dirty */,
- gboolean make_survivors_dirty);
+gboolean nmp_global_tracker_untrack_all(NMPGlobalTracker *self,
+ gconstpointer user_tag,
+ gboolean all /* or only dirty */,
+ gboolean make_survivors_dirty);
-void nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean keep_deleted);
+void nmp_global_tracker_sync(NMPGlobalTracker *self, NMPObjectType obj_type, gboolean keep_deleted);
/*****************************************************************************/
-#endif /* __NMP_ROUTE_MANAGER_H__ */
+#endif /* __NMP_GLOBAL_TRACKER_H__ */