Commit 454195c0 authored by Thomas Haller's avatar Thomas Haller

device: don't capture resolve.conf for initial device config

This was called by via

  ...
  - manager:recheck_assume_connection()
    - manager:get_existing_connection()
      - nm_device_capture_initial_config()
        - update_ext_ip_config(initial=TRUE)

and would parse resolv.conf, and try to fill the device IP config
with nameservers and dns-options.

But why? It would only have effect if NM was started with
nm_dns_manager_get_resolv_conf_explicit(), but is that really sensible?
And it would only take effect on devices that have a default route.
And for what is this information even used?

Let's not do it this way. If we need this information for assuming or
external sys-iface mode, then it should be explicitly loaded at the
appropriate moment.

For now, drop it and see what breaks. Then we can fix it properly. If
it even matters.
parent 453f9e51
......@@ -513,7 +513,7 @@ static const GDBusSignalInfo signal_info_state_changed;
static void nm_device_set_proxy_config (NMDevice *self, const char *pac_url);
static gboolean update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolean intersect_configs);
static gboolean update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_configs);
static gboolean nm_device_set_ip4_config (NMDevice *self,
NMIP4Config *config,
......@@ -6118,7 +6118,7 @@ ip4_config_merge_and_apply (NMDevice *self,
if (commit) {
if (priv->queued_ip4_config_id)
update_ext_ip_config (self, AF_INET, FALSE, FALSE);
update_ext_ip_config (self, AF_INET, FALSE);
ensure_con_ip4_config (self);
}
......@@ -6892,7 +6892,7 @@ ip6_config_merge_and_apply (NMDevice *self,
if (commit) {
if (priv->queued_ip6_config_id)
update_ext_ip_config (self, AF_INET6, FALSE, FALSE);
update_ext_ip_config (self, AF_INET6, FALSE);
ensure_con_ip6_config (self);
}
......@@ -8377,7 +8377,6 @@ act_stage3_ip6_config_start (NMDevice *self,
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
nm_device_get_ip_ifindex (self),
FALSE,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
ip6_privacy = _ip6_privacy_get (self);
......@@ -11291,11 +11290,10 @@ intersect_ext_config (NMDevice *self, AppliedConfig *config)
}
static gboolean
update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolean intersect_configs)
update_ext_ip_config (NMDevice *self, int addr_family, gboolean intersect_configs)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
int ifindex;
gboolean capture_resolv_conf;
GSList *iter;
nm_assert_addr_family (addr_family);
......@@ -11304,16 +11302,12 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolea
if (!ifindex)
return FALSE;
capture_resolv_conf = initial
&& nm_dns_manager_get_resolv_conf_explicit (nm_dns_manager_get ());
if (addr_family == AF_INET) {
g_clear_object (&priv->ext_ip4_config);
priv->ext_ip4_config = nm_ip4_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
ifindex,
capture_resolv_conf);
ifindex);
if (priv->ext_ip4_config) {
if (intersect_configs) {
/* This function was called upon external changes. Remove the configuration
......@@ -11361,7 +11355,6 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolea
priv->ext_ip6_config_captured = nm_ip6_config_capture (nm_device_get_multi_index (self),
nm_device_get_platform (self),
ifindex,
capture_resolv_conf,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN);
if (priv->ext_ip6_config_captured) {
......@@ -11416,13 +11409,13 @@ update_ext_ip_config (NMDevice *self, int addr_family, gboolean initial, gboolea
}
static void
update_ip_config (NMDevice *self, int addr_family, gboolean initial)
update_ip_config (NMDevice *self, int addr_family)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
nm_assert_addr_family (addr_family);
if (update_ext_ip_config (self, addr_family, initial, TRUE)) {
if (update_ext_ip_config (self, addr_family, TRUE)) {
if (addr_family == AF_INET) {
if (priv->ext_ip4_config)
ip4_config_merge_and_apply (self, FALSE);
......@@ -11436,8 +11429,8 @@ update_ip_config (NMDevice *self, int addr_family, gboolean initial)
void
nm_device_capture_initial_config (NMDevice *self)
{
update_ip_config (self, AF_INET, TRUE);
update_ip_config (self, AF_INET6, TRUE);
update_ip_config (self, AF_INET);
update_ip_config (self, AF_INET6);
}
static gboolean
......@@ -11469,7 +11462,7 @@ queued_ip4_config_change (gpointer user_data)
priv->queued_ip4_config_id = g_idle_add (queued_ip4_config_change, self);
_LOGT (LOGD_DEVICE, "IP4 update was postponed");
} else
update_ip_config (self, AF_INET, FALSE);
update_ip_config (self, AF_INET);
set_unmanaged_external_down (self, TRUE);
......@@ -11512,7 +11505,7 @@ queued_ip6_config_change (gpointer user_data)
priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, self);
_LOGT (LOGD_DEVICE, "IP6 update was postponed");
} else {
update_ip_config (self, AF_INET6, FALSE);
update_ip_config (self, AF_INET6);
/* Check whether we need to complete waiting for link-local.
* We are also called from an idle handler, so no problem doing state transitions
......
......@@ -125,7 +125,7 @@ dhcp4_state_changed (NMDhcpClient *client,
g_assert (nm_ip4_config_get_ifindex (ip4_config) == gl.ifindex);
existing = nm_ip4_config_capture (nm_platform_get_multi_idx (NM_PLATFORM_GET),
NM_PLATFORM_GET, gl.ifindex, FALSE);
NM_PLATFORM_GET, gl.ifindex);
if (last_config)
nm_ip4_config_subtract (existing, last_config, 0);
......@@ -171,7 +171,7 @@ ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_in
NMIP6Config *existing;
existing = nm_ip6_config_capture (nm_platform_get_multi_idx (NM_PLATFORM_GET),
NM_PLATFORM_GET, gl.ifindex, FALSE, global_opt.tempaddr);
NM_PLATFORM_GET, gl.ifindex, global_opt.tempaddr);
if (ndisc_config)
nm_ip6_config_subtract (existing, ndisc_config, 0);
else {
......
......@@ -593,14 +593,13 @@ nm_ip4_config_clone (const NMIP4Config *self)
}
NMIP4Config *
nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf)
nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex)
{
NMIP4Config *self;
NMIP4ConfigPrivate *priv;
const NMDedupMultiHeadEntry *head_entry;
NMDedupMultiIter iter;
const NMPObject *plobj = NULL;
gboolean has_addresses = FALSE;
nm_assert (ifindex > 0);
......@@ -632,7 +631,6 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
nm_dedup_multi_head_entry_sort (head_entry,
sort_captured_addresses,
NULL);
has_addresses = TRUE;
_notify_addresses (self);
}
......@@ -644,23 +642,6 @@ nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
nmp_cache_iter_for_each (&iter, head_entry, &plobj)
_add_route (self, plobj, NULL, NULL);
/* If the interface has the default route, and has IPv4 addresses, capture
* nameservers from /etc/resolv.conf.
*/
if ( has_addresses
&& priv->best_default_route
&& capture_resolv_conf) {
gs_free char *rc_contents = NULL;
if (g_file_get_contents (_PATH_RESCONF, &rc_contents, NULL, NULL)) {
if (nm_utils_resolve_conf_parse (AF_INET,
rc_contents,
priv->nameservers,
priv->dns_options))
_notify (self, PROP_NAMESERVERS);
}
}
return self;
}
......
......@@ -160,7 +160,7 @@ int nm_ip4_config_get_ifindex (const NMIP4Config *self);
NMDedupMultiIndex *nm_ip4_config_get_multi_idx (const NMIP4Config *self);
NMIP4Config *nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf);
NMIP4Config *nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex);
void nm_ip4_config_add_dependent_routes (NMIP4Config *self,
guint32 route_table,
......
......@@ -376,14 +376,13 @@ nm_ip6_config_clone (const NMIP6Config *self)
}
NMIP6Config *
nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary)
nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, NMSettingIP6ConfigPrivacy use_temporary)
{
NMIP6Config *self;
NMIP6ConfigPrivate *priv;
const NMDedupMultiHeadEntry *head_entry;
NMDedupMultiIter iter;
const NMPObject *plobj = NULL;
gboolean has_addresses = FALSE;
nm_assert (ifindex > 0);
......@@ -409,7 +408,6 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
NULL,
NULL))
nm_assert_not_reached ();
has_addresses = TRUE;
}
head_entry = nm_ip6_config_lookup_addresses (self);
nm_assert (head_entry);
......@@ -426,23 +424,6 @@ nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int i
nmp_cache_iter_for_each (&iter, head_entry, &plobj)
_add_route (self, plobj, NULL, NULL);
/* If the interface has the default route, and has IPv6 addresses, capture
* nameservers from /etc/resolv.conf.
*/
if ( has_addresses
&& priv->best_default_route
&& capture_resolv_conf) {
gs_free char *rc_contents = NULL;
if (g_file_get_contents (_PATH_RESCONF, &rc_contents, NULL, NULL)) {
if (nm_utils_resolve_conf_parse (AF_INET6,
rc_contents,
priv->nameservers,
priv->dns_options))
_notify (self, PROP_NAMESERVERS);
}
}
return self;
}
......
......@@ -106,7 +106,7 @@ int nm_ip6_config_get_ifindex (const NMIP6Config *self);
struct _NMDedupMultiIndex *nm_ip6_config_get_multi_idx (const NMIP6Config *self);
NMIP6Config *nm_ip6_config_capture (struct _NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex,
gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
NMSettingIP6ConfigPrivacy use_temporary);
void nm_ip6_config_add_dependent_routes (NMIP6Config *self,
guint32 route_table,
......
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