diff options
Diffstat (limited to 'src/nm-policy.c')
-rw-r--r-- | src/nm-policy.c | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/src/nm-policy.c b/src/nm-policy.c index 7a5ed42b6c..2a9f6c051f 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -29,8 +29,7 @@ #include "settings/nm-settings.h" #include "settings/nm-settings-connection.h" #include "settings/nm-agent-manager.h" -#include "nm-dhcp4-config.h" -#include "nm-dhcp6-config.h" +#include "nm-dhcp-config.h" #include "nm-config.h" #include "nm-netns.h" #include "nm-hostname-manager.h" @@ -692,6 +691,7 @@ update_system_hostname (NMPolicy *self, const char *msg) const NMPlatformIP4Address *addr4; const NMPlatformIP6Address *addr6; NMDevice *device; + NMDhcpConfig *dhcp_config; g_return_if_fail (self != NULL); @@ -745,12 +745,10 @@ update_system_hostname (NMPolicy *self, const char *msg) } if (priv->default_ac4) { - NMDhcp4Config *dhcp4_config; - /* Grab a hostname out of the device's DHCP4 config */ - dhcp4_config = nm_device_get_dhcp4_config (get_default_device (self, AF_INET)); - if (dhcp4_config) { - dhcp_hostname = nm_dhcp4_config_get_option (dhcp4_config, "host_name"); + dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET), AF_INET); + if (dhcp_config) { + dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name"); if (dhcp_hostname && dhcp_hostname[0]) { p = nm_str_skip_leading_spaces (dhcp_hostname); if (p[0]) { @@ -765,12 +763,10 @@ update_system_hostname (NMPolicy *self, const char *msg) } if (priv->default_ac6) { - NMDhcp6Config *dhcp6_config; - /* Grab a hostname out of the device's DHCP6 config */ - dhcp6_config = nm_device_get_dhcp6_config (get_default_device (self, AF_INET6)); - if (dhcp6_config) { - dhcp_hostname = nm_dhcp6_config_get_option (dhcp6_config, "host_name"); + dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET6), AF_INET6); + if (dhcp_config) { + dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name"); if (dhcp_hostname && dhcp_hostname[0]) { p = nm_str_skip_leading_spaces (dhcp_hostname); if (p[0]) { @@ -1007,21 +1003,6 @@ update_ip4_routing (NMPolicy *self, gboolean force_update) } static void -update_ip6_dns_delegation (NMPolicy *self) -{ - NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); - NMDevice *device; - NMActiveConnection *ac; - const CList *tmp_list; - - nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { - device = nm_active_connection_get_device (ac); - if (device && nm_device_needs_ip6_subnet (device)) - nm_device_copy_ip6_dns_config (device, get_default_device (self, AF_INET6)); - } -} - -static void update_ip6_prefix_delegation (NMPolicy *self) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); @@ -1089,8 +1070,9 @@ update_ip6_routing (NMPolicy *self, gboolean force_update) } static void -update_ip_dns (NMPolicy *self, int addr_family) +update_ip_dns (NMPolicy *self, int addr_family, NMDevice *changed_device) { + NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); gpointer ip_config; const char *ip_iface = NULL; NMVpnConnection *vpn = NULL; @@ -1112,19 +1094,32 @@ update_ip_dns (NMPolicy *self, int addr_family) device); } - if (addr_family == AF_INET6) - update_ip6_dns_delegation (self); + if (addr_family == AF_INET6) { + NMActiveConnection *ac; + const CList *tmp_list; + + /* Tell devices needing a subnet about the new DNS configuration */ + nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { + device = nm_active_connection_get_device (ac); + if ( device + && device != changed_device + && nm_device_needs_ip6_subnet (device)) + nm_device_copy_ip6_dns_config (device, get_default_device (self, AF_INET6)); + } + } } static void -update_routing_and_dns (NMPolicy *self, gboolean force_update) +update_routing_and_dns (NMPolicy *self, + gboolean force_update, + NMDevice *changed_device) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); nm_dns_manager_begin_updates (priv->dns_manager, __func__); - update_ip_dns (self, AF_INET); - update_ip_dns (self, AF_INET6); + update_ip_dns (self, AF_INET, changed_device); + update_ip_dns (self, AF_INET6, changed_device); update_ip4_routing (self, force_update); update_ip6_routing (self, force_update); @@ -1859,14 +1854,14 @@ device_state_changed (NMDevice *device, if (ip6_config) _dns_manager_set_ip_config (priv->dns_manager, NM_IP_CONFIG_CAST (ip6_config), NM_DNS_IP_CONFIG_TYPE_DEFAULT, device); - update_routing_and_dns (self, FALSE); + update_routing_and_dns (self, FALSE, device); nm_dns_manager_end_updates (priv->dns_manager, __func__); break; case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: if (old_state > NM_DEVICE_STATE_DISCONNECTED) - update_routing_and_dns (self, FALSE); + update_routing_and_dns (self, FALSE, device); break; case NM_DEVICE_STATE_DEACTIVATING: if (sett_conn) { @@ -1901,7 +1896,7 @@ device_state_changed (NMDevice *device, reset_autoconnect_all (self, device, FALSE); if (old_state > NM_DEVICE_STATE_DISCONNECTED) - update_routing_and_dns (self, FALSE); + update_routing_and_dns (self, FALSE, device); /* Device is now available for auto-activation */ schedule_activate_check (self, device); @@ -1932,7 +1927,7 @@ device_state_changed (NMDevice *device, if ( s_con && nm_setting_connection_get_num_secondaries (s_con) > 0) { /* Make routes and DNS up-to-date before activating dependent connections */ - update_routing_and_dns (self, FALSE); + update_routing_and_dns (self, FALSE, device); /* Activate secondary (VPN) connections */ if (!activate_secondary_connections (self, @@ -1988,7 +1983,7 @@ device_ip_config_changed (NMDevice *device, if (old_config) nm_dns_manager_set_ip_config (priv->dns_manager, old_config, NM_DNS_IP_CONFIG_TYPE_REMOVED); } - update_ip_dns (self, addr_family); + update_ip_dns (self, addr_family, device); if (addr_family == AF_INET) update_ip4_routing (self, TRUE); else @@ -2110,7 +2105,7 @@ vpn_connection_activated (NMPolicy *self, NMVpnConnection *vpn) if (ip6_config) nm_dns_manager_set_ip_config (priv->dns_manager, NM_IP_CONFIG_CAST (ip6_config), NM_DNS_IP_CONFIG_TYPE_VPN); - update_routing_and_dns (self, TRUE); + update_routing_and_dns (self, TRUE, NULL); nm_dns_manager_end_updates (priv->dns_manager, __func__); } @@ -2132,7 +2127,7 @@ vpn_connection_deactivated (NMPolicy *self, NMVpnConnection *vpn) if (ip6_config) nm_dns_manager_set_ip_config (priv->dns_manager, NM_IP_CONFIG_CAST (ip6_config), NM_DNS_IP_CONFIG_TYPE_REMOVED); - update_routing_and_dns (self, TRUE); + update_routing_and_dns (self, TRUE, NULL); nm_dns_manager_end_updates (priv->dns_manager, __func__); } @@ -2673,7 +2668,7 @@ dispose (GObject *object) nm_clear_g_object (&priv->default_ac6); nm_clear_g_object (&priv->activating_ac4); nm_clear_g_object (&priv->activating_ac6); - g_clear_pointer (&priv->pending_active_connections, g_hash_table_unref); + nm_clear_pointer (&priv->pending_active_connections, g_hash_table_unref); c_list_for_each_entry_safe (data, data_safe, &priv->pending_activation_checks, pending_lst) activate_data_free (data); @@ -2711,9 +2706,9 @@ dispose (GObject *object) nm_clear_g_source (&priv->reset_retries_id); nm_clear_g_source (&priv->schedule_activate_all_id); - g_clear_pointer (&priv->orig_hostname, g_free); - g_clear_pointer (&priv->cur_hostname, g_free); - g_clear_pointer (&priv->last_hostname, g_free); + nm_clear_g_free (&priv->orig_hostname); + nm_clear_g_free (&priv->cur_hostname); + nm_clear_g_free (&priv->last_hostname); if (priv->hostname_manager) { g_signal_handlers_disconnect_by_data (priv->hostname_manager, priv); |