summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2019-06-12 17:15:13 +0200
committerLubomir Rintel <lkundrak@v3.sk>2019-06-14 10:33:26 +0200
commitf2c066e1046cc8da5a277b1528a59bf2653e17c8 (patch)
treed039d8fc32f79923cc062c7cc0740aa99de79045
parentdedc0cba23b5d51773f88d8bc06424eb589083cd (diff)
downloadNetworkManager-f2c066e1046cc8da5a277b1528a59bf2653e17c8.tar.gz
ovs/ovsdb: signal a failure when an error column is set
When an interface (other OVS device types can not fail) encounters an error it indicates it by changing the error column. Watch for those changes so that we can eventually communicate them to the OVS factory to deal with them.
-rw-r--r--src/devices/ovs/nm-ovsdb.c24
-rw-r--r--src/devices/ovs/nm-ovsdb.h5
2 files changed, 24 insertions, 5 deletions
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
index 42e6b132fa..c11abe51c5 100644
--- a/src/devices/ovs/nm-ovsdb.c
+++ b/src/devices/ovs/nm-ovsdb.c
@@ -58,6 +58,7 @@ typedef struct {
enum {
DEVICE_ADDED,
DEVICE_REMOVED,
+ INTERFACE_FAILED,
LAST_SIGNAL
};
@@ -737,14 +738,14 @@ ovsdb_next_command (NMOvsdb *self)
msg = json_pack ("{s:i, s:s, s:[s, n, {"
" s:[{s:[s, s, s]}],"
" s:[{s:[s, s, s]}],"
- " s:[{s:[s, s, s]}],"
+ " s:[{s:[s, s, s, s]}],"
" s:[{s:[]}]"
"}]}",
"id", call->id,
"method", "monitor", "params", "Open_vSwitch",
"Bridge", "columns", "name", "ports", "external_ids",
"Port", "columns", "name", "interfaces", "external_ids",
- "Interface", "columns", "name", "type", "external_ids",
+ "Interface", "columns", "name", "type", "external_ids", "error",
"Open_vSwitch", "columns");
break;
case OVSDB_ADD_INTERFACE:
@@ -883,15 +884,17 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
/* Interfaces */
json_object_foreach (interface, key, value) {
+ json_t *error = NULL;
gboolean old = FALSE;
gboolean new = FALSE;
if (json_unpack (value, "{s:{}}", "old") == 0)
old = TRUE;
- if (json_unpack (value, "{s:{s:s, s:s, s:o}}", "new",
+ if (json_unpack (value, "{s:{s:s, s:s, s?:o, s:o}}", "new",
"name", &name,
"type", &type,
+ "error", &error,
"external_ids", &external_ids) == 0)
new = TRUE;
@@ -936,6 +939,14 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
ovs_interface->name, NM_DEVICE_TYPE_OVS_INTERFACE);
}
}
+ /* The error is a string. No error is indicated by an empty set,
+ * because why the fuck not: [ "set": [] ] */
+ if (error && json_is_string (error)) {
+ g_signal_emit (self, signals[INTERFACE_FAILED], 0,
+ ovs_interface->name,
+ ovs_interface->connection_uuid,
+ json_string_value (error));
+ }
g_hash_table_insert (priv->interfaces, g_strdup (key), ovs_interface);
}
}
@@ -1585,4 +1596,11 @@ nm_ovsdb_class_init (NMOvsdbClass *klass)
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
+
+ signals[INTERFACE_FAILED] =
+ g_signal_new (NM_OVSDB_INTERFACE_FAILED,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
}
diff --git a/src/devices/ovs/nm-ovsdb.h b/src/devices/ovs/nm-ovsdb.h
index c7f391fe31..279155a498 100644
--- a/src/devices/ovs/nm-ovsdb.h
+++ b/src/devices/ovs/nm-ovsdb.h
@@ -27,8 +27,9 @@
#define NM_IS_OVSDB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_OVSDB))
#define NM_OVSDB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_OVSDB, NMOvsdbClass))
-#define NM_OVSDB_DEVICE_ADDED "device-added"
-#define NM_OVSDB_DEVICE_REMOVED "device-removed"
+#define NM_OVSDB_DEVICE_ADDED "device-added"
+#define NM_OVSDB_DEVICE_REMOVED "device-removed"
+#define NM_OVSDB_INTERFACE_FAILED "interface-failed"
typedef struct _NMOvsdb NMOvsdb;
typedef struct _NMOvsdbClass NMOvsdbClass;