core: simplify nm_l3_config_data_add_nameserver_detail()

Remove unused "server_name" argument. It is still possible to pass the
server name, if needed, with the nm_l3_config_data_add_nameserver()
function. After this change, rename the function to
nm_l3_config_data_add_nameserver_addr(), since the function only
accepts an address.
This commit is contained in:
Beniamino Galvani
2024-12-16 17:47:46 +01:00
parent 85484ab2d3
commit 28668f8698
11 changed files with 19 additions and 34 deletions

View File

@@ -3739,7 +3739,7 @@ nm_device_iwd_parse_netconfig(NMDeviceIwd *self, int addr_family, GVariantIter *
if (inet_pton(addr_family, str_value, &dns_bin) != 1)
goto param_error;
nm_l3_config_data_add_nameserver_detail(l3cd, addr_family, &dns_bin, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, addr_family, &dns_bin);
nm_l3_config_data_set_dns_priority(l3cd, addr_family, NM_DNS_PRIORITY_DEFAULT_NORMAL);
}
}

View File

@@ -1162,7 +1162,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho
dns = mm_bearer_ip_config_get_dns(self->_priv.ipv4_config);
for (i = 0; dns && dns[i]; i++) {
if (nm_inet_parse_bin(AF_INET, dns[i], NULL, &address_network) && address_network > 0) {
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET, &address_network, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET, &address_network);
_LOGI(" DNS %s", dns[i]);
}
}
@@ -1281,7 +1281,7 @@ stage3_ip_config_start(NMModem *modem, int addr_family, NMModemIPMethod ip_metho
struct in6_addr addr;
if (inet_pton(AF_INET6, dns[i], &addr)) {
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET6, &addr, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET6, &addr);
_LOGI(" DNS %s", dns[i]);
}
}

View File

@@ -1315,7 +1315,7 @@ handle_settings(NMModemOfono *self, GVariant *v_dict)
}
any_good = TRUE;
_LOGI("DNS: %s", array[i]);
nm_l3_config_data_add_nameserver_detail(priv->l3cd_4, AF_INET, &address_network, NULL);
nm_l3_config_data_add_nameserver_addr(priv->l3cd_4, AF_INET, &address_network);
}
if (!any_good) {
_LOGW("Settings: 'DomainNameServers': none specified");

View File

@@ -387,7 +387,7 @@ lease_parse_address_list(NDhcp4ClientLease *lease,
nm_inet4_ntop(addr, addr_str));
continue;
}
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET, &addr, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET, &addr);
break;
case NM_DHCP_OPTION_DHCP4_NIS_SERVERS:
nm_l3_config_data_add_nis_server(l3cd, addr);

View File

@@ -157,7 +157,7 @@ lease_to_ip6_config(NMDhcpSystemd *self, sd_dhcp6_lease *lease, gint32 ts, GErro
for (i = 0; i < num; i++) {
nm_inet6_ntop(&dns[i], addr_str);
g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET6, &dns[i], NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET6, &dns[i]);
}
nm_dhcp_option_add_option(options,
TRUE,

View File

@@ -499,7 +499,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
for (s = dns; dns && *s; s++) {
if (inet_pton(AF_INET, *s, &tmp_addr) > 0) {
if (tmp_addr) {
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET, &tmp_addr, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET, &tmp_addr);
_LOG2I(LOGD_DHCP4, iface, " nameserver '%s'", *s);
}
} else
@@ -704,7 +704,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx,
for (s = dns; dns && *s; s++) {
if (inet_pton(AF_INET6, *s, &tmp_addr) > 0) {
if (!IN6_IS_ADDR_UNSPECIFIED(&tmp_addr)) {
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET6, &tmp_addr, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET6, &tmp_addr);
_LOG2I(LOGD_DHCP6, iface, " nameserver '%s'", *s);
}
} else

View File

@@ -205,10 +205,7 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex *multi_idx,
}
for (i = 0; i < rdata->dns_servers_n; i++) {
nm_l3_config_data_add_nameserver_detail(l3cd,
AF_INET6,
&rdata->dns_servers[i].address,
NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET6, &rdata->dns_servers[i].address);
}
for (i = 0; i < rdata->dns_domains_n; i++)

View File

@@ -1474,27 +1474,16 @@ nm_l3_config_data_add_nameserver(NML3ConfigData *self, int addr_family, const ch
}
gboolean
nm_l3_config_data_add_nameserver_detail(NML3ConfigData *self,
int addr_family,
gconstpointer addr_bin,
const char *server_name)
nm_l3_config_data_add_nameserver_addr(NML3ConfigData *self, int addr_family, gconstpointer addr_bin)
{
gs_free char *s_free = NULL;
char *s;
gsize l;
char addrstr[NM_INET_ADDRSTRLEN];
nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE));
nm_assert_addr_family(addr_family);
nm_assert(addr_bin);
l = (NM_INET_ADDRSTRLEN + 2u) + (server_name ? strlen(server_name) : 0u);
s = nm_malloc_maybe_a(300, l, &s_free);
if (!nm_utils_dnsname_construct(addr_family, addr_bin, server_name, s, l))
nm_assert_not_reached();
return nm_l3_config_data_add_nameserver(self, addr_family, s);
nm_inet_ntop(addr_family, addr_bin, addrstr);
return nm_l3_config_data_add_nameserver(self, addr_family, addrstr);
}
gboolean

View File

@@ -500,10 +500,9 @@ nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, g
gboolean
nm_l3_config_data_add_nameserver(NML3ConfigData *self, int addr_family, const char *nameserver);
gboolean nm_l3_config_data_add_nameserver_detail(NML3ConfigData *self,
int addr_family,
gconstpointer addr_bin,
const char *server_name);
gboolean nm_l3_config_data_add_nameserver_addr(NML3ConfigData *self,
int addr_family,
gconstpointer addr_bin);
gboolean nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family);

View File

@@ -583,7 +583,7 @@ impl_ppp_manager_set_ip4_config(NMDBusObject *obj,
if (g_variant_lookup(config_dict, NM_PPP_IP4_CONFIG_DNS, "au", &iter)) {
while (g_variant_iter_next(iter, "u", &u32))
nm_l3_config_data_add_nameserver_detail(l3cd, AF_INET, &u32, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, AF_INET, &u32);
g_variant_iter_free(iter);
}

View File

@@ -2060,14 +2060,14 @@ _dbus_signal_ip_config_cb(NMVpnConnection *self, int addr_family, GVariant *dict
if (IS_IPv4) {
if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP4_CONFIG_DNS, "au", &var_iter)) {
while (g_variant_iter_next(var_iter, "u", &u32))
nm_l3_config_data_add_nameserver_detail(l3cd, addr_family, &u32, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, addr_family, &u32);
g_variant_iter_free(var_iter);
}
} else {
if (g_variant_lookup(dict, NM_VPN_PLUGIN_IP6_CONFIG_DNS, "aay", &var_iter)) {
while (g_variant_iter_next(var_iter, "@ay", &v)) {
if (nm_ip_addr_set_from_variant(AF_INET6, &v_addr, v, NULL))
nm_l3_config_data_add_nameserver_detail(l3cd, addr_family, &v_addr, NULL);
nm_l3_config_data_add_nameserver_addr(l3cd, addr_family, &v_addr);
g_variant_unref(v);
}
g_variant_iter_free(var_iter);