summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format2
-rw-r--r--src/devices/nm-device.c26
-rw-r--r--src/dns/nm-dns-dnsmasq.c4
-rw-r--r--src/dns/nm-dns-manager.c256
-rw-r--r--src/dns/nm-dns-manager.h7
-rw-r--r--src/dns/nm-dns-plugin.h2
-rw-r--r--src/dns/nm-dns-systemd-resolved.c6
-rw-r--r--src/nm-core-utils.c8
-rw-r--r--src/nm-core-utils.h16
-rw-r--r--src/nm-ip4-config.h56
-rw-r--r--src/nm-pacrunner-manager.c63
-rw-r--r--src/platform/nmp-object.h104
-rw-r--r--src/tests/test-core.c26
13 files changed, 318 insertions, 258 deletions
diff --git a/.clang-format b/.clang-format
index 33a0c6399..13c9899c6 100644
--- a/.clang-format
+++ b/.clang-format
@@ -101,6 +101,8 @@ ForEachMacros: ['c_list_for_each',
'nm_ip_config_iter_ip4_route_for_each',
'nm_ip_config_iter_ip6_address_for_each',
'nm_ip_config_iter_ip6_route_for_each',
+ 'nm_ip_config_iter_ip_address_for_each',
+ 'nm_ip_config_iter_ip_route_for_each',
'nm_json_array_foreach',
'nm_json_object_foreach',
'nm_l3_config_data_iter_ip4_address_for_each',
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 45c07f63d..ec01d3af6 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3670,7 +3670,8 @@ nm_device_get_route_table(NMDevice *self, int addr_family)
static NMIPRouteTableSyncMode
_get_route_table_sync_mode_stateful(NMDevice *self, int addr_family)
{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
+ const int IS_IPv4 = NM_IS_IPv4(addr_family);
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
NMDedupMultiIter ipconf_iter;
gboolean all_sync_now;
gboolean all_sync_eff;
@@ -3678,25 +3679,14 @@ _get_route_table_sync_mode_stateful(NMDevice *self, int addr_family)
all_sync_now = _prop_get_ipvx_route_table(self, addr_family) != 0u;
if (!all_sync_now) {
+ const NMPlatformIPRoute *route;
+
/* If there's a local route switch to all-sync in order
* to properly manage the local table */
- if (NM_IS_IPv4(addr_family)) {
- const NMPlatformIP4Route *route;
-
- nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, priv->con_ip_config_4, &route) {
- if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) {
- all_sync_now = TRUE;
- break;
- }
- }
- } else {
- const NMPlatformIP6Route *route;
-
- nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, priv->con_ip_config_6, &route) {
- if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) {
- all_sync_now = TRUE;
- break;
- }
+ nm_ip_config_iter_ip_route_for_each (&ipconf_iter, priv->con_ip_config_x[IS_IPv4], &route) {
+ if (nm_platform_route_type_uncoerce(route->type_coerced) == RTN_LOCAL) {
+ all_sync_now = TRUE;
+ break;
}
}
}
diff --git a/src/dns/nm-dns-dnsmasq.c b/src/dns/nm-dns-dnsmasq.c
index 97f1dfabf..a56072380 100644
--- a/src/dns/nm-dns-dnsmasq.c
+++ b/src/dns/nm-dns-dnsmasq.c
@@ -804,7 +804,7 @@ add_global_config(NMDnsDnsmasq * self,
}
static void
-add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *ip_data)
+add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPData *ip_data)
{
NMIPConfig * ip_config = ip_data->ip_config;
gconstpointer addr;
@@ -850,7 +850,7 @@ create_update_args(NMDnsDnsmasq * self,
const char * hostname)
{
GVariantBuilder servers;
- const NMDnsIPConfigData *ip_data;
+ const NMDnsConfigIPData *ip_data;
g_variant_builder_init(&servers, G_VARIANT_TYPE("aas"));
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
index 81d86d6c3..ac7021db4 100644
--- a/src/dns/nm-dns-manager.c
+++ b/src/dns/nm-dns-manager.c
@@ -80,14 +80,18 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDnsManager, PROP_MODE, PROP_RC_MANAGER, PROP_CONF
static guint signals[LAST_SIGNAL] = {0};
typedef struct {
- GHashTable *configs;
- CList ip_config_lst_head;
- GVariant * config_variant;
+ GHashTable *configs_dict;
+ CList configs_lst_head;
- NMDnsIPConfigData *best_ip_config_4;
- NMDnsIPConfigData *best_ip_config_6;
+ CList ip_configs_lst_head;
+ GVariant *config_variant;
- bool ip_config_lst_need_sort : 1;
+ NMDnsConfigIPData *best_ip_config_4;
+ NMDnsConfigIPData *best_ip_config_6;
+
+ bool ip_configs_lst_need_sort : 1;
+
+ bool configs_lst_need_sort : 1;
bool dns_touched : 1;
bool is_stopped : 1;
@@ -158,7 +162,7 @@ NM_DEFINE_SINGLETON_GETTER(NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER
/*****************************************************************************/
static void
-_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsIPConfigData *ip_data);
+_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsConfigIPData *ip_data);
/*****************************************************************************/
@@ -207,7 +211,7 @@ static NM_UTILS_LOOKUP_STR_DEFINE(
/*****************************************************************************/
static void
-_ASSERT_config_data(const NMDnsConfigData *data)
+_ASSERT_dns_config_data(const NMDnsConfigData *data)
{
nm_assert(data);
nm_assert(NM_IS_DNS_MANAGER(data->self));
@@ -215,10 +219,10 @@ _ASSERT_config_data(const NMDnsConfigData *data)
}
static void
-_ASSERT_ip_config_data(const NMDnsIPConfigData *ip_data)
+_ASSERT_dns_config_ip_data(const NMDnsConfigIPData *ip_data)
{
nm_assert(ip_data);
- _ASSERT_config_data(ip_data->data);
+ _ASSERT_dns_config_data(ip_data->data);
nm_assert(NM_IS_IP_CONFIG(ip_data->ip_config));
nm_assert(c_list_contains(&ip_data->data->data_lst_head, &ip_data->data_lst));
nm_assert(ip_data->data->ifindex == nm_ip_config_get_ifindex(ip_data->ip_config));
@@ -244,23 +248,25 @@ _ASSERT_ip_config_data(const NMDnsIPConfigData *ip_data)
#endif
}
-static NMDnsIPConfigData *
-_ip_config_data_new(NMDnsConfigData *data, NMIPConfig *ip_config, NMDnsIPConfigType ip_config_type)
+static NMDnsConfigIPData *
+_dns_config_ip_data_new(NMDnsConfigData * data,
+ NMIPConfig * ip_config,
+ NMDnsIPConfigType ip_config_type)
{
- NMDnsIPConfigData *ip_data;
+ NMDnsConfigIPData *ip_data;
- _ASSERT_config_data(data);
+ _ASSERT_dns_config_data(data);
nm_assert(NM_IS_IP_CONFIG(ip_config));
nm_assert(ip_config_type != NM_DNS_IP_CONFIG_TYPE_REMOVED);
- ip_data = g_slice_new(NMDnsIPConfigData);
- *ip_data = (NMDnsIPConfigData){
+ ip_data = g_slice_new(NMDnsConfigIPData);
+ *ip_data = (NMDnsConfigIPData){
.data = data,
.ip_config = g_object_ref(ip_config),
.ip_config_type = ip_config_type,
};
c_list_link_tail(&data->data_lst_head, &ip_data->data_lst);
- c_list_link_tail(&NM_DNS_MANAGER_GET_PRIVATE(data->self)->ip_config_lst_head,
+ c_list_link_tail(&NM_DNS_MANAGER_GET_PRIVATE(data->self)->ip_configs_lst_head,
&ip_data->ip_config_lst);
g_signal_connect(ip_config,
@@ -269,14 +275,14 @@ _ip_config_data_new(NMDnsConfigData *data, NMIPConfig *ip_config, NMDnsIPConfigT
(GCallback) _ip_config_dns_priority_changed,
ip_data);
- _ASSERT_ip_config_data(ip_data);
+ _ASSERT_dns_config_ip_data(ip_data);
return ip_data;
}
static void
-_ip_config_data_free(NMDnsIPConfigData *ip_data)
+_dns_config_ip_data_free(NMDnsConfigIPData *ip_data)
{
- _ASSERT_ip_config_data(ip_data);
+ _ASSERT_dns_config_ip_data(ip_data);
c_list_unlink_stale(&ip_data->data_lst);
c_list_unlink_stale(&ip_data->ip_config_lst);
@@ -292,15 +298,15 @@ _ip_config_data_free(NMDnsIPConfigData *ip_data)
nm_g_slice_free(ip_data);
}
-static NMDnsIPConfigData *
-_config_data_find_ip_config(NMDnsConfigData *data, NMIPConfig *ip_config)
+static NMDnsConfigIPData *
+_dns_config_data_find_ip_config(NMDnsConfigData *data, NMIPConfig *ip_config)
{
- NMDnsIPConfigData *ip_data;
+ NMDnsConfigIPData *ip_data;
- _ASSERT_config_data(data);
+ _ASSERT_dns_config_data(data);
c_list_for_each_entry (ip_data, &data->data_lst_head, data_lst) {
- _ASSERT_ip_config_data(ip_data);
+ _ASSERT_dns_config_ip_data(ip_data);
if (ip_data->ip_config == ip_config)
return ip_data;
@@ -309,19 +315,20 @@ _config_data_find_ip_config(NMDnsConfigData *data, NMIPConfig *ip_config)
}
static void
-_config_data_free(NMDnsConfigData *data)
+_dns_config_data_free(NMDnsConfigData *data)
{
- _ASSERT_config_data(data);
+ _ASSERT_dns_config_data(data);
nm_assert(c_list_is_empty(&data->data_lst_head));
+ c_list_unlink_stale(&data->configs_lst);
nm_g_slice_free(data);
}
static int
-_ip_config_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data)
+_mgr_get_ip_configs_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data)
{
- const NMDnsIPConfigData *a = c_list_entry(a_lst, NMDnsIPConfigData, ip_config_lst);
- const NMDnsIPConfigData *b = c_list_entry(b_lst, NMDnsIPConfigData, ip_config_lst);
+ const NMDnsConfigIPData *a = c_list_entry(a_lst, NMDnsConfigIPData, ip_config_lst);
+ const NMDnsConfigIPData *b = c_list_entry(b_lst, NMDnsConfigIPData, ip_config_lst);
/* Configurations with lower priority value first */
NM_CMP_DIRECT(nm_ip_config_get_dns_priority(a->ip_config),
@@ -334,16 +341,39 @@ _ip_config_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data
}
static CList *
-_ip_config_lst_head(NMDnsManager *self)
+_mgr_get_ip_configs_lst_head(NMDnsManager *self)
{
NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self);
- if (priv->ip_config_lst_need_sort) {
- priv->ip_config_lst_need_sort = FALSE;
- c_list_sort(&priv->ip_config_lst_head, _ip_config_lst_cmp, NULL);
+ if (G_UNLIKELY(priv->ip_configs_lst_need_sort)) {
+ priv->ip_configs_lst_need_sort = FALSE;
+ c_list_sort(&priv->ip_configs_lst_head, _mgr_get_ip_configs_lst_cmp, NULL);
}
- return &priv->ip_config_lst_head;
+ return &priv->ip_configs_lst_head;
+}
+
+static int
+_mgr_get_configs_lst_cmp(const CList *a_lst, const CList *b_lst, const void *user_data)
+{
+ const NMDnsConfigData *a = c_list_entry(a_lst, NMDnsConfigData, configs_lst);
+ const NMDnsConfigData *b = c_list_entry(b_lst, NMDnsConfigData, configs_lst);
+
+ NM_CMP_FIELD(b, a, ifindex);
+ return nm_assert_unreachable_val(0);
+}
+
+_nm_unused static CList *
+_mgr_get_configs_lst_head(NMDnsManager *self)
+{
+ NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self);
+
+ if (G_UNLIKELY(priv->configs_lst_need_sort)) {
+ priv->configs_lst_need_sort = FALSE;
+ c_list_sort(&priv->configs_lst_head, _mgr_get_configs_lst_cmp, NULL);
+ }
+
+ return &priv->configs_lst_head;
}
/*****************************************************************************/
@@ -1077,7 +1107,7 @@ static void
compute_hash(NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[HASH_LEN])
{
nm_auto_free_checksum GChecksum *sum = NULL;
- NMDnsIPConfigData * ip_data;
+ NMDnsConfigIPData * ip_data;
sum = g_checksum_new(G_CHECKSUM_SHA1);
nm_assert(HASH_LEN == g_checksum_type_get_length(G_CHECKSUM_SHA1));
@@ -1089,7 +1119,7 @@ compute_hash(NMDnsManager *self, const NMGlobalDnsConfig *global, guint8 buffer[
/* FIXME(ip-config-checksum): this relies on the fact that an IP
* configuration without DNS parameters gives a zero checksum. */
- head = _ip_config_lst_head(self);
+ head = _mgr_get_ip_configs_lst_head(self);
c_list_for_each_entry (ip_data, head, ip_config_lst)
nm_ip_config_hash(ip_data->ip_config, sum, TRUE);
}
@@ -1196,15 +1226,15 @@ _collect_resolv_conf_data(NMDnsManager * self,
else {
nm_auto_free_gstring GString *tmp_gstring = NULL;
int prio, first_prio = 0;
- const NMDnsIPConfigData * ip_data;
+ const NMDnsConfigIPData * ip_data;
const CList * head;
gboolean is_first = TRUE;
- head = _ip_config_lst_head(self);
+ head = _mgr_get_ip_configs_lst_head(self);
c_list_for_each_entry (ip_data, head, ip_config_lst) {
gboolean skip = FALSE;
- _ASSERT_ip_config_data(ip_data);
+ _ASSERT_dns_config_ip_data(ip_data);
prio = nm_ip_config_get_dns_priority(ip_data->ip_config);
@@ -1259,41 +1289,35 @@ _collect_resolv_conf_data(NMDnsManager * self,
*out_nis_domain = rc.nis_domain;
}
+/*****************************************************************************/
+
static char **
get_ip_rdns_domains(NMIPConfig *ip_config)
{
- int addr_family = nm_ip_config_get_addr_family(ip_config);
- char ** strv;
- GPtrArray * domains = NULL;
- NMDedupMultiIter ipconf_iter;
+ int addr_family = nm_ip_config_get_addr_family(ip_config);
+ char ** strv;
+ GPtrArray * domains;
+ NMDedupMultiIter ipconf_iter;
+ const NMPlatformIPAddress *address;
+ const NMPlatformIPRoute * route;
nm_assert_addr_family(addr_family);
domains = g_ptr_array_sized_new(5);
- if (addr_family == AF_INET) {
- NMIP4Config * ip4 = (gpointer) ip_config;
- const NMPlatformIP4Address *address;
- const NMPlatformIP4Route * route;
-
- nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, ip4, &address)
- nm_utils_get_reverse_dns_domains_ip4(address->address, address->plen, domains);
-
- nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, ip4, &route) {
- if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route))
- nm_utils_get_reverse_dns_domains_ip4(route->network, route->plen, domains);
- }
- } else {
- NMIP6Config * ip6 = (gpointer) ip_config;
- const NMPlatformIP6Address *address;
- const NMPlatformIP6Route * route;
-
- nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, ip6, &address)
- nm_utils_get_reverse_dns_domains_ip6(&address->address, address->plen, domains);
+ nm_ip_config_iter_ip_address_for_each (&ipconf_iter, ip_config, &address) {
+ nm_utils_get_reverse_dns_domains_ip(addr_family,
+ address->address_ptr,
+ address->plen,
+ domains);
+ }
- nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, ip6, &route) {
- if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route))
- nm_utils_get_reverse_dns_domains_ip6(&route->network, route->plen, domains);
+ nm_ip_config_iter_ip_route_for_each (&ipconf_iter, ip_config, &route) {
+ if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route)) {
+ nm_utils_get_reverse_dns_domains_ip(addr_family,
+ route->network_ptr,
+ route->plen,
+ domains);
}
}
@@ -1307,7 +1331,7 @@ get_ip_rdns_domains(NMIPConfig *ip_config)
}
static gboolean
-domain_ht_get_priority(GHashTable *ht, const char *domain, int *out_priority)
+_domain_track_get_priority(GHashTable *ht, const char *domain, int *out_priority)
{
gpointer ptr;
@@ -1321,11 +1345,11 @@ domain_ht_get_priority(GHashTable *ht, const char *domain, int *out_priority)
/* Check if the domain is shadowed by a parent domain with more negative priority */
static gboolean
-domain_is_shadowed(GHashTable * ht,
- const char * domain,
- int priority,
- const char **out_parent,
- int * out_parent_priority)
+_domain_track_is_shadowed(GHashTable * ht,
+ const char * domain,
+ int priority,
+ const char **out_parent,
+ int * out_parent_priority)
{
char *parent;
int parent_priority;
@@ -1335,7 +1359,7 @@ domain_is_shadowed(GHashTable * ht,
nm_assert(!g_hash_table_contains(ht, domain));
- if (domain_ht_get_priority(ht, "", &parent_priority)) {
+ if (_domain_track_get_priority(ht, "", &parent_priority)) {
nm_assert(parent_priority <= priority);
if (parent_priority < 0 && parent_priority < priority) {
*out_parent = "";
@@ -1347,7 +1371,7 @@ domain_is_shadowed(GHashTable * ht,
parent = strchr(domain, '.');
while (parent && parent[1]) {
parent++;
- if (domain_ht_get_priority(ht, parent, &parent_priority)) {
+ if (_domain_track_get_priority(ht, parent, &parent_priority)) {
nm_assert(parent_priority <= priority);
if (parent_priority < 0 && parent_priority < priority) {
*out_parent = parent;
@@ -1362,18 +1386,18 @@ domain_is_shadowed(GHashTable * ht,
}
static void
-rebuild_domain_lists(NMDnsManager *self)
+_mgr_configs_data_construct(NMDnsManager *self)
{
- NMDnsIPConfigData *ip_data;
+ NMDnsConfigIPData *ip_data;
gs_unref_hashtable GHashTable *ht = NULL;
gs_unref_hashtable GHashTable *wildcard_entries = NULL;
CList * head;
int prev_priority = G_MININT;
- head = _ip_config_lst_head(self);
+ head = _mgr_get_ip_configs_lst_head(self);
#if NM_MORE_ASSERTS
- /* we call clear_domain_lists() at the end of update. We
+ /* we call _mgr_configs_data_clear() at the end of update. We
* don't expect any domain settings here. */
c_list_for_each_entry (ip_data, head, ip_config_lst) {
nm_assert(!ip_data->domains.search);
@@ -1496,7 +1520,7 @@ rebuild_domain_lists(NMDnsManager *self)
break;
/* Remove domains with lower priority */
- if (domain_ht_get_priority(ht, domain_clean, &old_priority)) {
+ if (_domain_track_get_priority(ht, domain_clean, &old_priority)) {
nm_assert(old_priority <= priority);
if (old_priority < priority) {
_LOGT("plugin: drop domain %s%s%s (i=%d, p=%d) because it already exists "
@@ -1511,7 +1535,11 @@ rebuild_domain_lists(NMDnsManager *self)
old_priority);
continue;
}
- } else if (domain_is_shadowed(ht, domain_clean, priority, &parent, &parent_priority)) {
+ } else if (_domain_track_is_shadowed(ht,
+ domain_clean,
+ priority,
+ &parent,
+ &parent_priority)) {
_LOGT("plugin: drop domain %s%s%s (i=%d, p=%d) shadowed by '%s' (p=%d)",
NM_PRINT_FMT_QUOTED(!check_default_route,
"'",
@@ -1578,12 +1606,12 @@ rebuild_domain_lists(NMDnsManager *self)
}
static void
-clear_domain_lists(NMDnsManager *self)
+_mgr_configs_data_clear(NMDnsManager *self)
{
- NMDnsIPConfigData *ip_data;
+ NMDnsConfigIPData *ip_data;
CList * head;
- head = _ip_config_lst_head(self);
+ head = _mgr_get_ip_configs_lst_head(self);
c_list_for_each_entry (ip_data, head, ip_config_lst) {
nm_clear_g_free(&ip_data->domains.search);
nm_clear_pointer(&ip_data->domains.reverse, g_strfreev);
@@ -1593,6 +1621,8 @@ clear_domain_lists(NMDnsManager *self)
}
}
+/*****************************************************************************/
+
static gboolean
update_dns(NMDnsManager *self, gboolean no_caching, GError **error)
{
@@ -1645,12 +1675,12 @@ update_dns(NMDnsManager *self, gboolean no_caching, GError **error)
&nis_domain);
if (priv->plugin || priv->sd_resolve_plugin)
- rebuild_domain_lists(self);
+ _mgr_configs_data_construct(self);
if (priv->sd_resolve_plugin) {
nm_dns_plugin_update(priv->sd_resolve_plugin,
global_config,
- _ip_config_lst_head(self),
+ _mgr_get_ip_configs_lst_head(self),
priv->hostname,
NULL);
}
@@ -1672,7 +1702,7 @@ update_dns(NMDnsManager *self, gboolean no_caching, GError **error)
_LOGD("update-dns: updating plugin %s", plugin_name);
if (!nm_dns_plugin_update(plugin,
global_config,
- _ip_config_lst_head(self),
+ _mgr_get_ip_configs_lst_head(self),
priv->hostname,
&plugin_error)) {
_LOGW("update-dns: plugin %s update failed: %s", plugin_name, plugin_error->message);
@@ -1689,7 +1719,7 @@ plugin_skip:;
/* Clear the generated search list as it points to
* strings owned by IP configurations and we can't
* guarantee they stay alive. */
- clear_domain_lists(self);
+ _mgr_configs_data_clear(self);
update_resolv_conf_no_stub(self,
NM_CAST_STRV_CC(searches),
@@ -1805,11 +1835,11 @@ plugin_skip:;
/*****************************************************************************/
static void
-_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsIPConfigData *ip_data)
+_ip_config_dns_priority_changed(gpointer config, GParamSpec *pspec, NMDnsConfigIPData *ip_data)
{
- _ASSERT_ip_config_data(ip_data);
+ _ASSERT_dns_config_ip_data(ip_data);
- NM_DNS_MANAGER_GET_PRIVATE(ip_data->data->self)->ip_config_lst_need_sort = TRUE;
+ NM_DNS_MANAGER_GET_PRIVATE(ip_data->data->self)->ip_configs_lst_need_sort = TRUE;
}
gboolean
@@ -1818,10 +1848,10 @@ nm_dns_manager_set_ip_config(NMDnsManager * self,
NMDnsIPConfigType ip_config_type)
{
NMDnsManagerPrivate *priv;
- NMDnsIPConfigData * ip_data;
+ NMDnsConfigIPData * ip_data;
NMDnsConfigData * data;
int ifindex;
- NMDnsIPConfigData ** p_best;
+ NMDnsConfigIPData ** p_best;
g_return_val_if_fail(NM_IS_DNS_MANAGER(self), FALSE);
g_return_val_if_fail(NM_IS_IP_CONFIG(ip_config), FALSE);
@@ -1831,11 +1861,11 @@ nm_dns_manager_set_ip_config(NMDnsManager * self,
priv = NM_DNS_MANAGER_GET_PRIVATE(self);
- data = g_hash_table_lookup(priv->configs, &ifindex);
+ data = g_hash_table_lookup(priv->configs_dict, &ifindex);
if (!data)
ip_data = NULL;
else
- ip_data = _config_data_find_ip_config(data, ip_config);
+ ip_data = _dns_config_data_find_ip_config(data, ip_config);
if (ip_config_type == NM_DNS_IP_CONFIG_TYPE_REMOVED) {
if (!ip_data)
@@ -1845,9 +1875,9 @@ nm_dns_manager_set_ip_config(NMDnsManager * self,
if (priv->best_ip_config_6 == ip_data)
priv->best_ip_config_6 = NULL;
/* deleting a config doesn't invalidate the configs' sort order. */
- _ip_config_data_free(ip_data);
+ _dns_config_ip_data_free(ip_data);
if (c_list_is_empty(&data->data_lst_head))
- g_hash_table_remove(priv->configs, &ifindex);
+ g_hash_table_remove(priv->configs_dict, &ifindex);
goto changed;
}
@@ -1863,16 +1893,18 @@ nm_dns_manager_set_ip_config(NMDnsManager * self,
.self = self,
.data_lst_head = C_LIST_INIT(data->data_lst_head),
};
- _ASSERT_config_data(data);
- g_hash_table_add(priv->configs, data);
+ _ASSERT_dns_config_data(data);
+ g_hash_table_add(priv->configs_dict, data);
+ c_list_link_tail(&priv->configs_lst_head, &data->configs_lst);
+ priv->configs_lst_need_sort = TRUE;
}
if (!ip_data)
- ip_data = _ip_config_data_new(data, ip_config, ip_config_type);
+ ip_data = _dns_config_ip_data_new(data, ip_config, ip_config_type);
else
ip_data->ip_config_type = ip_config_type;
- priv->ip_config_lst_need_sort = TRUE;
+ priv->ip_configs_lst_need_sort = TRUE;
p_best = NM_IS_IP4_CONFIG(ip_config) ? &priv->best_ip_config_4 : &priv->best_ip_config_6;
@@ -2392,7 +2424,7 @@ _get_config_variant(NMDnsManager *self)
NMGlobalDnsConfig * global_config;
gs_free char * str = NULL;
GVariantBuilder builder;
- NMDnsIPConfigData * ip_data;
+ NMDnsConfigIPData * ip_data;
const CList * head;
gs_unref_ptrarray GPtrArray *array_domains = NULL;
@@ -2408,7 +2440,7 @@ _get_config_variant(NMDnsManager *self)
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
- head = _ip_config_lst_head(self);
+ head = _mgr_get_ip_configs_lst_head(self);
c_list_for_each_entry (ip_data, head, ip_config_lst) {
const NMIPConfig *ip_config = ip_data->ip_config;
GVariantBuilder entry_builder;
@@ -2513,15 +2545,16 @@ nm_dns_manager_init(NMDnsManager *self)
_LOGT("creating...");
- c_list_init(&priv->ip_config_lst_head);
+ c_list_init(&priv->configs_lst_head);
+ c_list_init(&priv->ip_configs_lst_head);
priv->config = g_object_ref(nm_config_get());
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMDnsConfigData, ifindex) == 0);
- priv->configs = g_hash_table_new_full(nm_pint_hash,
- nm_pint_equals,
- (GDestroyNotify) _config_data_free,
- NULL);
+ priv->configs_dict = g_hash_table_new_full(nm_pint_hash,
+ nm_pint_equals,
+ (GDestroyNotify) _dns_config_data_free,
+ NULL);
/* Set the initial hash */
compute_hash(self, NULL, NM_DNS_MANAGER_GET_PRIVATE(self)->hash);
@@ -2538,7 +2571,7 @@ dispose(GObject *object)
{
NMDnsManager * self = NM_DNS_MANAGER(object);
NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE(self);
- NMDnsIPConfigData * ip_data, *ip_data_safe;
+ NMDnsConfigIPData * ip_data, *ip_data_safe;
_LOGT("disposing");
@@ -2554,10 +2587,11 @@ dispose(GObject *object)
priv->best_ip_config_4 = NULL;
priv->best_ip_config_6 = NULL;
- c_list_for_each_entry_safe (ip_data, ip_data_safe, &priv->ip_config_lst_head, ip_config_lst)
- _ip_config_data_free(ip_data);
+ c_list_for_each_entry_safe (ip_data, ip_data_safe, &priv->ip_configs_lst_head, ip_config_lst)
+ _dns_config_ip_data_free(ip_data);
- nm_clear_pointer(&priv->configs, g_hash_table_destroy);
+ nm_clear_pointer(&priv->configs_dict, g_hash_table_destroy);
+ nm_assert(c_list_is_empty(&priv->configs_lst_head));
nm_clear_g_source(&priv->plugin_ratelimit.timer);
diff --git a/src/dns/nm-dns-manager.h b/src/dns/nm-dns-manager.h
index fb2f36d22..7f104ebe0 100644
--- a/src/dns/nm-dns-manager.h
+++ b/src/dns/nm-dns-manager.h
@@ -25,6 +25,8 @@ enum {
NM_DNS_PRIORITY_DEFAULT_VPN = 50,
};
+/*****************************************************************************/
+
struct _NMDnsConfigData;
struct _NMDnsManager;
@@ -60,14 +62,17 @@ typedef struct {
* With systemd-resolved, this is the value for SetLinkDefaultRoute(). */
bool has_default_route : 1;
} domains;
-} NMDnsIPConfigData;
+} NMDnsConfigIPData;
typedef struct _NMDnsConfigData {
int ifindex;
struct _NMDnsManager *self;
CList data_lst_head;
+ CList configs_lst;
} NMDnsConfigData;
+/*****************************************************************************/
+
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type())
#define NM_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), NM_TYPE_DNS_MANAGER, NMDnsManager))
#define NM_DNS_MANAGER_CLASS(k) \
diff --git a/src/dns/nm-dns-plugin.h b/src/dns/nm-dns-plugin.h
index 5e87f59b2..b5cffccb4 100644
--- a/src/dns/nm-dns-plugin.h
+++ b/src/dns/nm-dns-plugin.h
@@ -26,7 +26,7 @@ typedef struct {
GObjectClass parent;
/* Called when DNS information is changed. 'configs' is an array
- * of pointers to NMDnsIPConfigData sorted by priority.
+ * of pointers to NMDnsConfigIPData sorted by priority.
* 'global_config' is the optional global DNS
* configuration.
*/
diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c
index 4db7da419..089a5c9bb 100644
--- a/src/dns/nm-dns-systemd-resolved.c
+++ b/src/dns/nm-dns-systemd-resolved.c
@@ -139,7 +139,7 @@ static gboolean
update_add_ip_config(NMDnsSystemdResolved *self,
GVariantBuilder * dns,
GVariantBuilder * domains,
- NMDnsIPConfigData * data)
+ NMDnsConfigIPData * data)
{
int addr_family;
gsize addr_size;
@@ -216,7 +216,7 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic)
g_variant_builder_open(&domains, G_VARIANT_TYPE("a(sb)"));
c_list_for_each_entry (elem, &ic->configs_lst_head, lst) {
- NMDnsIPConfigData *data = elem->data;
+ NMDnsConfigIPData *data = elem->data;
NMIPConfig * ip_config = data->ip_config;
has_config |= update_add_ip_config(self, &dns, &domains, data);
@@ -367,7 +367,7 @@ update(NMDnsPlugin * plugin,
gs_free gpointer * interfaces_keys = NULL;
guint interfaces_len;
int ifindex;
- NMDnsIPConfigData *ip_data;
+ NMDnsConfigIPData *ip_data;
GHashTableIter iter;
guint i;
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index 1f816f84e..81879be87 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -4381,7 +4381,7 @@ nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size)
}
/**
- * nm_utils_get_reverse_dns_domains_ip4:
+ * nm_utils_get_reverse_dns_domains_ip_4:
* @addr: IP address in network order
* @plen: prefix length
* @domains: array for results
@@ -4390,7 +4390,7 @@ nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size)
* append them to @domains.
*/
void
-nm_utils_get_reverse_dns_domains_ip4(guint32 addr, guint8 plen, GPtrArray *domains)
+nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *domains)
{
guint32 ip, ip2, mask;
guchar *p;
@@ -4429,7 +4429,7 @@ nm_utils_get_reverse_dns_domains_ip4(guint32 addr, guint8 plen, GPtrArray *domai
}
/**
- * nm_utils_get_reverse_dns_domains_ip6:
+ * nm_utils_get_reverse_dns_domains_ip_6:
* @addr: IPv6 address
* @plen: prefix length
* @domains: array for results
@@ -4438,7 +4438,7 @@ nm_utils_get_reverse_dns_domains_ip4(guint32 addr, guint8 plen, GPtrArray *domai
* append them to @domains.
*/
void
-nm_utils_get_reverse_dns_domains_ip6(const struct in6_addr *ip, guint8 plen, GPtrArray *domains)
+nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GPtrArray *domains)
{
struct in6_addr addr;
guint nibbles, bits, entries;
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index dcc354c75..5c8bac9c8 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -532,9 +532,21 @@ nm_utils_ip4_address_is_zeronet(in_addr_t network)
const char *nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size);
-void nm_utils_get_reverse_dns_domains_ip4(guint32 ip, guint8 plen, GPtrArray *domains);
+void nm_utils_get_reverse_dns_domains_ip_4(guint32 ip, guint8 plen, GPtrArray *domains);
void
-nm_utils_get_reverse_dns_domains_ip6(const struct in6_addr *ip, guint8 plen, GPtrArray *domains);
+nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GPtrArray *domains);
+
+static inline void
+nm_utils_get_reverse_dns_domains_ip(int addr_family,
+ gconstpointer addr,
+ guint8 plen,
+ GPtrArray * domains)
+{
+ if (NM_IS_IPv4(addr_family))
+ nm_utils_get_reverse_dns_domains_ip_4(*((const in_addr_t *) addr), plen, domains);
+ else
+ nm_utils_get_reverse_dns_domains_ip_6(addr, plen, domains);
+}
struct stat;
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index e1f231e52..c8bad3a8d 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -319,14 +319,21 @@ NM_IS_IP_CONFIG_ADDR_FAMILY(gconstpointer config, int addr_family)
NM_CONSTCAST_FULL(NMIPConfig, (config), _configx, NMIP4Config, NMIP6Config); \
})
+static inline gboolean
+nm_ip_config_is_ipv4(const NMIPConfig *config)
+{
+ if (NM_IP_CONFIG_GET_CLASS(config)->is_ipv4) {
+ nm_assert(NM_IS_IP4_CONFIG(config));
+ return TRUE;
+ }
+ nm_assert(NM_IS_IP6_CONFIG(config));
+ return FALSE;
+}
+
static inline int
nm_ip_config_get_addr_family(const NMIPConfig *config)
{
- if (NM_IS_IP4_CONFIG(config))
- return AF_INET;
- if (NM_IS_IP6_CONFIG(config))
- return AF_INET6;
- g_return_val_if_reached(AF_UNSPEC);
+ return nm_ip_config_is_ipv4(config) ? AF_INET : AF_INET6;
}
#define _NM_IP_CONFIG_DISPATCH(config, v4_func, v6_func, ...) \
@@ -334,10 +341,9 @@ nm_ip_config_get_addr_family(const NMIPConfig *config)
{ \
gconstpointer _config = (config); \
\
- if (NM_IS_IP4_CONFIG(_config)) { \
+ if (nm_ip_config_is_ipv4(_config)) { \
return v4_func((NMIP4Config *) _config, ##__VA_ARGS__); \
} else { \
- nm_assert(NM_IS_IP6_CONFIG(_config)); \
return v6_func((NMIP6Config *) _config, ##__VA_ARGS__); \
} \
} \
@@ -348,10 +354,9 @@ nm_ip_config_get_addr_family(const NMIPConfig *config)
{ \
gconstpointer _config = (config); \
\
- if (NM_IS_IP4_CONFIG(_config)) { \
+ if (nm_ip_config_is_ipv4(_config)) { \
v4_func((NMIP4Config *) _config, ##__VA_ARGS__); \
} else { \
- nm_assert(NM_IS_IP6_CONFIG(_config)); \
v6_func((NMIP6Config *) _config, ##__VA_ARGS__); \
} \
} \
@@ -376,6 +381,32 @@ nm_ip_config_get_first_address(NMIPConfig *self)
}
static inline void
+nm_ip_config_iter_ip_address_init(NMDedupMultiIter *iter, const NMIPConfig *self)
+{
+ if (nm_ip_config_is_ipv4(self))
+ nm_ip_config_iter_ip4_address_init(iter, (const NMIP4Config *) self);
+ else
+ nm_ip_config_iter_ip6_address_init(iter, (const NMIP6Config *) self);
+}
+
+#define nm_ip_config_iter_ip_address_for_each(iter, self, address) \
+ for (nm_ip_config_iter_ip_address_init((iter), (self)); \
+ nm_platform_dedup_multi_iter_next_ip_address((iter), (address));)
+
+static inline void
+nm_ip_config_iter_ip_route_init(NMDedupMultiIter *iter, const NMIPConfig *self)
+{
+ if (nm_ip_config_is_ipv4(self))
+ nm_ip_config_iter_ip4_route_init(iter, (const NMIP4Config *) self);
+ else
+ nm_ip_config_iter_ip6_route_init(iter, (const NMIP6Config *) self);
+}
+
+#define nm_ip_config_iter_ip_route_for_each(iter, self, route) \
+ for (nm_ip_config_iter_ip_route_init((iter), (self)); \
+ nm_platform_dedup_multi_iter_next_ip_route((iter), (route));)
+
+static inline void
nm_ip_config_add_address(NMIPConfig *self, const NMPlatformIPAddress *address)
{
_NM_IP_CONFIG_DISPATCH_VOID(self,
@@ -549,11 +580,9 @@ nm_ip_config_set_never_default(NMIPConfig *self, gboolean never_default)
gpointer _dst = (dst); \
gconstpointer _src = (src); \
\
- if (NM_IS_IP4_CONFIG(_dst)) { \
- nm_assert(NM_IS_IP4_CONFIG(_src)); \
+ if (nm_ip_config_is_ipv4(_dst)) { \
_return v4_func((NMIP4Config *) _dst, (const NMIP4Config *) _src, ##__VA_ARGS__); \
} else { \
- nm_assert(NM_IS_IP6_CONFIG(_src)); \
_return v6_func((NMIP6Config *) _dst, (const NMIP6Config *) _src, ##__VA_ARGS__); \
} \
} \
@@ -616,7 +645,8 @@ nm_ip_config_intersect_alloc(const NMIPConfig *a,
gboolean intersect_routes,
guint32 default_route_metric_penalty)
{
- if (NM_IS_IP4_CONFIG(a)) {
+ if (nm_ip_config_is_ipv4(a)) {
+ nm_assert(NM_IS_IP4_CONFIG(a));
nm_assert(NM_IS_IP4_CONFIG(b));
return (NMIPConfig *) nm_ip4_config_intersect_alloc((const NMIP4Config *) a,
(const NMIP4Config *) b,
diff --git a/src/nm-pacrunner-manager.c b/src/nm-pacrunner-manager.c
index 0fb319848..7c1c2c56a 100644
--- a/src/nm-pacrunner-manager.c
+++ b/src/nm-pacrunner-manager.c
@@ -126,11 +126,13 @@ NM_AUTO_DEFINE_FCN0(NMPacrunnerConfId *, _nm_auto_unref_conf_id, conf_id_unref);
static void
get_ip_domains(GPtrArray *domains, NMIPConfig *ip_config)
{
- NMDedupMultiIter ipconf_iter;
- char * cidr;
- guint i, num;
- char sbuf[NM_UTILS_INET_ADDRSTRLEN];
- int addr_family;
+ NMDedupMultiIter ipconf_iter;
+ char * cidr;
+ guint i, num;
+ char sbuf[NM_UTILS_INET_ADDRSTRLEN];
+ int addr_family;
+ const NMPlatformIPAddress *address;
+ const NMPlatformIPRoute * routes;
if (!ip_config)
return;
@@ -145,47 +147,20 @@ get_ip_domains(GPtrArray *domains, NMIPConfig *ip_config)
for (i = 0; i < num; i++)
g_ptr_array_add(domains, g_strdup(nm_ip_config_get_domain(ip_config, i)));
- if (addr_family == AF_INET) {
- const NMPlatformIP4Address *address;
-
- nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, (NMIP4Config *) ip_config, &address) {
- cidr = g_strdup_printf("%s/%u",
- _nm_utils_inet4_ntop(address->address, sbuf),
- address->plen);
- g_ptr_array_add(domains, cidr);
- }
- } else {
- const NMPlatformIP6Address *address;
-
- nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, (NMIP6Config *) ip_config, &address) {
- cidr = g_strdup_printf("%s/%u",
- _nm_utils_inet6_ntop(&address->address, sbuf),
- address->plen);
- g_ptr_array_add(domains, cidr);
- }
+ nm_ip_config_iter_ip_address_for_each (&ipconf_iter, ip_config, &address) {
+ cidr = g_strdup_printf("%s/%u",
+ nm_utils_inet_ntop(addr_family, address->address_ptr, sbuf),
+ address->plen);
+ g_ptr_array_add(domains, cidr);
}
- if (addr_family == AF_INET) {
- const NMPlatformIP4Route *routes;
-
- nm_ip_config_iter_ip4_route_for_each (&ipconf_iter, (NMIP4Config *) ip_config, &routes) {
- if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(routes))
- continue;
- cidr =
- g_strdup_printf("%s/%u", _nm_utils_inet4_ntop(routes->network, sbuf), routes->plen);
- g_ptr_array_add(domains, cidr);
- }
- } else {
- const NMPlatformIP6Route *routes;
-
- nm_ip_config_iter_ip6_route_for_each (&ipconf_iter, (NMIP6Config *) ip_config, &routes) {
- if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(routes))
- continue;
- cidr = g_strdup_printf("%s/%u",
- _nm_utils_inet6_ntop(&routes->network, sbuf),
- routes->plen);
- g_ptr_array_add(domains, cidr);
- }
+ nm_ip_config_iter_ip_route_for_each (&ipconf_iter, ip_config, &routes) {
+ if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT(routes))
+ continue;
+ cidr = g_strdup_printf("%s/%u",
+ nm_utils_inet_ntop(addr_family, routes->network_ptr, sbuf),
+ routes->plen);
+ g_ptr_array_add(domains, cidr);
}
}
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index 58f54dbe0..5480f8391 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -1077,52 +1077,64 @@ nm_platform_dedup_multi_iter_next_obj(NMDedupMultiIter *ipconf_iter,
return has_next;
}
-static inline gboolean
-nm_platform_dedup_multi_iter_next_ip4_address(NMDedupMultiIter * ipconf_iter,
- const NMPlatformIP4Address **out_address)
-{
- gboolean has_next;
-
- has_next = nm_dedup_multi_iter_next(ipconf_iter);
- if (out_address)
- *out_address = has_next ? NMP_OBJECT_CAST_IP4_ADDRESS(ipconf_iter->current->obj) : NULL;
- return has_next;
-}
-
-static inline gboolean
-nm_platform_dedup_multi_iter_next_ip4_route(NMDedupMultiIter * ipconf_iter,
- const NMPlatformIP4Route **out_route)
-{
- gboolean has_next;
-
- has_next = nm_dedup_multi_iter_next(ipconf_iter);
- if (out_route)
- *out_route = has_next ? NMP_OBJECT_CAST_IP4_ROUTE(ipconf_iter->current->obj) : NULL;
- return has_next;
-}
-
-static inline gboolean
-nm_platform_dedup_multi_iter_next_ip6_address(NMDedupMultiIter * ipconf_iter,
- const NMPlatformIP6Address **out_address)
-{
- gboolean has_next;
-
- has_next = nm_dedup_multi_iter_next(ipconf_iter);
- if (out_address)
- *out_address = has_next ? NMP_OBJECT_CAST_IP6_ADDRESS(ipconf_iter->current->obj) : NULL;
- return has_next;
-}
-
-static inline gboolean
-nm_platform_dedup_multi_iter_next_ip6_route(NMDedupMultiIter * ipconf_iter,
- const NMPlatformIP6Route **out_route)
-{
- gboolean has_next;
+#define _nm_platform_dedup_multi_iter_next(ipconf_iter, out_obj, field, ...) \
+ ({ \
+ NMDedupMultiIter *const _ipconf_iter = (ipconf_iter); \
+ const typeof(((NMPObject *) NULL)->field) **const _out_obj = (out_obj); \
+ gboolean _has_next; \
+ \
+ if (G_LIKELY(nm_dedup_multi_iter_next(_ipconf_iter))) { \
+ if (_out_obj) { \
+ *_out_obj = _NMP_OBJECT_CAST(_ipconf_iter->current->obj, field, __VA_ARGS__); \
+ } else { \
+ nm_assert( \
+ NM_IN_SET(NMP_OBJECT_GET_TYPE(_ipconf_iter->current->obj), __VA_ARGS__)); \
+ } \
+ _has_next = TRUE; \
+ } else { \
+ if (_out_obj) \
+ *_out_obj = NULL; \
+ _has_next = FALSE; \
+ } \
+ _has_next; \
+ })
- has_next = nm_dedup_multi_iter_next(ipconf_iter);
- if (out_route)
- *out_route = has_next ? NMP_OBJECT_CAST_IP6_ROUTE(ipconf_iter->current->obj) : NULL;
- return has_next;
-}
+#define nm_platform_dedup_multi_iter_next_ip_address(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip_address, \
+ NMP_OBJECT_TYPE_IP4_ADDRESS, \
+ NMP_OBJECT_TYPE_IP6_ADDRESS)
+
+#define nm_platform_dedup_multi_iter_next_ip4_address(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip4_address, \
+ NMP_OBJECT_TYPE_IP4_ADDRESS)
+
+#define nm_platform_dedup_multi_iter_next_ip6_address(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip6_address, \
+ NMP_OBJECT_TYPE_IP6_ADDRESS)
+
+#define nm_platform_dedup_multi_iter_next_ip_route(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip_route, \
+ NMP_OBJECT_TYPE_IP4_ROUTE, \
+ NMP_OBJECT_TYPE_IP6_ROUTE)
+
+#define nm_platform_dedup_multi_iter_next_ip4_route(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip4_route, \
+ NMP_OBJECT_TYPE_IP4_ROUTE)
+
+#define nm_platform_dedup_multi_iter_next_ip6_route(ipconf_iter, out_obj) \
+ _nm_platform_dedup_multi_iter_next((ipconf_iter), \
+ (out_obj), \
+ ip6_route, \
+ NMP_OBJECT_TYPE_IP6_ROUTE)
#endif /* __NMP_OBJECT_H__ */
diff --git a/src/tests/test-core.c b/src/tests/test-core.c
index 37b4a6252..39c5ad46d 100644
--- a/src/tests/test-core.c
+++ b/src/tests/test-core.c
@@ -1929,7 +1929,7 @@ test_reverse_dns_ip4(void)
GPtrArray *domains = g_ptr_array_new_full(8, g_free);
inet_pton(AF_INET, "7.2.3.0", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 27, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 27, domains);
g_assert_cmpuint(domains->len, ==, 32);
g_assert_cmpstr(domains->pdata[0], ==, "0.3.2.7.in-addr.arpa");
g_assert_cmpstr(domains->pdata[31], ==, "31.3.2.7.in-addr.arpa");
@@ -1937,7 +1937,7 @@ test_reverse_dns_ip4(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "10.155.16.0", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 22, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 22, domains);
g_assert_cmpuint(domains->len, ==, 4);
g_assert_cmpstr(domains->pdata[0], ==, "16.155.10.in-addr.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "17.155.10.in-addr.arpa");
@@ -1947,21 +1947,21 @@ test_reverse_dns_ip4(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "4.5.6.7", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 32, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 32, domains);
g_assert_cmpuint(domains->len, ==, 1);
g_assert_cmpstr(domains->pdata[0], ==, "7.6.5.4.in-addr.arpa");
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "4.5.6.7", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 8, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 8, domains);
g_assert_cmpuint(domains->len, ==, 1);
g_assert_cmpstr(domains->pdata[0], ==, "4.in-addr.arpa");
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "4.180.6.7", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 9, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 9, domains);
g_assert_cmpuint(domains->len, ==, 128);
g_assert_cmpstr(domains->pdata[0], ==, "128.4.in-addr.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "129.4.in-addr.arpa");
@@ -1970,7 +1970,7 @@ test_reverse_dns_ip4(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "172.16.0.0", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 12, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 12, domains);
g_assert_cmpuint(domains->len, ==, 16);
g_assert_cmpstr(domains->pdata[0], ==, "16.172.in-addr.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "17.172.in-addr.arpa");
@@ -1980,7 +1980,7 @@ test_reverse_dns_ip4(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET, "1.2.3.4", &addr);
- nm_utils_get_reverse_dns_domains_ip4(addr, 0, domains);
+ nm_utils_get_reverse_dns_domains_ip_4(addr, 0, domains);
g_assert_cmpuint(domains->len, ==, 0);
g_ptr_array_unref(domains);
@@ -1993,14 +1993,14 @@ test_reverse_dns_ip6(void)
GPtrArray * domains = g_ptr_array_new_full(8, g_free);
inet_pton(AF_INET6, "1234::56", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 16, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 16, domains);
g_assert_cmpuint(domains->len, ==, 1);
g_assert_cmpstr(domains->pdata[0], ==, "4.3.2.1.ip6.arpa");
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET6, "1234::56", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 17, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 17, domains);
g_assert_cmpuint(domains->len, ==, 8);
g_assert_cmpstr(domains->pdata[0], ==, "0.4.3.2.1.ip6.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "1.4.3.2.1.ip6.arpa");
@@ -2009,7 +2009,7 @@ test_reverse_dns_ip6(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET6, "2001:db8::", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 29, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 29, domains);
g_assert_cmpuint(domains->len, ==, 8);
g_assert_cmpstr(domains->pdata[0], ==, "8.b.d.0.1.0.0.2.ip6.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "9.b.d.0.1.0.0.2.ip6.arpa");
@@ -2018,7 +2018,7 @@ test_reverse_dns_ip6(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET6, "0123:4567:89ab:cdef::", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 63, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 63, domains);
g_assert_cmpuint(domains->len, ==, 2);
g_assert_cmpstr(domains->pdata[0], ==, "e.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.ip6.arpa");
g_assert_cmpstr(domains->pdata[1], ==, "f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.ip6.arpa");
@@ -2026,7 +2026,7 @@ test_reverse_dns_ip6(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET6, "fec0:1234:5678:9ab0::", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 61, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 61, domains);
g_assert_cmpuint(domains->len, ==, 8);
g_assert_cmpstr(domains->pdata[0], ==, "0.b.a.9.8.7.6.5.4.3.2.1.0.c.e.f.ip6.arpa");
g_assert_cmpstr(domains->pdata[7], ==, "7.b.a.9.8.7.6.5.4.3.2.1.0.c.e.f.ip6.arpa");
@@ -2034,7 +2034,7 @@ test_reverse_dns_ip6(void)
g_ptr_array_set_size(domains, 0);
inet_pton(AF_INET6, "0123:4567:89ab:cdee::", &addr);
- nm_utils_get_reverse_dns_domains_ip6(&addr, 0, domains);
+ nm_utils_get_reverse_dns_domains_ip_6(&addr, 0, domains);
g_assert_cmpuint(domains->len, ==, 0);
g_ptr_array_unref(domains);