diff options
| author | Michael Biebl <biebl@debian.org> | 2016-08-03 22:59:23 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-08-03 22:59:23 +0200 |
| commit | d6201f5d8daada3d64a0a3e0038e14eebec683ce (patch) | |
| tree | 035500728cc23e7ee5368c3fd605270265a077f7 /src/devices | |
| parent | 73e152af6e3fb4f5848bfb8394484026ff119003 (diff) | |
Imported Upstream version 1.2.4 upstream/1.2.4
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/adsl/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/bluetooth/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/bluetooth/nm-bluez-device.c | 88 | ||||
| -rw-r--r-- | src/devices/nm-device-bond.c | 2 | ||||
| -rw-r--r-- | src/devices/nm-device-tun.c | 7 | ||||
| -rw-r--r-- | src/devices/nm-device-vxlan.c | 7 | ||||
| -rw-r--r-- | src/devices/nm-device.c | 216 | ||||
| -rw-r--r-- | src/devices/nm-device.h | 4 | ||||
| -rw-r--r-- | src/devices/nm-lldp-listener.c | 4 | ||||
| -rw-r--r-- | src/devices/team/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/team/nm-device-team.c | 14 | ||||
| -rw-r--r-- | src/devices/tests/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/wifi/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 2 | ||||
| -rw-r--r-- | src/devices/wifi/tests/Makefile.in | 1 | ||||
| -rw-r--r-- | src/devices/wwan/Makefile.in | 1 |
17 files changed, 258 insertions, 94 deletions
diff --git a/src/devices/Makefile.in b/src/devices/Makefile.in index 4415d31b..d6848e53 100644 --- a/src/devices/Makefile.in +++ b/src/devices/Makefile.in @@ -324,6 +324,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/adsl/Makefile.in b/src/devices/adsl/Makefile.in index c8549200..b6805537 100644 --- a/src/devices/adsl/Makefile.in +++ b/src/devices/adsl/Makefile.in @@ -351,6 +351,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/bluetooth/Makefile.in b/src/devices/bluetooth/Makefile.in index 233ad9e8..d2b0b865 100644 --- a/src/devices/bluetooth/Makefile.in +++ b/src/devices/bluetooth/Makefile.in @@ -372,6 +372,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 5ee22f93..dcfa5eec 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -54,6 +54,8 @@ typedef struct { gboolean usable; NMBluetoothCapabilities connection_bt_type; + guint check_emit_usable_id; + char *adapter_address; char *address; char *name; @@ -257,14 +259,14 @@ pan_connection_check_create (NMBluezDevice *self) g_free (uuid); } -static void +static gboolean check_emit_usable (NMBluezDevice *self) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); gboolean new_usable; /* only expect the supported capabilities set. */ - g_assert ((priv->capabilities & ~(NM_BT_CAPABILITY_NAP | NM_BT_CAPABILITY_DUN)) == NM_BT_CAPABILITY_NONE ); + nm_assert ((priv->capabilities & ~(NM_BT_CAPABILITY_NAP | NM_BT_CAPABILITY_DUN)) == NM_BT_CAPABILITY_NONE ); new_usable = (priv->initialized && priv->capabilities && priv->name && ((priv->bluez_version == 4) || @@ -291,6 +293,17 @@ END: priv->usable = new_usable; g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_USABLE); } + + return G_SOURCE_REMOVE; +} + +static void +check_emit_usable_schedule (NMBluezDevice *self) +{ + NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); + + if (priv->check_emit_usable_id == 0) + priv->check_emit_usable_id = g_idle_add ((GSourceFunc) check_emit_usable, self); } /********************************************************************/ @@ -331,15 +344,26 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection) return TRUE; } -static void -_internal_add_connection (NMBluezDevice *self, NMConnection *connection) +static gboolean +_internal_track_connection (NMBluezDevice *self, NMConnection *connection, gboolean tracked) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); + gboolean was_tracked; + + was_tracked = !!g_slist_find (priv->connections, connection); + if (was_tracked == !!tracked) + return FALSE; - if (!g_slist_find (priv->connections, connection)) { + if (tracked) priv->connections = g_slist_prepend (priv->connections, g_object_ref (connection)); - check_emit_usable (self); + else { + priv->connections = g_slist_remove (priv->connections, connection); + if (priv->pan_connection == connection) + priv->pan_connection = NULL; + g_object_unref (connection); } + + return TRUE; } static void @@ -347,8 +371,10 @@ cp_connection_added (NMConnectionProvider *provider, NMConnection *connection, NMBluezDevice *self) { - if (connection_compatible (self, connection)) - _internal_add_connection (self, connection); + if (connection_compatible (self, connection)) { + if (_internal_track_connection (self, connection, TRUE)) + check_emit_usable (self); + } } static void @@ -356,15 +382,8 @@ cp_connection_removed (NMConnectionProvider *provider, NMConnection *connection, NMBluezDevice *self) { - NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); - - if (g_slist_find (priv->connections, connection)) { - priv->connections = g_slist_remove (priv->connections, connection); - if (priv->pan_connection == connection) - priv->pan_connection = NULL; - g_object_unref (connection); + if (_internal_track_connection (self, connection, FALSE)) check_emit_usable (self); - } } static void @@ -372,10 +391,9 @@ cp_connection_updated (NMConnectionProvider *provider, NMConnection *connection, NMBluezDevice *self) { - if (connection_compatible (self, connection)) - _internal_add_connection (self, connection); - else - cp_connection_removed (provider, connection, self); + if (_internal_track_connection (self, connection, + connection_compatible (self, connection))) + check_emit_usable_schedule (self); } static void @@ -383,10 +401,17 @@ load_connections (NMBluezDevice *self) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); const GSList *connections, *iter; + gboolean changed = FALSE; connections = nm_connection_provider_get_connections (priv->provider); - for (iter = connections; iter; iter = g_slist_next (iter)) - cp_connection_added (priv->provider, NM_CONNECTION (iter->data), self); + for (iter = connections; iter; iter = g_slist_next (iter)) { + NMConnection *connection = iter->data; + + if (connection_compatible (self, connection)) + changed |= _internal_track_connection (self, connection, TRUE); + } + if (changed) + check_emit_usable (self); } /***********************************************************/ @@ -1031,20 +1056,9 @@ nm_bluez_device_new (const char *path, if (adapter_address) set_adapter_address (self, adapter_address); - g_signal_connect (priv->provider, - NM_CP_SIGNAL_CONNECTION_ADDED, - G_CALLBACK (cp_connection_added), - self); - - g_signal_connect (priv->provider, - NM_CP_SIGNAL_CONNECTION_REMOVED, - G_CALLBACK (cp_connection_removed), - self); - - g_signal_connect (priv->provider, - NM_CP_SIGNAL_CONNECTION_UPDATED, - G_CALLBACK (cp_connection_updated), - self); + g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_ADDED, G_CALLBACK (cp_connection_added), self); + g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_REMOVED, G_CALLBACK (cp_connection_removed), self); + g_signal_connect (priv->provider, NM_CP_SIGNAL_CONNECTION_UPDATED, G_CALLBACK (cp_connection_updated), self); g_bus_get (G_BUS_TYPE_SYSTEM, NULL, @@ -1084,6 +1098,8 @@ dispose (GObject *object) NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); NMConnection *to_delete = NULL; + nm_clear_g_source (&priv->check_emit_usable_id); + if (priv->pan_connection) { /* Check whether we want to remove the created connection. If so, we take a reference * and delete it at the end of dispose(). */ diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 6ae29b9c..9c98c8ea 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -316,7 +316,7 @@ apply_bonding_config (NMDevice *device) if (NM_IN_STRSET (mode, "active-backup", "balance-alb", "balance-tlb")) { value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_PRIMARY); set_bond_attr (device, "primary", value ? value : ""); - set_simple_option (device, "lp_internal", s_bond, NM_SETTING_BOND_OPTION_LP_INTERVAL); + set_simple_option (device, "lp_interval", s_bond, NM_SETTING_BOND_OPTION_LP_INTERVAL); } /* Clear ARP targets */ diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index eac2fb82..01cd8ea6 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -104,6 +104,12 @@ reload_tun_properties (NMDeviceTun *self) g_object_thaw_notify (object); } +static NMDeviceCapabilities +get_generic_capabilities (NMDevice *dev) +{ + return NM_DEVICE_CAP_IS_SOFTWARE; +} + static void link_changed (NMDevice *device, NMPlatformLink *info) { @@ -430,6 +436,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) device_class->complete_connection = complete_connection; device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; + device_class->get_generic_capabilities = get_generic_capabilities; device_class->realize_start_notify = realize_start_notify; device_class->unrealize_notify = unrealize_notify; device_class->update_connection = update_connection; diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index d308d47a..45f33bdd 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -136,6 +136,12 @@ update_properties (NMDevice *device) g_object_thaw_notify (object); } +static NMDeviceCapabilities +get_generic_capabilities (NMDevice *dev) +{ + return NM_DEVICE_CAP_IS_SOFTWARE; +} + static void link_changed (NMDevice *device, NMPlatformLink *info) { @@ -647,6 +653,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) device_class->create_and_realize = create_and_realize; device_class->check_connection_compatible = check_connection_compatible; device_class->complete_connection = complete_connection; + device_class->get_generic_capabilities = get_generic_capabilities; device_class->update_connection = update_connection; device_class->act_stage1_prepare = act_stage1_prepare; device_class->ip4_config_pre_commit = ip4_config_pre_commit; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8472ff80..62259bc4 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -34,7 +34,7 @@ #include <netlink/route/addr.h> #include <linux/if_addr.h> -#include "nm-device.h" +#include "nm-common-macros.h" #include "nm-device-private.h" #include "NetworkManagerUtils.h" #include "nm-manager.h" @@ -387,6 +387,9 @@ static gboolean nm_device_set_ip6_config (NMDevice *self, gboolean commit, gboolean routes_full_sync, NMDeviceStateReason *reason); +static gboolean ip6_config_merge_and_apply (NMDevice *self, + gboolean commit, + NMDeviceStateReason *out_reason); static void nm_device_master_add_slave (NMDevice *self, NMDevice *slave, gboolean configure); static void nm_device_slave_notify_enslave (NMDevice *self, gboolean success); @@ -413,6 +416,7 @@ static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, N static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason); static void nm_device_start_ip_check (NMDevice *self); static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink); +static void nm_device_set_mtu (NMDevice *self, guint32 mtu); /***********************************************************/ @@ -520,6 +524,34 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_reason_to_string, NMDeviceStateReason, /***********************************************************/ +static void +init_ip4_config_dns_priority (NMDevice *self, NMIP4Config *config) +{ + gs_free char *value = NULL; + gint priority; + + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "ipv4.dns-priority", + self); + priority = _nm_utils_ascii_str_to_int64 (value, 10, G_MININT, G_MAXINT, 0); + nm_ip4_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL); +} + +static void +init_ip6_config_dns_priority (NMDevice *self, NMIP6Config *config) +{ + gs_free char *value = NULL; + gint priority; + + value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, + "ipv6.dns-priority", + self); + priority = _nm_utils_ascii_str_to_int64 (value, 10, G_MININT, G_MAXINT, 0); + nm_ip6_config_set_dns_priority (config, priority ?: NM_DNS_PRIORITY_DEFAULT_NORMAL); +} + +/***********************************************************/ + gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value) { @@ -1091,6 +1123,38 @@ find_slave_info (NMDevice *self, NMDevice *slave) return NULL; } +static void +apply_mtu_from_config (NMDevice *self) +{ + const char *method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + NMSettingIPConfig *s_ip4; + NMSettingWired *s_wired; + guint32 mtu; + + /* Devices having an IPv4 configuration will set MTU during the commit + * stage, so it is an error to call this function if the IPv4 method is not + * 'disabled'. + */ + s_ip4 = (NMSettingIPConfig *) + nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP4_CONFIG); + if (s_ip4) + method = nm_setting_ip_config_get_method (s_ip4); + g_return_if_fail (nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)); + + s_wired = (NMSettingWired *) + nm_device_get_applied_setting (self, NM_TYPE_SETTING_WIRED); + + if (s_wired) { + mtu = nm_setting_wired_get_mtu (s_wired); + if (mtu) { + _LOGD (LOGD_DEVICE | LOGD_IP, + "setting MTU of device without IP4 config to %u", + mtu); + nm_device_set_mtu (self, mtu); + } + } +} + /** * nm_device_master_enslave_slave: * @self: the master device @@ -1148,6 +1212,11 @@ nm_device_master_enslave_slave (NMDevice *self, NMDevice *slave, NMConnection *c nm_device_activate_stage3_ip6_start (self); } + /* Since slave devices don't have their own IP configuration, + * set the MTU here. + */ + apply_mtu_from_config (slave); + return success; } @@ -1500,6 +1569,7 @@ device_link_changed (NMDevice *self) NMPlatformLink info; const NMPlatformLink *pllink; int ifindex; + gboolean was_up; priv->device_link_changed_id = 0; @@ -1572,6 +1642,7 @@ device_link_changed (NMDevice *self) if (ip_ifname_changed) nm_device_update_dynamic_ip_setup (self); + was_up = priv->up; priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP); if ( info.initialized @@ -1599,6 +1670,20 @@ device_link_changed (NMDevice *self) set_unmanaged_external_down (self, FALSE); device_recheck_slave_status (self, &info); + + if (priv->up && !was_up) { + /* the link was down and just came up. That happens for example, while changing MTU. + * We must restore IP configuration. */ + if (priv->ip4_state == IP_DONE) { + if (!ip4_config_merge_and_apply (self, NULL, TRUE, NULL)) + _LOGW (LOGD_IP4, "failed applying IP4 config after link comes up again"); + } + if (priv->ip6_state == IP_DONE) { + if (!ip6_config_merge_and_apply (self, TRUE, NULL)) + _LOGW (LOGD_IP6, "failed applying IP6 config after link comes up again"); + } + } + return G_SOURCE_REMOVE; } @@ -4287,6 +4372,7 @@ ip4_config_merge_and_apply (NMDevice *self, gboolean routes_full_sync; gboolean ignore_auto_routes = FALSE; gboolean ignore_auto_dns = FALSE; + gboolean auto_method = FALSE; /* Merge all the configs into the composite config */ if (config) { @@ -4302,10 +4388,15 @@ ip4_config_merge_and_apply (NMDevice *self, if (s_ip4) { ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip4); ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip4); + + if (nm_streq0 (nm_setting_ip_config_get_method (s_ip4), + NM_SETTING_IP4_CONFIG_METHOD_AUTO)) + auto_method = TRUE; } } composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); + init_ip4_config_dns_priority (self, composite); if (commit) ensure_con_ip4_config (self); @@ -4357,10 +4448,12 @@ ip4_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - if (nm_device_uses_generated_assumed_connection (self)) { - /* a generate-assumed-connection always detects the default route from platform */ + /* a generated-assumed connection detects the default route from the platform, + * but if the IP method is automatic we need to update the default route to + * maintain connectivity. + */ + if (nm_device_uses_generated_assumed_connection (self) && !auto_method) goto END_ADD_DEFAULT_ROUTE; - } /* At this point, we treat assumed and non-assumed connections alike. * For assumed connections we do that because we still manage RA and DHCP @@ -4946,7 +5039,8 @@ act_stage3_ip4_config_start (NMDevice *self, } else ret = NM_ACT_STAGE_RETURN_FAILURE; } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) { - /* Nothing to do... */ + apply_mtu_from_config (self); + /* Nothing else to do... */ ret = NM_ACT_STAGE_RETURN_STOP; } else _LOGW (LOGD_IP4, "unhandled IPv4 config method '%s'; will fail", method); @@ -5009,6 +5103,7 @@ ip6_config_merge_and_apply (NMDevice *self, gboolean routes_full_sync; gboolean ignore_auto_routes = FALSE; gboolean ignore_auto_dns = FALSE; + gboolean auto_method = FALSE; /* Apply ignore-auto-routes and ignore-auto-dns settings */ connection = nm_device_get_applied_connection (self); @@ -5018,14 +5113,21 @@ ip6_config_merge_and_apply (NMDevice *self, if (s_ip6) { ignore_auto_routes = nm_setting_ip_config_get_ignore_auto_routes (s_ip6); ignore_auto_dns = nm_setting_ip_config_get_ignore_auto_dns (s_ip6); + + if (NM_IN_STRSET (nm_setting_ip_config_get_method (s_ip6), + NM_SETTING_IP6_CONFIG_METHOD_AUTO, + NM_SETTING_IP6_CONFIG_METHOD_DHCP)) + auto_method = TRUE; } } /* If no config was passed in, create a new one */ composite = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); + init_ip6_config_dns_priority (self, composite); if (commit) ensure_con_ip6_config (self); + g_assert (composite); /* Merge all the IP configs into the composite config */ @@ -5081,10 +5183,12 @@ ip6_config_merge_and_apply (NMDevice *self, goto END_ADD_DEFAULT_ROUTE; } - if (nm_device_uses_generated_assumed_connection (self)) { - /* a generate-assumed-connection always detects the default route from platform */ + /* a generated-assumed connection detects the default route from the platform, + * but if the IP method is automatic we need to update the default route to + * maintain connectivity. + */ + if (nm_device_uses_generated_assumed_connection (self) && !auto_method) goto END_ADD_DEFAULT_ROUTE; - } /* At this point, we treat assumed and non-assumed connections alike. * For assumed connections we do that because we still manage RA and DHCP @@ -7895,6 +7999,9 @@ nm_device_set_ip4_config (NMDevice *self, g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + _LOGD (LOGD_IP4, "ip4-config: update (commit=%d, routes-full-sync=%d, new-config=%p)", + commit, routes_full_sync, new_config); + priv = NM_DEVICE_GET_PRIVATE (self); ip_ifindex = nm_device_get_ip_ifindex (self); @@ -7928,7 +8035,7 @@ nm_device_set_ip4_config (NMDevice *self, * this causes a re-read and reset. This should only happen for relevant changes */ nm_ip4_config_replace (old_config, new_config, &has_changes); if (has_changes) { - _LOGD (LOGD_IP4, "update IP4Config instance (%s)", + _LOGD (LOGD_IP4, "ip4-config: update IP4Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); } } else { @@ -7938,13 +8045,13 @@ nm_device_set_ip4_config (NMDevice *self, if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config))) nm_exported_object_export (NM_EXPORTED_OBJECT (new_config)); - _LOGD (LOGD_IP4, "set IP4Config instance (%s)", + _LOGD (LOGD_IP4, "ip4-config: set IP4Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config))); } } else if (old_config) { has_changes = TRUE; priv->ip4_config = NULL; - _LOGD (LOGD_IP4, "clear IP4Config instance (%s)", + _LOGD (LOGD_IP4, "ip4-config: clear IP4Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); /* Device config is invalid if combined config is invalid */ g_clear_object (&priv->dev_ip4_config); @@ -7963,23 +8070,16 @@ nm_device_set_ip4_config (NMDevice *self, nm_exported_object_clear_and_unexport (&old_config); if (nm_device_uses_generated_assumed_connection (self)) { - NMConnection *connection = nm_device_get_applied_connection (self); NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self)); NMSetting *s_ip4; - g_object_freeze_notify (G_OBJECT (connection)); g_object_freeze_notify (G_OBJECT (settings_connection)); nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP4_CONFIG); s_ip4 = nm_ip4_config_create_setting (priv->ip4_config); nm_connection_add_setting (settings_connection, s_ip4); - nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP4_CONFIG); - s_ip4 = nm_ip4_config_create_setting (priv->ip4_config); - nm_connection_add_setting (connection, s_ip4); - g_object_thaw_notify (G_OBJECT (settings_connection)); - g_object_thaw_notify (G_OBJECT (connection)); } nm_device_queue_recheck_assume (self); @@ -8070,6 +8170,9 @@ nm_device_set_ip6_config (NMDevice *self, g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); + _LOGD (LOGD_IP6, "ip6-config: update (commit=%d, routes-full-sync=%d, new-config=%p)", + commit, routes_full_sync, new_config); + priv = NM_DEVICE_GET_PRIVATE (self); ip_ifindex = nm_device_get_ip_ifindex (self); @@ -8097,7 +8200,7 @@ nm_device_set_ip6_config (NMDevice *self, * this causes a re-read and reset. This should only happen for relevant changes */ nm_ip6_config_replace (old_config, new_config, &has_changes); if (has_changes) { - _LOGD (LOGD_IP6, "update IP6Config instance (%s)", + _LOGD (LOGD_IP6, "ip6-config: update IP6Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); } } else { @@ -8107,13 +8210,13 @@ nm_device_set_ip6_config (NMDevice *self, if (success && !nm_exported_object_is_exported (NM_EXPORTED_OBJECT (new_config))) nm_exported_object_export (NM_EXPORTED_OBJECT (new_config)); - _LOGD (LOGD_IP6, "set IP6Config instance (%s)", + _LOGD (LOGD_IP6, "ip6-config: set IP6Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (new_config))); } } else if (old_config) { has_changes = TRUE; priv->ip6_config = NULL; - _LOGD (LOGD_IP6, "clear IP6Config instance (%s)", + _LOGD (LOGD_IP6, "ip6-config: clear IP6Config instance (%s)", nm_exported_object_get_path (NM_EXPORTED_OBJECT (old_config))); } @@ -8128,23 +8231,16 @@ nm_device_set_ip6_config (NMDevice *self, nm_exported_object_clear_and_unexport (&old_config); if (nm_device_uses_generated_assumed_connection (self)) { - NMConnection *connection = nm_device_get_applied_connection (self); NMConnection *settings_connection = NM_CONNECTION (nm_device_get_settings_connection (self)); NMSetting *s_ip6; - g_object_freeze_notify (G_OBJECT (connection)); g_object_freeze_notify (G_OBJECT (settings_connection)); nm_connection_remove_setting (settings_connection, NM_TYPE_SETTING_IP6_CONFIG); s_ip6 = nm_ip6_config_create_setting (priv->ip6_config); nm_connection_add_setting (settings_connection, s_ip6); - nm_connection_remove_setting (connection, NM_TYPE_SETTING_IP6_CONFIG); - s_ip6 = nm_ip6_config_create_setting (priv->ip6_config); - nm_connection_add_setting (connection, s_ip6); - g_object_thaw_notify (G_OBJECT (settings_connection)); - g_object_thaw_notify (G_OBJECT (connection)); } nm_device_queue_recheck_assume (self); @@ -8545,6 +8641,17 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) nm_device_update_hw_address (self); _update_ip4_address (self); + + /* when the link comes up, we must restore IP configuration if necessary. */ + if (priv->ip4_state == IP_DONE) { + if (!ip4_config_merge_and_apply (self, NULL, TRUE, NULL)) + _LOGW (LOGD_IP4, "failed applying IP4 config after bringing link up"); + } + if (priv->ip6_state == IP_DONE) { + if (!ip6_config_merge_and_apply (self, TRUE, NULL)) + _LOGW (LOGD_IP6, "failed applying IP6 config after bringing link up"); + } + return TRUE; } @@ -8782,7 +8889,6 @@ update_ip4_config (NMDevice *self, gboolean initial) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); int ifindex; gboolean capture_resolv_conf; - NMDnsManagerResolvConfMode resolv_conf_mode; /* If a commit is scheduled, this function would potentially interfere with * it changing IP configurations before they are applied. Postpone the @@ -8801,8 +8907,8 @@ update_ip4_config (NMDevice *self, gboolean initial) if (!ifindex) return; - resolv_conf_mode = nm_dns_manager_get_resolv_conf_mode (nm_dns_manager_get ()); - capture_resolv_conf = initial && (resolv_conf_mode == NM_DNS_MANAGER_RESOLV_CONF_EXPLICIT); + capture_resolv_conf = initial + && nm_dns_manager_get_resolv_conf_explicit (nm_dns_manager_get ()); /* IPv4 */ g_clear_object (&priv->ext_ip4_config); @@ -8873,7 +8979,6 @@ update_ip6_config (NMDevice *self, gboolean initial) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); int ifindex; gboolean capture_resolv_conf; - NMDnsManagerResolvConfMode resolv_conf_mode; /* If a commit is scheduled, this function would potentially interfere with * it changing IP configurations before they are applied. Postpone the @@ -8892,8 +8997,8 @@ update_ip6_config (NMDevice *self, gboolean initial) if (!ifindex) return; - resolv_conf_mode = nm_dns_manager_get_resolv_conf_mode (nm_dns_manager_get ()); - capture_resolv_conf = initial && (resolv_conf_mode == NM_DNS_MANAGER_RESOLV_CONF_EXPLICIT); + capture_resolv_conf = initial + && nm_dns_manager_get_resolv_conf_explicit (nm_dns_manager_get ()); /* IPv6 */ g_clear_object (&priv->ext_ip6_config); @@ -8994,9 +9099,9 @@ queued_ip6_config_change (gpointer user_data) g_object_ref (self); update_ip6_config (self, FALSE); - if ( nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex) - && priv->state < NM_DEVICE_STATE_DEACTIVATING) { - /* Handle DAD falures */ + if ( priv->state < NM_DEVICE_STATE_DEACTIVATING + && nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex)) { + /* Handle DAD failures */ for (iter = priv->dad6_failed_addrs; iter; iter = g_slist_next (iter)) { NMPlatformIP6Address *addr = iter->data; @@ -9277,6 +9382,7 @@ nm_device_get_unmanaged_flags (NMDevice *self, NMUnmanagedFlags flag) * @allow_state_transition: if %FALSE, setting flags never triggers a device * state change. If %TRUE, the device can change state, if it is real and * switches from managed to unmanaged (or vice versa). + * @now: whether the state change should be immediate or delayed * @reason: the device state reason passed to nm_device_state_changed() if * the device becomes managed/unmanaged. This is only relevant if the * device switches state and if @allow_state_transition is %TRUE. @@ -9288,11 +9394,13 @@ _set_unmanaged_flags (NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, gboolean allow_state_transition, + gboolean now, NMDeviceStateReason reason) { NMDevicePrivate *priv; gboolean was_managed, transition_state; NMUnmanagedFlags old_flags, old_mask; + NMDeviceState new_state; const char *operation = NULL; char str1[512]; char str2[512]; @@ -9364,10 +9472,11 @@ _set_unmanaged_flags (NMDevice *self, #undef _FMT if (transition_state) { - if (was_managed) - nm_device_state_changed (self, NM_DEVICE_STATE_UNMANAGED, reason); + new_state = was_managed ? NM_DEVICE_STATE_UNMANAGED : NM_DEVICE_STATE_UNAVAILABLE; + if (now) + nm_device_state_changed (self, new_state, reason); else - nm_device_state_changed (self, NM_DEVICE_STATE_UNAVAILABLE, reason); + nm_device_queue_state (self, new_state, reason); } } @@ -9385,7 +9494,7 @@ nm_device_set_unmanaged_flags (NMDevice *self, NMUnmanagedFlags flags, NMUnmanFlagOp set_op) { - _set_unmanaged_flags (self, flags, set_op, FALSE, NM_DEVICE_STATE_REASON_NONE); + _set_unmanaged_flags (self, flags, set_op, FALSE, FALSE, NM_DEVICE_STATE_REASON_NONE); } /** @@ -9406,7 +9515,16 @@ nm_device_set_unmanaged_by_flags (NMDevice *self, NMUnmanFlagOp set_op, NMDeviceStateReason reason) { - _set_unmanaged_flags (self, flags, set_op, TRUE, reason); + _set_unmanaged_flags (self, flags, set_op, TRUE, TRUE, reason); +} + +void +nm_device_set_unmanaged_by_flags_queue (NMDevice *self, + NMUnmanagedFlags flags, + NMUnmanFlagOp set_op, + NMDeviceStateReason reason) +{ + _set_unmanaged_flags (self, flags, set_op, TRUE, FALSE, reason); } void @@ -9710,12 +9828,6 @@ nm_device_check_connection_available (NMDevice *self, return available; } -static void -available_connections_notify (NMDevice *self) -{ - _notify (self, PROP_AVAILABLE_CONNECTIONS); -} - static gboolean available_connections_del_all (NMDevice *self) { @@ -9815,7 +9927,7 @@ nm_device_recheck_available_connections (NMDevice *self) } if (changed) - available_connections_notify (self); + _notify (self, PROP_AVAILABLE_CONNECTIONS); available_connections_check_delete_unrealized (self); } @@ -9889,7 +10001,7 @@ cp_connection_added_or_updated (NMConnectionProvider *cp, NMConnection *connecti changed = available_connections_del (self, connection); if (changed) { - available_connections_notify (self); + _notify (self, PROP_AVAILABLE_CONNECTIONS); available_connections_check_delete_unrealized (self); } } @@ -9902,7 +10014,7 @@ cp_connection_removed (NMConnectionProvider *cp, NMConnection *connection, gpoin g_return_if_fail (NM_IS_DEVICE (self)); if (available_connections_del (self, connection)) { - available_connections_notify (self); + _notify (self, PROP_AVAILABLE_CONNECTIONS); available_connections_check_delete_unrealized (self); } } @@ -10524,7 +10636,7 @@ _set_state_full (NMDevice *self, if (state <= NM_DEVICE_STATE_UNAVAILABLE) { if (available_connections_del_all (self)) - available_connections_notify (self); + _notify (self, PROP_AVAILABLE_CONNECTIONS); if (old_state > NM_DEVICE_STATE_UNAVAILABLE) _clear_queued_act_request (priv); } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 9f689850..21804396 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -489,6 +489,10 @@ void nm_device_set_unmanaged_by_flags (NMDevice *device, NMUnmanagedFlags flags, NMUnmanFlagOp set_op, NMDeviceStateReason reason); +void nm_device_set_unmanaged_by_flags_queue (NMDevice *self, + NMUnmanagedFlags flags, + NMUnmanFlagOp set_op, + NMDeviceStateReason reason); void nm_device_set_unmanaged_by_user_config (NMDevice *self, const GSList *unmanaged_specs); void nm_device_set_unmanaged_by_user_udev (NMDevice *self); void nm_device_set_unmanaged_by_quitting (NMDevice *device); diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index 592059f5..9cc1d086 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -531,7 +531,7 @@ lldp_neighbor_new (sd_lldp_neighbor *neighbor_sd, GError **error) neigh->valid = TRUE; out: - return nm_unauto (&neigh); + return g_steal_pointer (&neigh); } static GVariant * @@ -694,7 +694,7 @@ process_lldp_neighbor (NMLldpListener *self, sd_lldp_neighbor *neighbor_sd, gboo LOG_NEIGH_ARG (neigh)); changed = TRUE; - g_hash_table_add (priv->lldp_neighbors, nm_unauto (&neigh)); + g_hash_table_add (priv->lldp_neighbors, g_steal_pointer (&neigh)); done: if (changed) diff --git a/src/devices/team/Makefile.in b/src/devices/team/Makefile.in index 115a7589..4ca3014f 100644 --- a/src/devices/team/Makefile.in +++ b/src/devices/team/Makefile.in @@ -355,6 +355,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 60842c18..b4b522d8 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -318,10 +318,18 @@ teamd_dbus_appeared (GDBusConnection *connection, 2000, NULL, NULL); - g_variant_get (ret, "(u)", &pid); - if (pid != priv->teamd_pid) - teamd_cleanup (device, FALSE); + if (ret) { + g_variant_get (ret, "(u)", &pid); + if (pid != priv->teamd_pid) + teamd_cleanup (device, FALSE); + } else { + _LOGW (LOGD_TEAM, "failed to determine D-Bus name owner"); + /* If we can't determine the bus name owner, don't kill our + * teamd instance. Hopefully another existing teamd just died and + * our instance will be able to grab the bus name. + */ + } } /* Grab a teamd control handle even if we aren't going to use it diff --git a/src/devices/tests/Makefile.in b/src/devices/tests/Makefile.in index 31cf0d38..b07e6dfd 100644 --- a/src/devices/tests/Makefile.in +++ b/src/devices/tests/Makefile.in @@ -527,6 +527,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/wifi/Makefile.in b/src/devices/wifi/Makefile.in index a180a434..34aa4b97 100644 --- a/src/devices/wifi/Makefile.in +++ b/src/devices/wifi/Makefile.in @@ -394,6 +394,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 95a89eab..82b12a11 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <errno.h> +#include "nm-common-macros.h" #include "nm-device.h" #include "nm-device-wifi.h" #include "nm-device-private.h" @@ -696,6 +697,7 @@ manf_defaults[] = { "WLAN", "ALICE-WLAN", "Speedport W 501V", + "TURBONETT", }; #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) diff --git a/src/devices/wifi/tests/Makefile.in b/src/devices/wifi/tests/Makefile.in index be874cc3..956730f8 100644 --- a/src/devices/wifi/tests/Makefile.in +++ b/src/devices/wifi/tests/Makefile.in @@ -522,6 +522,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ diff --git a/src/devices/wwan/Makefile.in b/src/devices/wwan/Makefile.in index e7722414..89328665 100644 --- a/src/devices/wwan/Makefile.in +++ b/src/devices/wwan/Makefile.in @@ -363,6 +363,7 @@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ +NM_CONFIG_DEFAULT_DNS_RC_MANAGER = @NM_CONFIG_DEFAULT_DNS_RC_MANAGER@ NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT = @NM_CONFIG_DEFAULT_LOGGING_AUDIT_TEXT@ NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT = @NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ |