core: extend NML3ConfigData:nameserver to track DNS as string

The DNS name can now also contain the DoT server name. It's not longer a
binary IP address only.

Extend NML3ConfigData to account for that. To track the additional
data, use the string representation. The alternative to have a separate
type that contains the parsed information would be cumbersome too.
This commit is contained in:
Thomas Haller
2022-10-17 12:07:54 +02:00
parent 6f9090538f
commit c68e148b02
19 changed files with 248 additions and 204 deletions

View File

@@ -10781,13 +10781,13 @@ nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device)
} }
if (l3cd_src) { if (l3cd_src) {
const char *const *strvarr; const char *const *strvarr;
const struct in6_addr *addrs; const char *const *addrs;
guint n; guint n;
guint i; guint i;
addrs = nm_l3_config_data_get_nameservers(l3cd_src, AF_INET6, &n); addrs = nm_l3_config_data_get_nameservers(l3cd_src, AF_INET6, &n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &addrs[i]); nm_l3_config_data_add_nameserver(l3cd, AF_INET6, addrs[i]);
strvarr = nm_l3_config_data_get_searches(l3cd_src, AF_INET6, &n); strvarr = nm_l3_config_data_get_searches(l3cd_src, AF_INET6, &n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)

View File

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

View File

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

View File

@@ -846,7 +846,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
} }
any_good = TRUE; any_good = TRUE;
_LOGI("DNS: %s", *array); _LOGI("DNS: %s", *array);
nm_l3_config_data_add_nameserver(priv->l3cd_4, AF_INET, &address_network); nm_l3_config_data_add_nameserver_detail(priv->l3cd_4, AF_INET, &address_network, NULL);
} }
if (!any_good) { if (!any_good) {
_LOGW("Settings: 'DomainNameServers': none specified"); _LOGW("Settings: 'DomainNameServers': none specified");

View File

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

View File

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

View File

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

View File

@@ -88,7 +88,6 @@ test_generic_options(void)
const char *expected_route2_dest = "100.99.88.56"; const char *expected_route2_dest = "100.99.88.56";
const char *expected_route2_gw = "10.1.1.1"; const char *expected_route2_gw = "10.1.1.1";
const char *const *strarr; const char *const *strarr;
const in_addr_t *ia_arr;
guint u; guint u;
options = fill_table(generic_options, NULL); options = fill_table(generic_options, NULL);
@@ -115,10 +114,10 @@ test_generic_options(void)
g_assert_cmpstr(strarr[0], ==, expected_search1); g_assert_cmpstr(strarr[0], ==, expected_search1);
g_assert_cmpstr(strarr[1], ==, expected_search2); g_assert_cmpstr(strarr[1], ==, expected_search2);
ia_arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &u); strarr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &u);
g_assert_cmpint(u, ==, 2); g_assert_cmpint(u, ==, 2);
nmtst_assert_ip4_address(ia_arr[0], expected_dns1); g_assert_cmpstr(strarr[0], ==, expected_dns1);
nmtst_assert_ip4_address(ia_arr[1], expected_dns2); g_assert_cmpstr(strarr[1], ==, expected_dns2);
g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3); g_assert_cmpint(nm_l3_config_data_get_num_routes(l3cd, AF_INET), ==, 3);

View File

@@ -871,19 +871,21 @@ add_ip_config(NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsConfigIPD
const char *iface; const char *iface;
const char *domain; const char *domain;
char ip_addr_to_string_buf[IP_ADDR_TO_STRING_BUFLEN]; char ip_addr_to_string_buf[IP_ADDR_TO_STRING_BUFLEN];
gconstpointer nameservers; const char *const *strarr;
guint num; guint num;
guint i; guint i;
guint j; guint j;
iface = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex); iface = nm_platform_link_get_name(NM_PLATFORM_GET, ip_data->data->ifindex);
nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); strarr = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
gconstpointer addr; NMIPAddr a;
addr = nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i); if (!nm_utils_dnsname_parse_assert(ip_data->addr_family, strarr[i], NULL, &a, NULL))
ip_addr_to_string(ip_data->addr_family, addr, iface, ip_addr_to_string_buf); continue;
ip_addr_to_string(ip_data->addr_family, &a, iface, ip_addr_to_string_buf);
if (!ip_data->domains.has_default_route_explicit && ip_data->domains.has_default_route) if (!ip_data->domains.has_default_route_explicit && ip_data->domains.has_default_route)
add_dnsmasq_nameserver(self, servers, ip_addr_to_string_buf, NULL); add_dnsmasq_nameserver(self, servers, ip_addr_to_string_buf, NULL);

View File

@@ -557,24 +557,24 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con
guint num_nameservers; guint num_nameservers;
guint num; guint num;
guint i; guint i;
gconstpointer nameservers; const char *const *strarr;
const char *const *strv;
nm_assert(ifindex == nm_l3_config_data_get_ifindex(l3cd)); nm_assert(ifindex == nm_l3_config_data_get_ifindex(l3cd));
nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers); strarr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers);
for (i = 0; i < num_nameservers; i++) { for (i = 0; i < num_nameservers; i++) {
const NMIPAddr *addr; NMIPAddr a;
addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i); if (!nm_utils_dnsname_parse_assert(addr_family, strarr[i], NULL, &a, NULL))
continue;
if (addr_family == AF_INET) if (addr_family == AF_INET)
nm_inet_ntop(addr_family, addr, buf); nm_inet_ntop(addr_family, &a, buf);
else if (IN6_IS_ADDR_V4MAPPED(addr)) else if (IN6_IS_ADDR_V4MAPPED(&a))
nm_inet4_ntop(addr->addr6.s6_addr32[3], buf); nm_inet4_ntop(a.addr6.s6_addr32[3], buf);
else { else {
nm_inet6_ntop(&addr->addr6, buf); nm_inet6_ntop(&a.addr6, buf);
if (IN6_IS_ADDR_LINKLOCAL(addr)) { if (IN6_IS_ADDR_LINKLOCAL(&a)) {
const char *ifname; const char *ifname;
ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ifindex); ifname = nm_platform_link_get_name(NM_PLATFORM_GET, ifindex);
@@ -591,9 +591,9 @@ merge_one_l3cd(NMResolvConfData *rc, int addr_family, int ifindex, const NML3Con
add_dns_domains(rc->searches, addr_family, l3cd, FALSE, TRUE); add_dns_domains(rc->searches, addr_family, l3cd, FALSE, TRUE);
has_trust_ad = FALSE; has_trust_ad = FALSE;
strv = nm_l3_config_data_get_dns_options(l3cd, addr_family, &num); strarr = nm_l3_config_data_get_dns_options(l3cd, addr_family, &num);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
const char *option = strv[i]; const char *option = strarr[i];
if (nm_streq(option, NM_SETTING_DNS_OPTION_TRUST_AD)) { if (nm_streq(option, NM_SETTING_DNS_OPTION_TRUST_AD)) {
has_trust_ad = TRUE; has_trust_ad = TRUE;
@@ -1261,16 +1261,18 @@ get_nameserver_list(int addr_family, const NML3ConfigData *l3cd, NMStrBuf *tmp_s
char buf[NM_INET_ADDRSTRLEN]; char buf[NM_INET_ADDRSTRLEN];
guint num; guint num;
guint i; guint i;
gconstpointer nameservers; const char *const *strarr;
nm_str_buf_reset(tmp_strbuf); nm_str_buf_reset(tmp_strbuf);
nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num); strarr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
const NMIPAddr *addr; NMIPAddr a;
addr = nm_ip_addr_from_packed_array(addr_family, nameservers, i); if (!nm_utils_dnsname_parse_assert(addr_family, strarr[i], NULL, &a, NULL))
nm_inet_ntop(addr_family, addr->addr_ptr, buf); continue;
nm_inet_ntop(addr_family, &a, buf);
if (i > 0) if (i > 0)
nm_str_buf_append_c(tmp_strbuf, ' '); nm_str_buf_append_c(tmp_strbuf, ' ');
nm_str_buf_append(tmp_strbuf, buf); nm_str_buf_append(tmp_strbuf, buf);
@@ -2636,9 +2638,9 @@ _get_config_variant(NMDnsManager *self)
guint i; guint i;
char buf[NM_INET_ADDRSTRLEN]; char buf[NM_INET_ADDRSTRLEN];
const char *ifname; const char *ifname;
gconstpointer nameservers; const char *const *strarr;
nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num); strarr = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &num);
if (num == 0) if (num == 0)
continue; continue;
@@ -2646,12 +2648,12 @@ _get_config_variant(NMDnsManager *self)
g_variant_builder_init(&strv_builder, G_VARIANT_TYPE("as")); g_variant_builder_init(&strv_builder, G_VARIANT_TYPE("as"));
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
const NMIPAddr *addr; NMIPAddr a;
addr = nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i); if (!nm_utils_dnsname_parse_assert(ip_data->addr_family, strarr[i], NULL, &a, NULL))
g_variant_builder_add(&strv_builder, continue;
"s",
nm_inet_ntop(ip_data->addr_family, addr, buf)); g_variant_builder_add(&strv_builder, "s", nm_inet_ntop(ip_data->addr_family, &a, buf));
} }
g_variant_builder_add(&entry_builder, g_variant_builder_add(&entry_builder,
"{sv}", "{sv}",

View File

@@ -349,7 +349,7 @@ update_add_ip_config(NMDnsSystemdResolved *self,
gboolean is_routing; gboolean is_routing;
const char *domain; const char *domain;
gboolean has_config = FALSE; gboolean has_config = FALSE;
gconstpointer nameservers; const char *const *strarr;
addr_size = nm_utils_addr_family_to_size(ip_data->addr_family); addr_size = nm_utils_addr_family_to_size(ip_data->addr_family);
@@ -361,14 +361,16 @@ update_add_ip_config(NMDnsSystemdResolved *self,
return FALSE; return FALSE;
} }
nameservers = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &n); strarr = nm_l3_config_data_get_nameservers(ip_data->l3cd, ip_data->addr_family, &n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
NMIPAddr a;
if (!nm_utils_dnsname_parse_assert(ip_data->addr_family, strarr[i], NULL, &a, NULL))
continue;
g_variant_builder_open(dns, G_VARIANT_TYPE("(iay)")); g_variant_builder_open(dns, G_VARIANT_TYPE("(iay)"));
g_variant_builder_add(dns, "i", ip_data->addr_family); g_variant_builder_add(dns, "i", ip_data->addr_family);
g_variant_builder_add_value( g_variant_builder_add_value(dns, nm_g_variant_new_ay((gconstpointer) &a, addr_size));
dns,
nm_g_variant_new_ay(nm_ip_addr_from_packed_array(ip_data->addr_family, nameservers, i),
addr_size));
g_variant_builder_close(dns); g_variant_builder_close(dns);
has_config = TRUE; has_config = TRUE;
} }

View File

@@ -104,7 +104,6 @@ create_dm_cmd_line(const char *iface,
gs_free char *error_desc = NULL; gs_free char *error_desc = NULL;
const char *dm_binary; const char *dm_binary;
const NMPlatformIP4Address *listen_address; const NMPlatformIP4Address *listen_address;
const in_addr_t *ipv4arr;
const char *const *strarr; const char *const *strarr;
guint n; guint n;
guint i; guint i;
@@ -163,13 +162,18 @@ create_dm_cmd_line(const char *iface,
nm_strv_ptrarray_add_string_concat(cmd, "--dhcp-option=option:router,", listen_address_s); nm_strv_ptrarray_add_string_concat(cmd, "--dhcp-option=option:router,", listen_address_s);
} }
ipv4arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &n); strarr = nm_l3_config_data_get_nameservers(l3cd, AF_INET, &n);
if (n > 0) { if (n > 0) {
nm_gstring_prepare(&s); nm_gstring_prepare(&s);
g_string_append(s, "--dhcp-option=option:dns-server"); g_string_append(s, "--dhcp-option=option:dns-server");
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
in_addr_t a;
if (!nm_utils_dnsname_parse_assert(AF_INET, strarr[i], NULL, &a, NULL))
continue;
g_string_append_c(s, ','); g_string_append_c(s, ',');
g_string_append(s, nm_inet4_ntop(ipv4arr[i], sbuf_addr)); g_string_append(s, nm_inet4_ntop(a, sbuf_addr));
} }
nm_strv_ptrarray_take_gstring(cmd, &s); nm_strv_ptrarray_take_gstring(cmd, &s);
} }

View File

@@ -13,6 +13,7 @@
#include "libnm-platform/nm-platform-utils.h" #include "libnm-platform/nm-platform-utils.h"
#include "libnm-platform/nm-platform.h" #include "libnm-platform/nm-platform.h"
#include "libnm-platform/nmp-netns.h" #include "libnm-platform/nmp-netns.h"
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
#include "nm-l3-config-data.h" #include "nm-l3-config-data.h"
#include "nm-l3cfg.h" #include "nm-l3cfg.h"
#include "nm-ndisc-private.h" #include "nm-ndisc-private.h"
@@ -186,8 +187,12 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex *multi_idx,
} }
} }
for (i = 0; i < rdata->dns_servers_n; i++) for (i = 0; i < rdata->dns_servers_n; i++) {
nm_l3_config_data_add_nameserver(l3cd, AF_INET6, &rdata->dns_servers[i].address); nm_l3_config_data_add_nameserver_detail(l3cd,
AF_INET6,
&rdata->dns_servers[i].address,
NULL);
}
for (i = 0; i < rdata->dns_domains_n; i++) for (i = 0; i < rdata->dns_domains_n; i++)
nm_l3_config_data_add_search(l3cd, AF_INET6, rdata->dns_domains[i].domain); nm_l3_config_data_add_search(l3cd, AF_INET6, rdata->dns_domains[i].domain);
@@ -990,7 +995,6 @@ void
nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd) nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd)
{ {
gboolean changed = FALSE; gboolean changed = FALSE;
const struct in6_addr *in6arr;
const char *const *strvarr; const char *const *strvarr;
NMDedupMultiIter iter; NMDedupMultiIter iter;
const NMPObject *obj; const NMPObject *obj;
@@ -1035,15 +1039,19 @@ nm_ndisc_set_config(NMNDisc *ndisc, const NML3ConfigData *l3cd)
changed = TRUE; changed = TRUE;
} }
in6arr = NULL; strvarr = NULL;
len = 0; len = 0;
if (l3cd) if (l3cd)
in6arr = nm_l3_config_data_get_nameservers(l3cd, AF_INET6, &len); strvarr = nm_l3_config_data_get_nameservers(l3cd, AF_INET6, &len);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
struct in6_addr a;
NMNDiscDNSServer n; NMNDiscDNSServer n;
if (!nm_utils_dnsname_parse_assert(AF_INET6, strvarr[i], NULL, &a, NULL))
continue;
n = (NMNDiscDNSServer){ n = (NMNDiscDNSServer){
.address = in6arr[i], .address = a,
.expiry_msec = _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP, .expiry_msec = _nm_ndisc_lifetime_to_expiry(NM_NDISC_EXPIRY_BASE_TIMESTAMP,
NM_NDISC_ROUTER_LIFETIME), NM_NDISC_ROUTER_LIFETIME),
}; };

View File

@@ -179,7 +179,6 @@ dump_ip_to_props(const NML3ConfigData *l3cd, int addr_family, GVariantBuilder *b
const NMPObject *default_route; const NMPObject *default_route;
const char *const *strarr; const char *const *strarr;
const in_addr_t *ip4arr; const in_addr_t *ip4arr;
gconstpointer iparr;
if (IS_IPv4) if (IS_IPv4)
g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aau")); g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aau"));
@@ -223,14 +222,17 @@ dump_ip_to_props(const NML3ConfigData *l3cd, int addr_family, GVariantBuilder *b
g_variant_builder_init(&int_builder, G_VARIANT_TYPE("au")); g_variant_builder_init(&int_builder, G_VARIANT_TYPE("au"));
else else
g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aay")); g_variant_builder_init(&int_builder, G_VARIANT_TYPE("aay"));
iparr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &n); strarr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
NMIPAddr a;
if (!nm_utils_dnsname_parse_assert(addr_family, strarr[i], NULL, &a, NULL))
continue;
if (IS_IPv4) if (IS_IPv4)
g_variant_builder_add(&int_builder, "u", ((const in_addr_t *) iparr)[i]); g_variant_builder_add(&int_builder, "u", &a);
else { else
var1 = nm_g_variant_new_ay_in6addr(&(((const struct in6_addr *) iparr)[i])); g_variant_builder_add(&int_builder, "@ay", nm_g_variant_new_ay_in6addr(&a.addr6));
g_variant_builder_add(&int_builder, "@ay", var1);
}
} }
g_variant_builder_add(builder, "{sv}", "nameservers", g_variant_builder_end(&int_builder)); g_variant_builder_add(builder, "{sv}", "nameservers", g_variant_builder_end(&int_builder));

View File

@@ -10,6 +10,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include "libnm-core-aux-intern/nm-libnm-core-utils.h"
#include "nm-l3cfg.h" #include "nm-l3cfg.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
@@ -336,6 +337,7 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
char addr_str[NM_INET_ADDRSTRLEN]; char addr_str[NM_INET_ADDRSTRLEN];
GVariantBuilder builder; GVariantBuilder builder;
const in_addr_t *addrs; const in_addr_t *addrs;
const char *const *strarr;
guint len; guint len;
guint i; guint i;
@@ -347,22 +349,30 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
g_value_set_variant(value, priv->v_routes); g_value_set_variant(value, priv->v_routes);
break; break;
case PROP_IP4_NAMESERVERS: case PROP_IP4_NAMESERVERS:
addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET, &len);
g_value_set_variant(value,
(len == 0) ? nm_g_variant_singleton_au()
: nm_g_variant_new_au(addrs, len));
break;
case PROP_IP4_NAMESERVER_DATA: case PROP_IP4_NAMESERVER_DATA:
addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET, &len); strarr = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET, &len);
if (len == 0) if (len == 0) {
g_value_set_variant(value, nm_g_variant_singleton_aaLsvI()); g_value_set_variant(value,
else { (prop_id == PROP_IP4_NAMESERVERS)
? nm_g_variant_singleton_au()
: nm_g_variant_singleton_aaLsvI());
} else {
if (prop_id == PROP_IP4_NAMESERVERS)
g_variant_builder_init(&builder, G_VARIANT_TYPE("au"));
else
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
in_addr_t a;
if (!nm_utils_dnsname_parse_assert(AF_INET, strarr[i], NULL, &a, NULL))
continue;
if (prop_id == PROP_IP4_NAMESERVERS)
g_variant_builder_add(&builder, "u", &a);
else {
GVariantBuilder nested_builder; GVariantBuilder nested_builder;
nm_inet4_ntop(addrs[i], addr_str); nm_inet4_ntop(a, addr_str);
g_variant_builder_init(&nested_builder, G_VARIANT_TYPE("a{sv}")); g_variant_builder_init(&nested_builder, G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(&nested_builder, g_variant_builder_add(&nested_builder,
"{sv}", "{sv}",
@@ -370,6 +380,7 @@ get_property_ip4(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
g_variant_new_string(addr_str)); g_variant_new_string(addr_str));
g_variant_builder_add(&builder, "a{sv}", &nested_builder); g_variant_builder_add(&builder, "a{sv}", &nested_builder);
} }
}
g_value_take_variant(value, g_variant_builder_end(&builder)); g_value_take_variant(value, g_variant_builder_end(&builder));
} }
@@ -503,7 +514,7 @@ nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_famil
{ {
guint i; guint i;
int val; int val;
const char *const *nameservers; const char *const *strarr;
const in_addr_t *wins; const in_addr_t *wins;
const char *const *domains; const char *const *domains;
const char *const *searches; const char *const *searches;
@@ -517,12 +528,9 @@ nm_ip_config_dns_hash(const NML3ConfigData *l3cd, GChecksum *sum, int addr_famil
g_return_if_fail(l3cd); g_return_if_fail(l3cd);
g_return_if_fail(sum); g_return_if_fail(sum);
nameservers = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers); strarr = nm_l3_config_data_get_nameservers(l3cd, addr_family, &num_nameservers);
for (i = 0; i < num_nameservers; i++) { for (i = 0; i < num_nameservers; i++)
g_checksum_update(sum, g_checksum_update(sum, (gpointer) strarr[i], strlen(strarr[i]));
nm_ip_addr_from_packed_array(addr_family, nameservers, i),
nm_utils_addr_family_to_size(addr_family));
}
if (addr_family == AF_INET) { if (addr_family == AF_INET) {
wins = nm_l3_config_data_get_wins(l3cd, &num_wins); wins = nm_l3_config_data_get_wins(l3cd, &num_wins);
@@ -635,7 +643,7 @@ get_property_ip6(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
GVariantBuilder builder; GVariantBuilder builder;
guint len; guint len;
guint i; guint i;
const struct in6_addr *addrs; const char *const *strarr;
switch (prop_id) { switch (prop_id) {
case PROP_IP6_ADDRESSES: case PROP_IP6_ADDRESSES:
@@ -645,13 +653,19 @@ get_property_ip6(GObject *object, guint prop_id, GValue *value, GParamSpec *pspe
g_value_set_variant(value, priv->v_routes); g_value_set_variant(value, priv->v_routes);
break; break;
case PROP_IP6_NAMESERVERS: case PROP_IP6_NAMESERVERS:
addrs = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET6, &len); strarr = nm_l3_config_data_get_nameservers(priv->l3cd, AF_INET6, &len);
if (len == 0) if (len == 0)
g_value_set_variant(value, nm_g_variant_singleton_aay()); g_value_set_variant(value, nm_g_variant_singleton_aay());
else { else {
g_variant_builder_init(&builder, G_VARIANT_TYPE("aay")); g_variant_builder_init(&builder, G_VARIANT_TYPE("aay"));
for (i = 0; i < len; i++) for (i = 0; i < len; i++) {
g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(&addrs[i])); struct in6_addr a;
if (!nm_utils_dnsname_parse_assert(AF_INET6, strarr[i], NULL, &a, NULL))
continue;
g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(&a));
}
g_value_take_variant(value, g_variant_builder_end(&builder)); g_value_take_variant(value, g_variant_builder_end(&builder));
} }
break; break;
@@ -736,8 +750,8 @@ _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd)
nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL;
GParamSpec *changed_params[8]; GParamSpec *changed_params[8];
guint n_changed_params = 0; guint n_changed_params = 0;
const char *const *strv; const char *const *strarr;
const char *const *strv_old; const char *const *strarr_old;
gconstpointer addrs; gconstpointer addrs;
gconstpointer addrs_old; gconstpointer addrs_old;
guint len; guint len;
@@ -748,9 +762,9 @@ _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd)
l3cd_old = g_steal_pointer(&priv->l3cd); l3cd_old = g_steal_pointer(&priv->l3cd);
priv->l3cd = nm_l3_config_data_ref(l3cd); priv->l3cd = nm_l3_config_data_ref(l3cd);
addrs_old = nm_l3_config_data_get_nameservers(l3cd_old, addr_family, &len_old); strarr_old = nm_l3_config_data_get_nameservers(l3cd_old, addr_family, &len_old);
addrs = nm_l3_config_data_get_nameservers(priv->l3cd, addr_family, &len); strarr = nm_l3_config_data_get_nameservers(priv->l3cd, addr_family, &len);
if (!nm_memeq_n(addrs_old, len_old, addrs, len, nm_utils_addr_family_to_size(addr_family))) { if (!nm_strv_equal_n(strarr_old, len_old, strarr, len)) {
if (IS_IPv4) { if (IS_IPv4) {
changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVER_DATA]; changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVER_DATA];
changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVERS]; changed_params[n_changed_params++] = obj_properties_ip4[PROP_IP4_NAMESERVERS];
@@ -758,14 +772,14 @@ _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd)
changed_params[n_changed_params++] = obj_properties_ip6[PROP_IP6_NAMESERVERS]; changed_params[n_changed_params++] = obj_properties_ip6[PROP_IP6_NAMESERVERS];
} }
strv_old = nm_l3_config_data_get_domains(l3cd_old, addr_family, &len_old); strarr_old = nm_l3_config_data_get_domains(l3cd_old, addr_family, &len_old);
strv = nm_l3_config_data_get_domains(priv->l3cd, addr_family, &len); strarr = nm_l3_config_data_get_domains(priv->l3cd, addr_family, &len);
if (!nm_strv_equal_n(strv, len, strv_old, len_old)) if (!nm_strv_equal_n(strarr, len, strarr_old, len_old))
changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DOMAINS]; changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DOMAINS];
strv_old = nm_l3_config_data_get_searches(l3cd_old, addr_family, &len_old); strarr_old = nm_l3_config_data_get_searches(l3cd_old, addr_family, &len_old);
strv = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len); strarr = nm_l3_config_data_get_searches(priv->l3cd, addr_family, &len);
if (!nm_strv_equal_n(strv, len, strv_old, len_old)) if (!nm_strv_equal_n(strarr, len, strarr_old, len_old))
changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_SEARCHES]; changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_SEARCHES];
v_i_old = nm_l3_config_data_get_dns_priority_or_default(l3cd_old, addr_family); v_i_old = nm_l3_config_data_get_dns_priority_or_default(l3cd_old, addr_family);
@@ -773,9 +787,9 @@ _handle_l3cd_changed(NMIPConfig *self, const NML3ConfigData *l3cd)
if (v_i != v_i_old) if (v_i != v_i_old)
changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_PRIORITY]; changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_PRIORITY];
strv_old = nm_l3_config_data_get_dns_options(l3cd_old, addr_family, &len); strarr_old = nm_l3_config_data_get_dns_options(l3cd_old, addr_family, &len);
strv = nm_l3_config_data_get_dns_options(priv->l3cd, addr_family, &len); strarr = nm_l3_config_data_get_dns_options(priv->l3cd, addr_family, &len);
if (!nm_strv_equal_n(strv, len, strv_old, len_old)) if (!nm_strv_equal_n(strarr, len, strarr_old, len_old))
changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_OPTIONS]; changed_params[n_changed_params++] = obj_properties_ip[PROP_IP_DNS_OPTIONS];
if (IS_IPv4) { if (IS_IPv4) {

View File

@@ -67,10 +67,10 @@ struct _NML3ConfigData {
union { union {
struct { struct {
GArray *nameservers_6; GPtrArray *nameservers_6;
GArray *nameservers_4; GPtrArray *nameservers_4;
}; };
GArray *nameservers_x[2]; GPtrArray *nameservers_x[2];
}; };
union { union {
@@ -269,17 +269,6 @@ _garray_inaddr_get(GArray *arr, guint *out_len)
return arr->data; return arr->data;
} }
static gconstpointer
_garray_inaddr_at(GArray *arr, gboolean IS_IPv4, guint idx)
{
nm_assert(arr);
nm_assert(idx < arr->len);
if (IS_IPv4)
return &nm_g_array_index(arr, in_addr_t, idx);
return &nm_g_array_index(arr, struct in6_addr, idx);
}
static gboolean static gboolean
_garray_inaddr_add(GArray **p_arr, int addr_family, gconstpointer addr) _garray_inaddr_add(GArray **p_arr, int addr_family, gconstpointer addr)
{ {
@@ -480,13 +469,11 @@ nm_l3_config_data_log(const NML3ConfigData *self,
self->dns_priority_x[IS_IPv4]); self->dns_priority_x[IS_IPv4]);
} }
for (i = 0; i < nm_g_array_len(self->nameservers_x[IS_IPv4]); i++) { for (i = 0; i < nm_g_ptr_array_len(self->nameservers_x[IS_IPv4]); i++) {
_L("nameserver%c[%u]: %s", _L("nameserver%c[%u]: %s",
nm_utils_addr_family_to_char(addr_family), nm_utils_addr_family_to_char(addr_family),
i, i,
nm_inet_ntop(addr_family, (char *) self->nameservers_x[IS_IPv4]->pdata[i]);
_garray_inaddr_at(self->nameservers_x[IS_IPv4], IS_IPv4, i),
sbuf_addr));
} }
for (i = 0; i < nm_g_ptr_array_len(self->domains_x[IS_IPv4]); i++) { for (i = 0; i < nm_g_ptr_array_len(self->domains_x[IS_IPv4]); i++) {
@@ -792,8 +779,8 @@ nm_l3_config_data_unref(const NML3ConfigData *self)
nm_clear_pointer(&mutable->dhcp_lease_4, nm_dhcp_lease_unref); nm_clear_pointer(&mutable->dhcp_lease_4, nm_dhcp_lease_unref);
nm_clear_pointer(&mutable->dhcp_lease_6, nm_dhcp_lease_unref); nm_clear_pointer(&mutable->dhcp_lease_6, nm_dhcp_lease_unref);
nm_clear_pointer(&mutable->nameservers_4, g_array_unref); nm_clear_pointer(&mutable->nameservers_4, g_ptr_array_unref);
nm_clear_pointer(&mutable->nameservers_6, g_array_unref); nm_clear_pointer(&mutable->nameservers_6, g_ptr_array_unref);
nm_clear_pointer(&mutable->domains_4, g_ptr_array_unref); nm_clear_pointer(&mutable->domains_4, g_ptr_array_unref);
nm_clear_pointer(&mutable->domains_6, g_ptr_array_unref); nm_clear_pointer(&mutable->domains_6, g_ptr_array_unref);
@@ -1421,7 +1408,7 @@ _check_and_add_domain(GPtrArray **p_arr, const char *domain)
return TRUE; return TRUE;
} }
gconstpointer const char *const *
nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len) nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len)
{ {
nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE));
@@ -1433,33 +1420,68 @@ nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, g
return NULL; return NULL;
} }
return _garray_inaddr_get(self->nameservers_x[NM_IS_IPv4(addr_family)], out_len); return nm_strv_ptrarray_get_unsafe(self->nameservers_x[NM_IS_IPv4(addr_family)], out_len);
} }
gboolean gboolean
nm_l3_config_data_add_nameserver(NML3ConfigData *self, nm_l3_config_data_add_nameserver(NML3ConfigData *self, int addr_family, const char *nameserver)
int addr_family,
gconstpointer /* (const NMIPAddr *) */ nameserver)
{ {
GPtrArray **p_arr;
nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE));
nm_assert_addr_family(addr_family); nm_assert_addr_family(addr_family);
nm_assert(nameserver); nm_assert(nameserver);
return _garray_inaddr_add(&self->nameservers_x[NM_IS_IPv4(addr_family)], if (NM_MORE_ASSERTS > 5) {
addr_family, gs_free char *s_free = NULL;
nameserver);
nm_assert(
nm_streq0(nm_utils_dnsname_normalize(addr_family, nameserver, &s_free), nameserver));
}
p_arr = &self->nameservers_x[NM_IS_IPv4(addr_family)];
if (nm_strv_ptrarray_contains(*p_arr, nameserver))
return FALSE;
nm_strv_ptrarray_add_string_dup(nm_strv_ptrarray_ensure(p_arr), nameserver);
return TRUE;
}
gboolean
nm_l3_config_data_add_nameserver_detail(NML3ConfigData *self,
int addr_family,
gconstpointer addr_bin,
const char *server_name)
{
gs_free char *s_free = NULL;
char *s;
gsize l;
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);
} }
gboolean gboolean
nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family) nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family)
{ {
gs_unref_array GArray *old = NULL; gs_unref_ptrarray GPtrArray *old = NULL;
nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE));
nm_assert_addr_family(addr_family); nm_assert_addr_family(addr_family);
old = g_steal_pointer(&self->nameservers_x[NM_IS_IPv4(addr_family)]); old = g_steal_pointer(&self->nameservers_x[NM_IS_IPv4(addr_family)]);
return (nm_g_array_len(old) > 0); return (nm_g_ptr_array_len(old) > 0);
} }
const in_addr_t * const in_addr_t *
@@ -2272,7 +2294,6 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a,
} }
for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) {
const int addr_family = IS_IPv4 ? AF_INET : AF_INET6;
const NMPObject *def_route_a = a->best_default_route_x[IS_IPv4]; const NMPObject *def_route_a = a->best_default_route_x[IS_IPv4];
const NMPObject *def_route_b = b->best_default_route_x[IS_IPv4]; const NMPObject *def_route_b = b->best_default_route_x[IS_IPv4];
@@ -2311,9 +2332,8 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a,
if (NM_FLAGS_HAS(flags, NM_L3_CONFIG_CMP_FLAGS_DNS)) { if (NM_FLAGS_HAS(flags, NM_L3_CONFIG_CMP_FLAGS_DNS)) {
const NML3ConfigDatFlags FLAG = NM_L3_CONFIG_DAT_FLAGS_HAS_DNS_PRIORITY(IS_IPv4); const NML3ConfigDatFlags FLAG = NM_L3_CONFIG_DAT_FLAGS_HAS_DNS_PRIORITY(IS_IPv4);
NM_CMP_RETURN(_garray_inaddr_cmp(a->nameservers_x[IS_IPv4], NM_CMP_RETURN(
b->nameservers_x[IS_IPv4], nm_strv_ptrarray_cmp(a->nameservers_x[IS_IPv4], b->nameservers_x[IS_IPv4]));
addr_family));
NM_CMP_RETURN(nm_strv_ptrarray_cmp(a->domains_x[IS_IPv4], b->domains_x[IS_IPv4])); NM_CMP_RETURN(nm_strv_ptrarray_cmp(a->domains_x[IS_IPv4], b->domains_x[IS_IPv4]));
NM_CMP_RETURN(nm_strv_ptrarray_cmp(a->searches_x[IS_IPv4], b->searches_x[IS_IPv4])); NM_CMP_RETURN(nm_strv_ptrarray_cmp(a->searches_x[IS_IPv4], b->searches_x[IS_IPv4]));
NM_CMP_RETURN( NM_CMP_RETURN(
@@ -2843,19 +2863,8 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co
} }
nnameservers = nm_setting_ip_config_get_num_dns(s_ip); nnameservers = nm_setting_ip_config_get_num_dns(s_ip);
for (i = 0; i < nnameservers; i++) { for (i = 0; i < nnameservers; i++)
const char *server_name; nm_l3_config_data_add_nameserver(self, addr_family, nm_setting_ip_config_get_dns(s_ip, i));
const char *s;
NMIPAddr ip;
s = nm_setting_ip_config_get_dns(s_ip, i);
if (!nm_utils_dnsname_parse_assert(addr_family, s, NULL, &ip, &server_name))
continue;
/* TODO: handle server_name. */
nm_l3_config_data_add_nameserver(self, addr_family, &ip);
}
nsearches = nm_setting_ip_config_get_num_dns_searches(s_ip); nsearches = nm_setting_ip_config_get_num_dns_searches(s_ip);
for (i = 0; i < nsearches; i++) { for (i = 0; i < nsearches; i++) {
@@ -3210,9 +3219,7 @@ nm_l3_config_data_merge(NML3ConfigData *self,
} }
if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS)) if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS))
_garray_inaddr_merge(&self->nameservers_x[IS_IPv4], _strv_ptrarray_merge(&self->nameservers_x[IS_IPv4], src->nameservers_x[IS_IPv4]);
src->nameservers_x[IS_IPv4],
addr_family);
if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS)) if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS))
_strv_ptrarray_merge(&self->domains_x[IS_IPv4], src->domains_x[IS_IPv4]); _strv_ptrarray_merge(&self->domains_x[IS_IPv4], src->domains_x[IS_IPv4]);

View File

@@ -495,12 +495,16 @@ const in_addr_t *nm_l3_config_data_get_wins(const NML3ConfigData *self, guint *o
gboolean nm_l3_config_data_add_wins(NML3ConfigData *self, in_addr_t wins); gboolean nm_l3_config_data_add_wins(NML3ConfigData *self, in_addr_t wins);
gconstpointer const char *const *
nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len); nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len);
gboolean nm_l3_config_data_add_nameserver(NML3ConfigData *self, 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, int addr_family,
gconstpointer /* (const NMIPAddr *) */ nameserver); gconstpointer addr_bin,
const char *server_name);
gboolean nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family); gboolean nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family);

View File

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

View File

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