diff options
| author | Michael Biebl <biebl@debian.org> | 2018-03-13 01:29:54 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-03-13 01:29:54 +0100 |
| commit | 7e9ff09fcb2366b383b7ebbec80d2f6fff117290 (patch) | |
| tree | e48e88b177182607488bcfd2d2645dbc77276866 /src/devices/ovs | |
| parent | 50f6b47074e01dffb8dc536c0a20961dcf28ae9b (diff) | |
New upstream version 1.10.6 upstream/1.10.6
Diffstat (limited to 'src/devices/ovs')
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-interface.c | 2 | ||||
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-port.c | 47 | ||||
| -rw-r--r-- | src/devices/ovs/nm-ovsdb.c | 32 |
3 files changed, 39 insertions, 42 deletions
diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c index e746a3fd..ce32c2dd 100644 --- a/src/devices/ovs/nm-device-ovs-interface.c +++ b/src/devices/ovs/nm-device-ovs-interface.c @@ -50,7 +50,7 @@ struct _NMDeviceOvsInterfaceClass { G_DEFINE_TYPE (NMDeviceOvsInterface, nm_device_ovs_interface, NM_TYPE_DEVICE) -#define NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceOvsInterface, NM_IS_DEVICE_OVS_INTERFACE) +#define NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceOvsInterface, NM_IS_DEVICE_OVS_INTERFACE, NMDevice) /*****************************************************************************/ diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c index 83199f2d..cb0915af 100644 --- a/src/devices/ovs/nm-device-ovs-port.c +++ b/src/devices/ovs/nm-device-ovs-port.c @@ -114,12 +114,13 @@ add_iface_cb (GError *error, gpointer user_data) { NMDevice *slave = user_data; - if (error) { - nm_log_warn (LOGD_DEVICE, "device %s could not be added to a ovs port: %s", + if ( error + && !g_error_matches (error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING)) { + nm_log_warn (LOGD_DEVICE, "device %s could not be added to a ovs port: %s", nm_device_get_iface (slave), error->message); - nm_device_state_changed (slave, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_OVSDB_FAILED); + nm_device_state_changed (slave, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_OVSDB_FAILED); } g_object_unref (slave); @@ -128,23 +129,22 @@ add_iface_cb (GError *error, gpointer user_data) static gboolean enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) { - NMActiveConnection *ac_port = NULL; - NMActiveConnection *ac_bridge = NULL; + NMActiveConnection *ac_port = NULL; + NMActiveConnection *ac_bridge = NULL; if (!configure) return TRUE; + ac_port = NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)); + ac_bridge = nm_active_connection_get_master (ac_port); + if (!ac_bridge) + ac_bridge = ac_port; - ac_port = NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)); - ac_bridge = nm_active_connection_get_master (ac_port); - if (!ac_bridge) - ac_bridge = ac_port; - - nm_ovsdb_add_interface (nm_ovsdb_get (), - nm_active_connection_get_applied_connection (ac_bridge), - nm_device_get_applied_connection (device), - nm_device_get_applied_connection (slave), - add_iface_cb, g_object_ref (slave)); + nm_ovsdb_add_interface (nm_ovsdb_get (), + nm_active_connection_get_applied_connection (ac_bridge), + nm_device_get_applied_connection (device), + nm_device_get_applied_connection (slave), + add_iface_cb, g_object_ref (slave)); return TRUE; } @@ -154,12 +154,13 @@ del_iface_cb (GError *error, gpointer user_data) { NMDevice *slave = user_data; - if (error) { - nm_log_warn (LOGD_DEVICE, "device %s could not be removed from a ovs port: %s", + if ( error + && !g_error_matches (error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING)) { + nm_log_warn (LOGD_DEVICE, "device %s could not be removed from a ovs port: %s", nm_device_get_iface (slave), error->message); - nm_device_state_changed (slave, - NM_DEVICE_STATE_FAILED, - NM_DEVICE_STATE_REASON_OVSDB_FAILED); + nm_device_state_changed (slave, + NM_DEVICE_STATE_FAILED, + NM_DEVICE_STATE_REASON_OVSDB_FAILED); } g_object_unref (slave); @@ -169,7 +170,7 @@ static void release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { nm_ovsdb_del_interface (nm_ovsdb_get (), nm_device_get_iface (slave), - del_iface_cb, g_object_ref (slave)); + del_iface_cb, g_object_ref (slave)); } /*****************************************************************************/ diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index b44668c0..92fcfa01 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -119,7 +119,7 @@ NM_DEFINE_SINGLETON_GETTER (NMOvsdb, nm_ovsdb_get, NM_TYPE_OVSDB); /*****************************************************************************/ static void ovsdb_try_connect (NMOvsdb *self); -static void ovsdb_disconnect (NMOvsdb *self); +static void ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing); static void ovsdb_read (NMOvsdb *self); static void ovsdb_write (NMOvsdb *self); static void ovsdb_next_command (NMOvsdb *self); @@ -1103,7 +1103,7 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg) "result", &result, "error", &error) == -1) { _LOGW ("couldn't grok the message: %s", json_error.text); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } @@ -1114,7 +1114,7 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg) /* It's a method call! */ if (!params) { _LOGW ("a method call with no params: '%s'", method); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } @@ -1134,13 +1134,13 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg) /* This is a response to a method call. */ if (!priv->calls->len) { _LOGE ("there are no queued calls expecting response %" G_GUINT64_FORMAT, id); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } call = &g_array_index (priv->calls, OvsdbMethodCall, 0); if (call->id != id) { _LOGE ("expected a response to call %" G_GUINT64_FORMAT ", not %" G_GUINT64_FORMAT, call->id, id); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } /* Cool, we found a corresponsing call. Finish it. */ @@ -1219,7 +1219,7 @@ ovsdb_read_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) if (size == -1) { _LOGW ("short read from ovsdb: %s", error->message); g_clear_error (&error); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } @@ -1267,7 +1267,7 @@ ovsdb_write_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) if (size == -1) { _LOGW ("short write to ovsdb: %s", error->message); g_clear_error (&error); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); return; } @@ -1310,21 +1310,19 @@ ovsdb_write (NMOvsdb *self) * puts us back in sync. */ static void -ovsdb_disconnect (NMOvsdb *self) +ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing) { NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self); OvsdbMethodCall *call; OvsdbMethodCallback callback; gpointer user_data; - GError *error; + gs_free_error GError *error = NULL; _LOGD ("disconnecting from ovsdb"); + nm_utils_error_set_cancelled (&error, is_disposing, "NMOvsdb"); while (priv->calls->len) { - error = NULL; call = &g_array_index (priv->calls, OvsdbMethodCall, priv->calls->len - 1); - g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled"); - callback = call->callback; user_data = call->user_data; g_array_remove_index (priv->calls, priv->calls->len - 1); @@ -1343,12 +1341,10 @@ static void _monitor_bridges_cb (NMOvsdb *self, json_t *result, GError *error, gpointer user_data) { if (error) { - if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (!nm_utils_error_is_cancelled (error, TRUE)) { _LOGI ("%s", error->message); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); } - - g_clear_error (&error); return; } @@ -1371,7 +1367,7 @@ _client_connect_cb (GObject *source_object, GAsyncResult *res, gpointer user_dat if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) _LOGI ("%s", error->message); - ovsdb_disconnect (self); + ovsdb_disconnect (self, FALSE); g_clear_error (&error); return; } @@ -1555,7 +1551,7 @@ dispose (GObject *object) NMOvsdb *self = NM_OVSDB (object); NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self); - ovsdb_disconnect (self); + ovsdb_disconnect (self, TRUE); g_string_free (priv->input, TRUE); priv->input = NULL; |