diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index b69b43203..b722f692c 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -227,21 +227,12 @@ pan_connection_check_create (NMBluezDevice *self) NULL); nm_connection_add_setting (connection, setting); - /* Setting: IPv4 */ - setting = nm_setting_ip4_config_new (); - g_object_set (G_OBJECT (setting), - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NM_SETTING_IP_CONFIG_MAY_FAIL, FALSE, - NULL); - nm_connection_add_setting (connection, setting); - - /* Setting: IPv6 */ - setting = nm_setting_ip6_config_new (); - g_object_set (G_OBJECT (setting), - NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, - NULL); - nm_connection_add_setting (connection, setting); + if (!nm_connection_normalize (connection, NULL, NULL, &error)) { + nm_log_err (LOGD_BT, "bluez[%s] couldn't generate a connection for NAP device: %s", + priv->path, error->message); + g_error_free (error); + g_return_if_reached (); + } /* Adding a new connection raises a signal which eventually calls check_emit_usable (again) * which then already finds the suitable connection in priv->connections. This is confusing, diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ff97475da..6347e292b 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4581,9 +4581,23 @@ nm_device_owns_iface (NMDevice *self, const char *iface) NMConnection * nm_device_new_default_connection (NMDevice *self) { - if (NM_DEVICE_GET_CLASS (self)->new_default_connection) - return NM_DEVICE_GET_CLASS (self)->new_default_connection (self); - return NULL; + NMConnection *connection; + GError *error = NULL; + + if (!NM_DEVICE_GET_CLASS (self)->new_default_connection) + return NULL; + + connection = NM_DEVICE_GET_CLASS (self)->new_default_connection (self); + if (!connection) + return NULL; + + if (!nm_connection_normalize (connection, NULL, NULL, &error)) { + _LOGD (LOGD_DEVICE, "device generated an invalid default connection: %s", error->message); + g_error_free (error); + g_return_val_if_reached (NULL); + } + + return connection; } static void @@ -5454,7 +5468,7 @@ nm_device_generate_connection (NMDevice *self, klass->update_connection (self, connection); - if (!nm_connection_verify (connection, &local)) { + if (!nm_connection_normalize (connection, NULL, NULL, error)) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "generated connection does not verify: %s", local->message);