diff options
author | Ricardo Salveti <rsalveti@rsalveti.net> | 2017-06-15 11:15:53 -0300 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2017-06-19 19:29:37 +0200 |
commit | 00f1cc1a85ee736773442cd82f3225ff9f731e8c (patch) | |
tree | 3710cf4d20a00b03d3e2fc7de008c5f74d48ff08 /meta-oe/recipes-connectivity/networkmanager | |
parent | 1565dc6af60a671786dfb6604df4c9975cc74fb6 (diff) | |
download | meta-openembedded-00f1cc1a85ee736773442cd82f3225ff9f731e8c.tar.gz |
networkmanager: add support for systemd-resolved
Now that resolved is enabled in systemd, backport upstream patch that
adds support for the systemd-resolved backend and add one additional
check for the OE-specific resolv.conf link path.
Signed-off-by: Ricardo Salveti <rsalveti@rsalveti.net>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-oe/recipes-connectivity/networkmanager')
3 files changed, 652 insertions, 0 deletions
diff --git a/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-add-systemd-resolved-backend.patch b/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-add-systemd-resolved-backend.patch new file mode 100644 index 000000000..bd194a61d --- /dev/null +++ b/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-add-systemd-resolved-backend.patch | |||
@@ -0,0 +1,621 @@ | |||
1 | From: Sjoerd Simons <sjoerd@luon.net> | ||
2 | Date: Sun, 21 Aug 2016 21:46:02 +0200 | ||
3 | Subject: [PATCH] dns/resolved: add systemd-resolved backend | ||
4 | |||
5 | Add initial DNS backend that pushes DNS information into | ||
6 | systemd-resolved. Backend is choosen by default if the systems | ||
7 | resolv.conv is setup to pointing to one of the standard resolved | ||
8 | locations. | ||
9 | |||
10 | This doesn't handle global dns configuration. | ||
11 | |||
12 | Signed-off-by: Sjoerd Simons <sjoerd@luon.net> | ||
13 | |||
14 | https://bugzilla.gnome.org/show_bug.cgi?id=762540 | ||
15 | |||
16 | Upstream-Status: Backport | ||
17 | |||
18 | --- | ||
19 | man/NetworkManager.conf.xml | 10 +- | ||
20 | src/Makefile.am | 2 + | ||
21 | src/dns-manager/nm-dns-manager.c | 43 ++- | ||
22 | src/dns-manager/nm-dns-systemd-resolved.c | 427 ++++++++++++++++++++++++++++++ | ||
23 | src/dns-manager/nm-dns-systemd-resolved.h | 45 ++++ | ||
24 | 5 files changed, 523 insertions(+), 4 deletions(-) | ||
25 | create mode 100644 src/dns-manager/nm-dns-systemd-resolved.c | ||
26 | create mode 100644 src/dns-manager/nm-dns-systemd-resolved.h | ||
27 | |||
28 | diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml | ||
29 | index 6295b82..0a67ae5 100644 | ||
30 | --- a/man/NetworkManager.conf.xml | ||
31 | +++ b/man/NetworkManager.conf.xml | ||
32 | @@ -275,10 +275,12 @@ no-auto-default=* | ||
33 | <varlistentry> | ||
34 | <term><varname>dns</varname></term> | ||
35 | <listitem><para>Set the DNS (<filename>resolv.conf</filename>) processing mode.</para> | ||
36 | - <para><literal>default</literal>: The default if the key is | ||
37 | - not specified. NetworkManager will update | ||
38 | + <para><literal>default</literal>: NetworkManager will update | ||
39 | <filename>resolv.conf</filename> to reflect the nameservers | ||
40 | - provided by currently active connections.</para> | ||
41 | + provided by currently active connections. This is the default | ||
42 | + if the key is not specified, unless the system is configured | ||
43 | + to use systemd-resolved; in this case the default is | ||
44 | + <literal>systemd-resolved</literal></para> | ||
45 | <para><literal>dnsmasq</literal>: NetworkManager will run | ||
46 | dnsmasq as a local caching nameserver, using a "split DNS" | ||
47 | configuration if you are connected to a VPN, and then update | ||
48 | @@ -288,6 +290,8 @@ no-auto-default=* | ||
49 | to unbound and dnssec-triggerd, providing a "split DNS" | ||
50 | configuration with DNSSEC support. The <filename>/etc/resolv.conf</filename> | ||
51 | will be managed by dnssec-trigger daemon.</para> | ||
52 | + <para><literal>systemd-resolved</literal>: NetworkManager will | ||
53 | + push the DNS configuration to systemd-resolved</para> | ||
54 | <para><literal>none</literal>: NetworkManager will not | ||
55 | modify resolv.conf. This implies | ||
56 | <literal>rc-manager</literal> <literal>unmanaged</literal></para> | ||
57 | diff --git a/src/Makefile.am b/src/Makefile.am | ||
58 | index 8d29b19..10f63de 100644 | ||
59 | --- a/src/Makefile.am | ||
60 | +++ b/src/Makefile.am | ||
61 | @@ -345,6 +345,8 @@ libNetworkManager_la_SOURCES = \ | ||
62 | \ | ||
63 | dns-manager/nm-dns-dnsmasq.c \ | ||
64 | dns-manager/nm-dns-dnsmasq.h \ | ||
65 | + dns-manager/nm-dns-systemd-resolved.c \ | ||
66 | + dns-manager/nm-dns-systemd-resolved.h \ | ||
67 | dns-manager/nm-dns-unbound.c \ | ||
68 | dns-manager/nm-dns-unbound.h \ | ||
69 | dns-manager/nm-dns-manager.c \ | ||
70 | diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c | ||
71 | index 5a758a9..38bc786 100644 | ||
72 | --- a/src/dns-manager/nm-dns-manager.c | ||
73 | +++ b/src/dns-manager/nm-dns-manager.c | ||
74 | @@ -45,6 +45,7 @@ | ||
75 | |||
76 | #include "nm-dns-plugin.h" | ||
77 | #include "nm-dns-dnsmasq.h" | ||
78 | +#include "nm-dns-systemd-resolved.h" | ||
79 | #include "nm-dns-unbound.h" | ||
80 | |||
81 | #if WITH_LIBSOUP | ||
82 | @@ -1588,6 +1589,37 @@ _check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager) | ||
83 | |||
84 | NM_DEFINE_SINGLETON_GETTER (NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGER); | ||
85 | |||
86 | +static gboolean | ||
87 | +_resolvconf_resolved_managed (void) | ||
88 | +{ | ||
89 | + static const char *const resolved_paths[] = { | ||
90 | + "/run/systemd/resolve/resolv.conf", | ||
91 | + "/lib/systemd/resolv.conf", | ||
92 | + "/usr/lib/systemd/resolv.conf", | ||
93 | + }; | ||
94 | + GFile *f; | ||
95 | + GFileInfo *info; | ||
96 | + gboolean ret = FALSE; | ||
97 | + | ||
98 | + f = g_file_new_for_path (_PATH_RESCONF); | ||
99 | + info = g_file_query_info (f, | ||
100 | + G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK","\ | ||
101 | + G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, | ||
102 | + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, | ||
103 | + NULL, NULL); | ||
104 | + | ||
105 | + if (info && g_file_info_get_is_symlink (info)) { | ||
106 | + ret = _nm_utils_strv_find_first ((gchar **) resolved_paths, | ||
107 | + G_N_ELEMENTS (resolved_paths), | ||
108 | + g_file_info_get_symlink_target (info)) >= 0; | ||
109 | + } | ||
110 | + | ||
111 | + g_clear_object(&info); | ||
112 | + g_clear_object(&f); | ||
113 | + | ||
114 | + return ret; | ||
115 | +} | ||
116 | + | ||
117 | static void | ||
118 | init_resolv_conf_mode (NMDnsManager *self, gboolean force_reload_plugin) | ||
119 | { | ||
120 | @@ -1633,7 +1665,16 @@ again: | ||
121 | |||
122 | rc_manager = _check_resconf_immutable (rc_manager); | ||
123 | |||
124 | - if (nm_streq0 (mode, "dnsmasq")) { | ||
125 | + if ( (!mode && _resolvconf_resolved_managed ()) | ||
126 | + || nm_streq0 (mode, "systemd-resolved")) { | ||
127 | + if ( force_reload_plugin | ||
128 | + || !NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin)) { | ||
129 | + _clear_plugin (self); | ||
130 | + priv->plugin = nm_dns_systemd_resolved_new (); | ||
131 | + plugin_changed = TRUE; | ||
132 | + } | ||
133 | + mode = "systemd-resolved"; | ||
134 | + } else if (nm_streq0 (mode, "dnsmasq")) { | ||
135 | if (force_reload_plugin || !NM_IS_DNS_DNSMASQ (priv->plugin)) { | ||
136 | _clear_plugin (self); | ||
137 | priv->plugin = nm_dns_dnsmasq_new (); | ||
138 | diff --git a/src/dns-manager/nm-dns-systemd-resolved.c b/src/dns-manager/nm-dns-systemd-resolved.c | ||
139 | new file mode 100644 | ||
140 | index 0000000..6bdd5f6 | ||
141 | --- /dev/null | ||
142 | +++ b/src/dns-manager/nm-dns-systemd-resolved.c | ||
143 | @@ -0,0 +1,427 @@ | ||
144 | +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ | ||
145 | +/* | ||
146 | + * Copyright (C) 2010 Dan Williams <dcbw@redhat.com> | ||
147 | + * Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net> | ||
148 | + * | ||
149 | + * This program is free software; you can redistribute it and/or modify | ||
150 | + * it under the terms of the GNU General Public License as published by | ||
151 | + * the Free Software Foundation; either version 2, or (at your option) | ||
152 | + * any later version. | ||
153 | + * | ||
154 | + * This program is distributed in the hope that it will be useful, | ||
155 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
156 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
157 | + * GNU General Public License for more details. | ||
158 | + * | ||
159 | + * You should have received a copy of the GNU General Public License along | ||
160 | + * with this program; if not, write to the Free Software Foundation, Inc., | ||
161 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
162 | + * | ||
163 | + */ | ||
164 | + | ||
165 | +#include "nm-default.h" | ||
166 | + | ||
167 | +#include "nm-dns-systemd-resolved.h" | ||
168 | + | ||
169 | +#include <stdlib.h> | ||
170 | +#include <unistd.h> | ||
171 | +#include <sys/types.h> | ||
172 | +#include <sys/wait.h> | ||
173 | +#include <arpa/inet.h> | ||
174 | +#include <sys/stat.h> | ||
175 | +#include <linux/if.h> | ||
176 | + | ||
177 | +#include "nm-core-internal.h" | ||
178 | +#include "nm-platform.h" | ||
179 | +#include "nm-utils.h" | ||
180 | +#include "nm-ip4-config.h" | ||
181 | +#include "nm-ip6-config.h" | ||
182 | +#include "nm-bus-manager.h" | ||
183 | +#include "nm-manager.h" | ||
184 | +#include "nm-device.h" | ||
185 | +#include "NetworkManagerUtils.h" | ||
186 | + | ||
187 | +G_DEFINE_TYPE (NMDnsSystemdResolved, nm_dns_systemd_resolved, NM_TYPE_DNS_PLUGIN) | ||
188 | + | ||
189 | +#define NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(o) \ | ||
190 | + (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DNS_SYSTEMD_RESOLVED, \ | ||
191 | + NMDnsSystemdResolvedPrivate)) | ||
192 | + | ||
193 | +#define SYSTEMD_RESOLVED_DBUS_SERVICE "org.freedesktop.resolve1" | ||
194 | +#define SYSTEMD_RESOLVED_DBUS_PATH "/org/freedesktop/resolve1" | ||
195 | + | ||
196 | +typedef struct { | ||
197 | + int ifindex; | ||
198 | + GList *configs; | ||
199 | +} InterfaceConfig; | ||
200 | + | ||
201 | +typedef struct { | ||
202 | + GDBusProxy *resolve; | ||
203 | + GCancellable *init_cancellable; | ||
204 | + GCancellable *update_cancellable; | ||
205 | + GQueue dns_updates; | ||
206 | + GQueue domain_updates; | ||
207 | +} NMDnsSystemdResolvedPrivate; | ||
208 | + | ||
209 | +/*****************************************************************************/ | ||
210 | + | ||
211 | +#define _NMLOG_DOMAIN LOGD_DNS | ||
212 | +#define _NMLOG_PREFIX_NAME "systemd-resolved" | ||
213 | +#define _NMLOG(level, ...) \ | ||
214 | + G_STMT_START { \ | ||
215 | + nm_log ((level), _NMLOG_DOMAIN, \ | ||
216 | + "%s[%p]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ | ||
217 | + _NMLOG_PREFIX_NAME, \ | ||
218 | + (self) \ | ||
219 | + _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ | ||
220 | + } G_STMT_END | ||
221 | + | ||
222 | +/*****************************************************************************/ | ||
223 | + | ||
224 | +static void | ||
225 | +call_done (GObject *source, GAsyncResult *r, gpointer user_data) | ||
226 | +{ | ||
227 | + GVariant *v; | ||
228 | + GError *error = NULL; | ||
229 | + NMDnsSystemdResolved *self = (NMDnsSystemdResolved *) user_data; | ||
230 | + | ||
231 | + v = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), r, &error); | ||
232 | + | ||
233 | + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) | ||
234 | + return; | ||
235 | + | ||
236 | + if (error != NULL) { | ||
237 | + _LOGW ("Failed: %s\n", error->message); | ||
238 | + g_error_free (error); | ||
239 | + } | ||
240 | +} | ||
241 | + | ||
242 | +static void | ||
243 | +add_interface_configuration (NMDnsSystemdResolved *self, | ||
244 | + GArray *interfaces, | ||
245 | + const NMDnsIPConfigData *data) | ||
246 | +{ | ||
247 | + int i; | ||
248 | + InterfaceConfig *ic = NULL; | ||
249 | + int ifindex; | ||
250 | + NMDevice *device; | ||
251 | + | ||
252 | + if (NM_IS_IP4_CONFIG (data->config)) | ||
253 | + ifindex = nm_ip4_config_get_ifindex (data->config); | ||
254 | + else if (NM_IS_IP6_CONFIG (data->config)) | ||
255 | + ifindex = nm_ip6_config_get_ifindex (data->config); | ||
256 | + else | ||
257 | + g_return_if_reached (); | ||
258 | + | ||
259 | + device = nm_manager_get_device_by_ifindex (nm_manager_get (), ifindex); | ||
260 | + | ||
261 | + if (!nm_device_get_managed (device, FALSE)) | ||
262 | + return; | ||
263 | + | ||
264 | + for (i = 0; i < interfaces->len; i++) { | ||
265 | + InterfaceConfig *tic = &g_array_index (interfaces, InterfaceConfig, i); | ||
266 | + if (ifindex == tic->ifindex) { | ||
267 | + ic = tic; | ||
268 | + break; | ||
269 | + } | ||
270 | + } | ||
271 | + | ||
272 | + if (!ic) { | ||
273 | + g_array_set_size (interfaces, interfaces->len + 1); | ||
274 | + ic = &g_array_index (interfaces, InterfaceConfig, | ||
275 | + interfaces->len - 1); | ||
276 | + ic->ifindex = ifindex; | ||
277 | + } | ||
278 | + | ||
279 | + ic->configs = g_list_append (ic->configs, data->config); | ||
280 | +} | ||
281 | + | ||
282 | +static void | ||
283 | +add_domain (GVariantBuilder *domains, | ||
284 | + const char *domain, | ||
285 | + gboolean never_default) | ||
286 | +{ | ||
287 | + /* If this link is never the default (e.g. only used for resources on this | ||
288 | + * network) add a routing domain. */ | ||
289 | + g_variant_builder_add (domains, "(sb)", domain, never_default); | ||
290 | +} | ||
291 | + | ||
292 | +static void | ||
293 | +update_add_ip6_config (NMDnsSystemdResolved *self, | ||
294 | + GVariantBuilder *dns, | ||
295 | + GVariantBuilder *domains, | ||
296 | + const NMIP6Config *config) | ||
297 | +{ | ||
298 | + guint i, n; | ||
299 | + | ||
300 | + n = nm_ip6_config_get_num_nameservers (config); | ||
301 | + for (i = 0 ; i < n; i++) { | ||
302 | + const struct in6_addr *ip; | ||
303 | + | ||
304 | + g_variant_builder_open (dns, G_VARIANT_TYPE ("(iay)")); | ||
305 | + g_variant_builder_add (dns, "i", AF_INET6); | ||
306 | + ip = nm_ip6_config_get_nameserver (config, i), | ||
307 | + | ||
308 | + g_variant_builder_add_value (dns, g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ip, 16, 1)); | ||
309 | + g_variant_builder_close (dns); | ||
310 | + } | ||
311 | + | ||
312 | + n = nm_ip6_config_get_num_searches (config); | ||
313 | + if (n > 0) { | ||
314 | + for (i = 0; i < n; i++) { | ||
315 | + add_domain (domains, nm_ip6_config_get_search (config, i), | ||
316 | + nm_ip6_config_get_never_default (config)); | ||
317 | + } | ||
318 | + } else { | ||
319 | + n = nm_ip6_config_get_num_domains (config); | ||
320 | + for (i = 0; i < n; i++) { | ||
321 | + add_domain (domains, nm_ip6_config_get_domain (config, i), | ||
322 | + nm_ip6_config_get_never_default (config)); | ||
323 | + } | ||
324 | + } | ||
325 | +} | ||
326 | + | ||
327 | +static void | ||
328 | +update_add_ip4_config (NMDnsSystemdResolved *self, | ||
329 | + GVariantBuilder *dns, | ||
330 | + GVariantBuilder *domains, | ||
331 | + const NMIP4Config *config) | ||
332 | +{ | ||
333 | + guint i, n; | ||
334 | + | ||
335 | + n = nm_ip4_config_get_num_nameservers (config); | ||
336 | + for (i = 0 ; i < n; i++) { | ||
337 | + guint32 ns; | ||
338 | + | ||
339 | + g_variant_builder_open (dns, G_VARIANT_TYPE ("(iay)")); | ||
340 | + g_variant_builder_add (dns, "i", AF_INET); | ||
341 | + ns = nm_ip4_config_get_nameserver (config, i), | ||
342 | + | ||
343 | + g_variant_builder_add_value (dns, g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, &ns, 4, 1)); | ||
344 | + g_variant_builder_close (dns); | ||
345 | + } | ||
346 | + | ||
347 | + n = nm_ip4_config_get_num_searches (config); | ||
348 | + if (n > 0) { | ||
349 | + for (i = 0; i < n; i++) { | ||
350 | + add_domain (domains, nm_ip4_config_get_search (config, i), | ||
351 | + nm_ip4_config_get_never_default (config)); | ||
352 | + } | ||
353 | + } else { | ||
354 | + n = nm_ip4_config_get_num_domains (config); | ||
355 | + for (i = 0; i < n; i++) { | ||
356 | + add_domain (domains, nm_ip4_config_get_domain (config, i), | ||
357 | + nm_ip4_config_get_never_default (config)); | ||
358 | + } | ||
359 | + } | ||
360 | +} | ||
361 | + | ||
362 | +static void | ||
363 | +free_pending_updates (NMDnsSystemdResolved *self) | ||
364 | +{ | ||
365 | + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
366 | + GVariant *v; | ||
367 | + | ||
368 | + while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL) | ||
369 | + g_variant_unref (v); | ||
370 | + | ||
371 | + while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL) | ||
372 | + g_variant_unref (v); | ||
373 | +} | ||
374 | + | ||
375 | +static void | ||
376 | +prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic) | ||
377 | +{ | ||
378 | + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
379 | + GVariantBuilder dns, domains; | ||
380 | + GList *l; | ||
381 | + | ||
382 | + g_variant_builder_init (&dns, G_VARIANT_TYPE ("(ia(iay))")); | ||
383 | + g_variant_builder_add (&dns, "i", ic->ifindex); | ||
384 | + g_variant_builder_open (&dns, G_VARIANT_TYPE ("a(iay)")); | ||
385 | + | ||
386 | + g_variant_builder_init (&domains, G_VARIANT_TYPE ("(ia(sb))")); | ||
387 | + g_variant_builder_add (&domains, "i", ic->ifindex); | ||
388 | + g_variant_builder_open (&domains, G_VARIANT_TYPE ("a(sb)")); | ||
389 | + | ||
390 | + for (l = ic->configs ; l != NULL ; l = g_list_next (l)) { | ||
391 | + if (NM_IS_IP4_CONFIG (l->data)) | ||
392 | + update_add_ip4_config (self, &dns, &domains, l->data); | ||
393 | + else if (NM_IS_IP6_CONFIG (l->data)) | ||
394 | + update_add_ip6_config (self, &dns, &domains, l->data); | ||
395 | + else | ||
396 | + g_assert_not_reached (); | ||
397 | + } | ||
398 | + g_variant_builder_close (&dns); | ||
399 | + g_variant_builder_close (&domains); | ||
400 | + | ||
401 | + g_queue_push_tail (&priv->dns_updates, | ||
402 | + g_variant_ref_sink (g_variant_builder_end (&dns))); | ||
403 | + g_queue_push_tail (&priv->domain_updates, | ||
404 | + g_variant_ref_sink (g_variant_builder_end (&domains))); | ||
405 | +} | ||
406 | + | ||
407 | +static void | ||
408 | +send_updates (NMDnsSystemdResolved *self) | ||
409 | +{ | ||
410 | + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
411 | + GVariant *v; | ||
412 | + | ||
413 | + nm_clear_g_cancellable (&priv->update_cancellable); | ||
414 | + | ||
415 | + if (!priv->resolve) | ||
416 | + return; | ||
417 | + | ||
418 | + priv->update_cancellable = g_cancellable_new (); | ||
419 | + | ||
420 | + while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL) { | ||
421 | + g_dbus_proxy_call (priv->resolve, "SetLinkDNS", v, | ||
422 | + G_DBUS_CALL_FLAGS_NONE, | ||
423 | + -1, priv->update_cancellable, call_done, self); | ||
424 | + g_variant_unref (v); | ||
425 | + } | ||
426 | + | ||
427 | + while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL) { | ||
428 | + g_dbus_proxy_call (priv->resolve, "SetLinkDomains", v, | ||
429 | + G_DBUS_CALL_FLAGS_NONE, | ||
430 | + -1, priv->update_cancellable, call_done, self); | ||
431 | + g_variant_unref (v); | ||
432 | + } | ||
433 | +} | ||
434 | + | ||
435 | +static gboolean | ||
436 | +update (NMDnsPlugin *plugin, | ||
437 | + const NMDnsIPConfigData **configs, | ||
438 | + const NMGlobalDnsConfig *global_config, | ||
439 | + const char *hostname) | ||
440 | +{ | ||
441 | + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin); | ||
442 | + GArray *interfaces = g_array_new (TRUE, TRUE, sizeof (InterfaceConfig)); | ||
443 | + const NMDnsIPConfigData **c; | ||
444 | + int i; | ||
445 | + | ||
446 | + for (c = configs; *c != NULL; c++) | ||
447 | + add_interface_configuration (self, interfaces, *c); | ||
448 | + | ||
449 | + free_pending_updates (self); | ||
450 | + | ||
451 | + for (i = 0; i < interfaces->len; i++) { | ||
452 | + InterfaceConfig *ic = &g_array_index (interfaces, InterfaceConfig, i); | ||
453 | + | ||
454 | + prepare_one_interface (self, ic); | ||
455 | + g_list_free (ic->configs); | ||
456 | + } | ||
457 | + | ||
458 | + g_array_free (interfaces, TRUE); | ||
459 | + | ||
460 | + send_updates (self); | ||
461 | + | ||
462 | + return TRUE; | ||
463 | +} | ||
464 | + | ||
465 | +/****************************************************************/ | ||
466 | + | ||
467 | +static gboolean | ||
468 | +is_caching (NMDnsPlugin *plugin) | ||
469 | +{ | ||
470 | + return TRUE; | ||
471 | +} | ||
472 | + | ||
473 | +static const char * | ||
474 | +get_name (NMDnsPlugin *plugin) | ||
475 | +{ | ||
476 | + return "systemd-resolved"; | ||
477 | +} | ||
478 | + | ||
479 | +/****************************************************************/ | ||
480 | + | ||
481 | +NMDnsPlugin * | ||
482 | +nm_dns_systemd_resolved_new (void) | ||
483 | +{ | ||
484 | + return g_object_new (NM_TYPE_DNS_SYSTEMD_RESOLVED, NULL); | ||
485 | +} | ||
486 | + | ||
487 | +static void | ||
488 | +resolved_proxy_created (GObject *source, GAsyncResult *r, gpointer user_data) | ||
489 | +{ | ||
490 | + NMDnsSystemdResolved *self = (NMDnsSystemdResolved *) user_data; | ||
491 | + NMDnsSystemdResolvedPrivate *priv; | ||
492 | + gs_free_error GError *error = NULL; | ||
493 | + GDBusProxy *resolve; | ||
494 | + | ||
495 | + resolve = g_dbus_proxy_new_finish (r, &error); | ||
496 | + if ( !resolve | ||
497 | + && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) | ||
498 | + return; | ||
499 | + | ||
500 | + priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
501 | + g_clear_object (&priv->init_cancellable); | ||
502 | + if (!resolve) { | ||
503 | + _LOGW ("failed to connect to resolved via DBus: %s", error->message); | ||
504 | + g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED); | ||
505 | + return; | ||
506 | + } | ||
507 | + | ||
508 | + priv->resolve = resolve; | ||
509 | + send_updates (self); | ||
510 | +} | ||
511 | + | ||
512 | + | ||
513 | +static void | ||
514 | +nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self) | ||
515 | +{ | ||
516 | + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
517 | + NMBusManager *dbus_mgr; | ||
518 | + GDBusConnection *connection; | ||
519 | + | ||
520 | + g_queue_init (&priv->dns_updates); | ||
521 | + g_queue_init (&priv->domain_updates); | ||
522 | + | ||
523 | + dbus_mgr = nm_bus_manager_get (); | ||
524 | + g_return_if_fail (dbus_mgr); | ||
525 | + | ||
526 | + connection = nm_bus_manager_get_connection (dbus_mgr); | ||
527 | + g_return_if_fail (connection); | ||
528 | + | ||
529 | + priv->init_cancellable = g_cancellable_new (); | ||
530 | + g_dbus_proxy_new (connection, | ||
531 | + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | | ||
532 | + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, | ||
533 | + NULL, | ||
534 | + SYSTEMD_RESOLVED_DBUS_SERVICE, | ||
535 | + SYSTEMD_RESOLVED_DBUS_PATH, | ||
536 | + SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager", | ||
537 | + priv->init_cancellable, | ||
538 | + resolved_proxy_created, | ||
539 | + self); | ||
540 | +} | ||
541 | + | ||
542 | +static void | ||
543 | +dispose (GObject *object) | ||
544 | +{ | ||
545 | + NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (object); | ||
546 | + NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); | ||
547 | + | ||
548 | + free_pending_updates (self); | ||
549 | + g_clear_object (&priv->resolve); | ||
550 | + nm_clear_g_cancellable (&priv->init_cancellable); | ||
551 | + nm_clear_g_cancellable (&priv->update_cancellable); | ||
552 | + | ||
553 | + G_OBJECT_CLASS (nm_dns_systemd_resolved_parent_class)->dispose (object); | ||
554 | +} | ||
555 | + | ||
556 | +static void | ||
557 | +nm_dns_systemd_resolved_class_init (NMDnsSystemdResolvedClass *dns_class) | ||
558 | +{ | ||
559 | + NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (dns_class); | ||
560 | + GObjectClass *object_class = G_OBJECT_CLASS (dns_class); | ||
561 | + | ||
562 | + g_type_class_add_private (dns_class, sizeof (NMDnsSystemdResolvedPrivate)); | ||
563 | + | ||
564 | + object_class->dispose = dispose; | ||
565 | + | ||
566 | + plugin_class->is_caching = is_caching; | ||
567 | + plugin_class->update = update; | ||
568 | + plugin_class->get_name = get_name; | ||
569 | +} | ||
570 | + | ||
571 | diff --git a/src/dns-manager/nm-dns-systemd-resolved.h b/src/dns-manager/nm-dns-systemd-resolved.h | ||
572 | new file mode 100644 | ||
573 | index 0000000..45c64b3 | ||
574 | --- /dev/null | ||
575 | +++ b/src/dns-manager/nm-dns-systemd-resolved.h | ||
576 | @@ -0,0 +1,45 @@ | ||
577 | +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ | ||
578 | +/* This program is free software; you can redistribute it and/or modify | ||
579 | + * it under the terms of the GNU General Public License as published by | ||
580 | + * the Free Software Foundation; either version 2, or (at your option) | ||
581 | + * any later version. | ||
582 | + * | ||
583 | + * This program is distributed in the hope that it will be useful, | ||
584 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
585 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
586 | + * GNU General Public License for more details. | ||
587 | + * | ||
588 | + * You should have received a copy of the GNU General Public License along | ||
589 | + * with this program; if not, write to the Free Software Foundation, Inc., | ||
590 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
591 | + * | ||
592 | + * Copyright (C) 2010 Red Hat, Inc. | ||
593 | + * Copyright (C) 2016 Sjoerd Simons <sjoerd@luon.net> | ||
594 | + */ | ||
595 | + | ||
596 | +#ifndef __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ | ||
597 | +#define __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ | ||
598 | + | ||
599 | +#include "nm-dns-plugin.h" | ||
600 | + | ||
601 | +#define NM_TYPE_DNS_SYSTEMD_RESOLVED (nm_dns_systemd_resolved_get_type ()) | ||
602 | +#define NM_DNS_SYSTEMD_RESOLVED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolved)) | ||
603 | +#define NM_DNS_SYSTEMD_RESOLVED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolvedClass)) | ||
604 | +#define NM_IS_DNS_SYSTEMD_RESOLVED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED)) | ||
605 | +#define NM_IS_DNS_SYSTEMD_RESOLVED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_SYSTEMD_RESOLVED)) | ||
606 | +#define NM_DNS_SYSTEMD_RESOLVED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_SYSTEMD_RESOLVED, NMDnsSystemdResolvedClass)) | ||
607 | + | ||
608 | +typedef struct { | ||
609 | + NMDnsPlugin parent; | ||
610 | +} NMDnsSystemdResolved; | ||
611 | + | ||
612 | +typedef struct { | ||
613 | + NMDnsPluginClass parent; | ||
614 | +} NMDnsSystemdResolvedClass; | ||
615 | + | ||
616 | +GType nm_dns_systemd_resolved_get_type (void); | ||
617 | + | ||
618 | +NMDnsPlugin *nm_dns_systemd_resolved_new (void); | ||
619 | + | ||
620 | +#endif /* __NETWORKMANAGER_DNS_SYSTEMD_RESOLVED_H__ */ | ||
621 | + | ||
diff --git a/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-also-check-for-etc-resolv-conf.systemd.patch b/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-also-check-for-etc-resolv-conf.systemd.patch new file mode 100644 index 000000000..ca7e4a496 --- /dev/null +++ b/meta-oe/recipes-connectivity/networkmanager/networkmanager/0001-dns-resolved-also-check-for-etc-resolv-conf.systemd.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From 6f799f1f0e68cc7bf89c0a56aec5ecf46937619d Mon Sep 17 00:00:00 2001 | ||
2 | From: Ricardo Salveti <rsalveti@rsalveti.net> | ||
3 | Date: Thu, 15 Jun 2017 10:02:38 -0300 | ||
4 | Subject: [PATCH] dns/resolved: also check for /etc/resolv-conf.systemd | ||
5 | |||
6 | OE specific resolv.conf path, so it can be enabled by default if available. | ||
7 | |||
8 | Upstream-Status: Inappropriate [OE config specific] | ||
9 | |||
10 | Signed-off-by: Ricardo Salveti <rsalveti@rsalveti.net> | ||
11 | --- | ||
12 | src/dns-manager/nm-dns-manager.c | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c | ||
16 | index c1d2bf7..d70d4b4 100644 | ||
17 | --- a/src/dns-manager/nm-dns-manager.c | ||
18 | +++ b/src/dns-manager/nm-dns-manager.c | ||
19 | @@ -1596,6 +1596,7 @@ _resolvconf_resolved_managed (void) | ||
20 | "/run/systemd/resolve/resolv.conf", | ||
21 | "/lib/systemd/resolv.conf", | ||
22 | "/usr/lib/systemd/resolv.conf", | ||
23 | + "/etc/resolv-conf.systemd", | ||
24 | }; | ||
25 | GFile *f; | ||
26 | GFileInfo *info; | ||
27 | -- | ||
28 | 2.7.4 | ||
29 | |||
diff --git a/meta-oe/recipes-connectivity/networkmanager/networkmanager_1.4.4.bb b/meta-oe/recipes-connectivity/networkmanager/networkmanager_1.4.4.bb index 85098fe2c..0de4383fb 100644 --- a/meta-oe/recipes-connectivity/networkmanager/networkmanager_1.4.4.bb +++ b/meta-oe/recipes-connectivity/networkmanager/networkmanager_1.4.4.bb | |||
@@ -32,6 +32,8 @@ SRC_URI = "${GNOME_MIRROR}/NetworkManager/${@gnome_verdir("${PV}")}/NetworkManag | |||
32 | file://0004-Define-missing-features-to-cater-for-musl.patch \ | 32 | file://0004-Define-missing-features-to-cater-for-musl.patch \ |
33 | file://0005-sd-lldp.h-Remove-net-ethernet.h-seems-to-be-over-spe.patch \ | 33 | file://0005-sd-lldp.h-Remove-net-ethernet.h-seems-to-be-over-spe.patch \ |
34 | file://0001-check-for-strndupa-before-using-it.patch \ | 34 | file://0001-check-for-strndupa-before-using-it.patch \ |
35 | file://0001-dns-resolved-add-systemd-resolved-backend.patch \ | ||
36 | file://0001-dns-resolved-also-check-for-etc-resolv-conf.systemd.patch \ | ||
35 | " | 37 | " |
36 | SRC_URI[md5sum] = "63f1e0d6d7e9099499d062c84c927a75" | 38 | SRC_URI[md5sum] = "63f1e0d6d7e9099499d062c84c927a75" |
37 | SRC_URI[sha256sum] = "829378f318cc008d138a23ca6a9191928ce75344e7e47a2f2c35f4ac82133309" | 39 | SRC_URI[sha256sum] = "829378f318cc008d138a23ca6a9191928ce75344e7e47a2f2c35f4ac82133309" |