summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-09-29 13:42:02 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-10-09 18:53:12 +0200
commit9db8586ad740ced29cd9120beb1b9848ede213e1 (patch)
tree8a91919392180403004eb5781e145deb86a8ce21
parentaa031261d5300361b8ea6f62b62bdef24b45a0f4 (diff)
downloadNetworkManager-9db8586ad740ced29cd9120beb1b9848ede213e1.tar.gz
dns: add wildcard domain to VPNs with never-default=no and no domains
If a VPN has never-default=no but doesn't get a default route (this can happen for example when the server pushes routes with openconnect), and there are no search domains, then the name servers pushed by the server would be unused. It is preferable in this case to use the VPN DNS server for all queries. https://bugzilla.redhat.com/show_bug.cgi?id=1863041 (cherry picked from commit cefd5ee3229d33de8b474852deb5a2044e378b04) (cherry picked from commit c5b57526accb2eef73f9b158c182bfa79fc73f5f)
-rw-r--r--src/dns/nm-dns-manager.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
index 207e2e7dfe..144ab8029f 100644
--- a/src/dns/nm-dns-manager.c
+++ b/src/dns/nm-dns-manager.c
@@ -1305,10 +1305,27 @@ rebuild_domain_lists (NMDnsManager *self)
head = _ip_config_lst_head (self);
c_list_for_each_entry (ip_data, head, ip_config_lst) {
NMIPConfig *ip_config = ip_data->ip_config;
+ gboolean add_wildcard = FALSE;
if (!nm_ip_config_get_num_nameservers (ip_config))
continue;
- if (nm_ip_config_best_default_route_get (ip_config)) {
+ if (nm_ip_config_best_default_route_get (ip_config))
+ add_wildcard = TRUE;
+ else {
+ /* If a VPN has never-default=no but doesn't get a default
+ * route (this can happen for example when the server
+ * pushes routes with openconnect), and there are no
+ * search or routing domains, then the name servers pushed
+ * by the server would be unused. It is preferable in this
+ * case to use the VPN DNS server for all queries. */
+ if ( ip_data->ip_config_type == NM_DNS_IP_CONFIG_TYPE_VPN
+ && !nm_ip_config_get_never_default (ip_data->ip_config)
+ && nm_ip_config_get_num_searches (ip_data->ip_config) == 0
+ && nm_ip_config_get_num_domains (ip_data->ip_config) == 0)
+ add_wildcard = TRUE;
+ }
+
+ if (add_wildcard) {
if (!wildcard_entries)
wildcard_entries = g_hash_table_new (nm_direct_hash, NULL);
g_hash_table_add (wildcard_entries, ip_data);