Commit 79630c11 authored by Beniamino Galvani's avatar Beniamino Galvani

device: fix handling of ignore-auto-dns and ignore-auto-routes

Since commit ab6548c6 ("device: better accept external IP
changes"), ipX_config_merge_and_apply() applies the configuration
static settings to an intermediate, initially empty configuration
(priv->con_ipX_config) instead of the composite configuration, and
thus the handling of ignore-auto-routes and ignore-auto-dns options
done in nm_ipX_config_merge_setting() has no effect.

Fix this by clearing the routes and the DNS information when needed
before merging static settings to the composite configuration.

Fixes: ab6548c6
parent 02989896
......@@ -3256,12 +3256,24 @@ ip4_config_merge_and_apply (NMDevice *self,
if (priv->wwan_ip4_config)
nm_ip4_config_merge (composite, priv->wwan_ip4_config);
/* Apply ignore-auto-routes and ignore-auto-dns settings */
connection = nm_device_get_connection (self);
if (connection) {
NMSettingIPConfig *s_ip4 = nm_connection_get_setting_ip4_config (connection);
if (nm_setting_ip_config_get_ignore_auto_routes (s_ip4))
nm_ip4_config_reset_routes (composite);
if (nm_setting_ip_config_get_ignore_auto_dns (s_ip4))
nm_ip4_config_reset_nameservers (composite);
nm_ip4_config_reset_domains (composite);
nm_ip4_config_reset_searches (composite);
}
/* Merge user overrides into the composite config. For assumed connections,
* con_ip4_config is empty. */
if (priv->con_ip4_config)
nm_ip4_config_merge (composite, priv->con_ip4_config);
connection = nm_device_get_connection (self);
/* Add the default route.
*
......@@ -3855,13 +3867,24 @@ ip6_config_merge_and_apply (NMDevice *self,
if (priv->wwan_ip6_config)
nm_ip6_config_merge (composite, priv->wwan_ip6_config);
/* Apply ignore-auto-routes and ignore-auto-dns settings */
connection = nm_device_get_connection (self);
if (connection) {
NMSettingIPConfig *s_ip6 = nm_connection_get_setting_ip6_config (connection);
if (nm_setting_ip_config_get_ignore_auto_routes (s_ip6))
nm_ip6_config_reset_routes (composite);
if (nm_setting_ip_config_get_ignore_auto_dns (s_ip6))
nm_ip6_config_reset_nameservers (composite);
nm_ip6_config_reset_domains (composite);
nm_ip6_config_reset_searches (composite);
}
/* Merge user overrides into the composite config. For assumed connections,
* con_ip6_config is empty. */
if (priv->con_ip6_config)
nm_ip6_config_merge (composite, priv->con_ip6_config);
connection = nm_device_get_connection (self);
/* Add the default route.
*
* We keep track of the default route of a device in a private field.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment