diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-07-23 19:13:00 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-07-27 15:13:49 +0200 |
commit | 9446481f4cc06c657d9467bce0921a85bb94ae6b (patch) | |
tree | 4875a097cf3ff9361ef95c90f4855f3b6f086da6 | |
parent | c44b13f87c21a75c701d1e54d2bb4abe48084ab4 (diff) | |
download | NetworkManager-9446481f4cc06c657d9467bce0921a85bb94ae6b.tar.gz |
policy: update system hostname when DHCP configuration changes
If both IPv4 and IPv6 are enabled and IPv6 terminates first (and
ipv4.may-fail=yes), the device becomes ACTIVATED and we try to update
the system hostname from the DHCP lease, if necessary. But later, the
termination of DHCPv4 doesn't trigger a new update and so it's
possible that the system hostname remains unset even if the DHCPv4
lease specifies a hostname.
To have a deterministic behavior we should always try to update the
system hostname when a DHCP transaction terminates.
https://bugzilla.redhat.com/show_bug.cgi?id=1356015
-rw-r--r-- | src/nm-policy.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c index 0af67425ed..0a67464946 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -1294,6 +1294,22 @@ device_state_changed (NMDevice *device, } static void +device_dhcp_config_changed (NMDevice *device, + GParamSpec *pspec, + gpointer user_data) +{ + NMPolicyPrivate *priv = user_data; + NMPolicy *self = priv->self; + + if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) { + /* Ensure that a hostname received through DHCP4/DHCP6 is applied even + * if the IPv4/IPv6 method completed after initial activation. + */ + update_routing_and_dns (self, FALSE); + } +} + +static void device_ip4_config_changed (NMDevice *device, NMIP4Config *new_config, NMIP4Config *old_config, @@ -1401,6 +1417,8 @@ devices_list_register (NMPolicy *self, NMDevice *device) g_signal_connect (device, NM_DEVICE_IP6_CONFIG_CHANGED, (GCallback) device_ip6_config_changed, priv); g_signal_connect (device, "notify::" NM_DEVICE_AUTOCONNECT, (GCallback) device_autoconnect_changed, priv); g_signal_connect (device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, (GCallback) device_recheck_auto_activate, priv); + g_signal_connect (device, "notify::" NM_DEVICE_DHCP4_CONFIG,(GCallback) device_dhcp_config_changed, priv); + g_signal_connect (device, "notify::" NM_DEVICE_DHCP6_CONFIG,(GCallback) device_dhcp_config_changed, priv); } static void |