networkmanager: connectivity check: set interface for DNS resolution

Use the same interface that it's being checked for the DNS resolution.

This makes connectivity check work in an scenario where the primary
interface has lost connectivity (for example ethernet) but you still
have connectivity through a secondary interface (e.g. wireless).

What happens in that case is that even though you have correct
connectivity in the secondary interface the check fails because it does
not use that secondary interface to resolve the name of the test URL.
The result is that the connectivity check assumes that this secondary
interface is also failing and it penalizes the metrics in the routing
table.

This commit uses libcurl's CURLOPT_DNS_INTERFACE to set the DNS
interface. Notice that this requires 'libcurl' to be compiled with
'--enable-ares'.

https://jira.digi.com/browse/DEL-4787

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2017-09-14 14:01:24 +02:00
parent f64a59ba25
commit c9b02d6288
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,38 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Thu, 14 Sep 2017 13:29:52 +0200
Subject: [PATCH] connectivity: configure network interface for DNS resolution
Use the same interface that it's being checked for the DNS resolution.
This makes connectivity check work in an scenario where the primary
interface has lost connectivity (for example ethernet) but you still
have connectivity through a secondary interface (e.g. wireless).
What happens in that case is that even though you have correct
connectivity in the secondary interface the check fails because it does
not use that secondary interface to resolve the name of the test URL.
The result is that the connectivity check assumes that this secondary
interface is also failing and it penalizes the metrics in the routing
table.
This commit uses libcurl's CURLOPT_DNS_INTERFACE to set the DNS
interface. Notice that this requires 'libcurl' to be compiled with
'--enable-ares'.
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
src/nm-connectivity.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index 6f16b28e56ca..c12f145c2ad8 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -365,6 +365,7 @@ nm_connectivity_check_async (NMConnectivity *self,
curl_easy_setopt (ehandle, CURLOPT_PRIVATE, cb_data);
curl_easy_setopt (ehandle, CURLOPT_HTTPHEADER, cb_data->request_headers);
curl_easy_setopt (ehandle, CURLOPT_INTERFACE, cb_data->ifspec);
+ curl_easy_setopt (ehandle, CURLOPT_DNS_INTERFACE, iface);
curl_multi_add_handle (priv->curl_mhandle, ehandle);
cb_data->timeout_id = g_timeout_add_seconds (30, timeout_cb, cb_data);

View File

@ -12,6 +12,7 @@ SRC_URI += " \
file://nm.eth1.static \
file://nm.wlan0.dhcp \
file://nm.wlan0.static \
file://0001-connectivity-configure-network-interface-for-DNS-res.patch \
"
# 'polkit' depends on 'consolekit', and this requires 'x11' distro feature. So