core: merge branch 'bg/manager-parent-warnings-rh1490157'

https://bugzilla.redhat.com/show_bug.cgi?id=1490157
This commit is contained in:
Beniamino Galvani
2017-09-20 08:07:05 +02:00
7 changed files with 27 additions and 16 deletions

View File

@@ -143,6 +143,8 @@ GQuark nm_crypto_error_quark (void);
* activation request (eg, the #NMAccessPoint or #NMWimaxNsp) was not * activation request (eg, the #NMAccessPoint or #NMWimaxNsp) was not
* found. * found.
* @NM_DEVICE_ERROR_VERSION_ID_MISMATCH: the version id did not match. * @NM_DEVICE_ERROR_VERSION_ID_MISMATCH: the version id did not match.
* @NM_DEVICE_ERROR_MISSING_DEPENDENCIES: the requested operation could not
* be completed due to missing dependencies.
* *
* Device-related errors. * Device-related errors.
* *
@@ -160,6 +162,7 @@ typedef enum {
NM_DEVICE_ERROR_NOT_ALLOWED, /*< nick=NotAllowed >*/ NM_DEVICE_ERROR_NOT_ALLOWED, /*< nick=NotAllowed >*/
NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, /*< nick=SpecificObjectNotFound >*/ NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, /*< nick=SpecificObjectNotFound >*/
NM_DEVICE_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/ NM_DEVICE_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/
NM_DEVICE_ERROR_MISSING_DEPENDENCIES, /*< nick=MissingDependencies >*/
} NMDeviceError; } NMDeviceError;
#define NM_DEVICE_ERROR nm_device_error_quark () #define NM_DEVICE_ERROR nm_device_error_quark ()

View File

@@ -269,13 +269,13 @@ create_and_realize (NMDevice *device,
} }
if (!parent) { if (!parent) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"InfiniBand partitions can not be created without a parent interface"); "InfiniBand partitions can not be created without a parent interface");
return FALSE; return FALSE;
} }
if (!NM_IS_DEVICE_INFINIBAND (parent)) { if (!NM_IS_DEVICE_INFINIBAND (parent)) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"Parent interface %s must be an InfiniBand interface", "Parent interface %s must be an InfiniBand interface",
nm_device_get_iface (parent)); nm_device_get_iface (parent));
return FALSE; return FALSE;
@@ -283,7 +283,7 @@ create_and_realize (NMDevice *device,
priv->parent_ifindex = nm_device_get_ifindex (parent); priv->parent_ifindex = nm_device_get_ifindex (parent);
if (priv->parent_ifindex <= 0) { if (priv->parent_ifindex <= 0) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"failed to get InfiniBand parent %s ifindex", "failed to get InfiniBand parent %s ifindex",
nm_device_get_iface (parent)); nm_device_get_iface (parent));
return FALSE; return FALSE;

View File

@@ -692,7 +692,7 @@ create_and_realize (NMDevice *device,
g_assert (s_macsec); g_assert (s_macsec);
if (!parent) { if (!parent) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"MACsec devices can not be created without a parent interface"); "MACsec devices can not be created without a parent interface");
return FALSE; return FALSE;
} }

View File

@@ -234,7 +234,7 @@ create_and_realize (NMDevice *device,
parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0; parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0;
if (parent_ifindex <= 0) { if (parent_ifindex <= 0) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"MACVLAN devices can not be created without a parent interface"); "MACVLAN devices can not be created without a parent interface");
g_return_val_if_fail (!parent, FALSE); g_return_val_if_fail (!parent, FALSE);
return FALSE; return FALSE;

View File

@@ -209,7 +209,7 @@ create_and_realize (NMDevice *device,
int parent_ifindex; int parent_ifindex;
if (!parent) { if (!parent) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"PPP devices can not be created without a parent interface"); "PPP devices can not be created without a parent interface");
return FALSE; return FALSE;
} }

View File

@@ -231,15 +231,15 @@ create_and_realize (NMDevice *device,
g_assert (s_vlan); g_assert (s_vlan);
if (!parent) { if (!parent) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"VLAN devices can not be created without a parent interface"); "VLAN devices can not be created without a parent interface");
return FALSE; return FALSE;
} }
parent_ifindex = nm_device_get_ifindex (parent); parent_ifindex = nm_device_get_ifindex (parent);
if (parent_ifindex <= 0) { if (parent_ifindex <= 0) {
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
"cannot retrieve ifindex of interface %s (%s): skip VLAN creation for now", "cannot retrieve ifindex of interface %s (%s)",
nm_device_get_iface (parent), nm_device_get_iface (parent),
nm_device_get_type_desc (parent)); nm_device_get_type_desc (parent));
return FALSE; return FALSE;

View File

@@ -94,6 +94,8 @@ static void settings_startup_complete_changed (NMSettings *settings,
GParamSpec *pspec, GParamSpec *pspec,
NMManager *self); NMManager *self);
static void retry_connections_for_parent_device (NMManager *self, NMDevice *device);
static NM_CACHED_QUARK_FCN ("active-connection-add-and-activate", active_connection_add_and_activate_quark) static NM_CACHED_QUARK_FCN ("active-connection-add-and-activate", active_connection_add_and_activate_quark)
typedef struct { typedef struct {
@@ -1299,6 +1301,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
gs_free char *iface = NULL; gs_free char *iface = NULL;
NMDevice *device = NULL, *parent = NULL; NMDevice *device = NULL, *parent = NULL;
GError *error = NULL; GError *error = NULL;
NMLogLevel log_level;
g_return_val_if_fail (NM_IS_MANAGER (self), NULL); g_return_val_if_fail (NM_IS_MANAGER (self), NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
@@ -1379,12 +1382,20 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
/* Create any backing resources the device needs */ /* Create any backing resources the device needs */
if (!nm_device_create_and_realize (device, connection, parent, &error)) { if (!nm_device_create_and_realize (device, connection, parent, &error)) {
_LOG3W (LOGD_DEVICE, connection, "couldn't create the device: %s", log_level = g_error_matches (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_MISSING_DEPENDENCIES)
? LOGL_DEBUG
: LOGL_ERR;
_NMLOG3 (log_level, LOGD_DEVICE, connection,
"couldn't create the device: %s",
error->message); error->message);
g_error_free (error); g_error_free (error);
remove_device (self, device, FALSE, TRUE); remove_device (self, device, FALSE, TRUE);
return NULL; return NULL;
} }
retry_connections_for_parent_device (self, device);
break; break;
} }
@@ -2232,11 +2243,6 @@ add_device (NMManager *self, NMDevice *device, GError **error)
_parent_notify_changed (self, device, FALSE); _parent_notify_changed (self, device, FALSE);
/* Virtual connections may refer to the new device as
* parent device, retry to activate them.
*/
retry_connections_for_parent_device (self, device);
return TRUE; return TRUE;
} }
@@ -2262,6 +2268,7 @@ factory_device_added_cb (NMDeviceFactory *factory,
&error)) { &error)) {
add_device (self, device, NULL); add_device (self, device, NULL);
_device_realize_finish (self, device, NULL); _device_realize_finish (self, device, NULL);
retry_connections_for_parent_device (self, device);
} else { } else {
_LOG2W (LOGD_DEVICE, device, "failed to realize device: %s", error->message); _LOG2W (LOGD_DEVICE, device, "failed to realize device: %s", error->message);
g_error_free (error); g_error_free (error);
@@ -2415,6 +2422,7 @@ platform_link_added (NMManager *self,
&error)) { &error)) {
add_device (self, device, NULL); add_device (self, device, NULL);
_device_realize_finish (self, device, plink); _device_realize_finish (self, device, plink);
retry_connections_for_parent_device (self, device);
} else { } else {
_LOGW (LOGD_DEVICE, "%s: failed to realize device: %s", _LOGW (LOGD_DEVICE, "%s: failed to realize device: %s",
plink->name, error->message); plink->name, error->message);