mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 04:58:01 +02:00
parent
e896488e1e
commit
7a2ca63fde
1 changed files with 20 additions and 29 deletions
|
|
@ -504,12 +504,15 @@ _add_interface (NMOvsdb *self, json_t *params,
|
||||||
OpenvswitchBridge *ovs_bridge = NULL;
|
OpenvswitchBridge *ovs_bridge = NULL;
|
||||||
OpenvswitchPort *ovs_port = NULL;
|
OpenvswitchPort *ovs_port = NULL;
|
||||||
OpenvswitchInterface *ovs_interface = NULL;
|
OpenvswitchInterface *ovs_interface = NULL;
|
||||||
|
nm_auto_decref_json json_t *bridges = NULL;
|
||||||
|
nm_auto_decref_json json_t *new_bridges = NULL;
|
||||||
|
nm_auto_decref_json json_t *ports = NULL;
|
||||||
|
nm_auto_decref_json json_t *new_ports = NULL;
|
||||||
|
nm_auto_decref_json json_t *interfaces = NULL;
|
||||||
|
nm_auto_decref_json json_t *new_interfaces = NULL;
|
||||||
|
gboolean has_interface = FALSE;
|
||||||
int pi;
|
int pi;
|
||||||
int ii;
|
int ii;
|
||||||
json_t *bridges, *new_bridges;
|
|
||||||
json_t *ports, *new_ports;
|
|
||||||
json_t *interfaces, *new_interfaces;
|
|
||||||
gboolean has_interface = FALSE;
|
|
||||||
|
|
||||||
bridges = json_array ();
|
bridges = json_array ();
|
||||||
ports = json_array ();
|
ports = json_array ();
|
||||||
|
|
@ -585,14 +588,6 @@ _add_interface (NMOvsdb *self, json_t *params,
|
||||||
_insert_interface (params, interface);
|
_insert_interface (params, interface);
|
||||||
json_array_append_new (new_interfaces, json_pack ("[s, s]", "named-uuid", "rowInterface"));
|
json_array_append_new (new_interfaces, json_pack ("[s, s]", "named-uuid", "rowInterface"));
|
||||||
}
|
}
|
||||||
|
|
||||||
json_decref (interfaces);
|
|
||||||
json_decref (ports);
|
|
||||||
json_decref (bridges);
|
|
||||||
|
|
||||||
json_decref (new_interfaces);
|
|
||||||
json_decref (new_ports);
|
|
||||||
json_decref (new_bridges);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -612,14 +607,12 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname)
|
||||||
OpenvswitchBridge *ovs_bridge;
|
OpenvswitchBridge *ovs_bridge;
|
||||||
OpenvswitchPort *ovs_port;
|
OpenvswitchPort *ovs_port;
|
||||||
OpenvswitchInterface *ovs_interface;
|
OpenvswitchInterface *ovs_interface;
|
||||||
int pi;
|
|
||||||
int ii;
|
|
||||||
json_t *bridges, *new_bridges;
|
json_t *bridges, *new_bridges;
|
||||||
json_t *ports, *new_ports;
|
|
||||||
json_t *interfaces, *new_interfaces;
|
|
||||||
gboolean bridges_changed;
|
gboolean bridges_changed;
|
||||||
gboolean ports_changed;
|
gboolean ports_changed;
|
||||||
gboolean interfaces_changed;
|
gboolean interfaces_changed;
|
||||||
|
int pi;
|
||||||
|
int ii;
|
||||||
|
|
||||||
bridges = json_array ();
|
bridges = json_array ();
|
||||||
new_bridges = json_array ();
|
new_bridges = json_array ();
|
||||||
|
|
@ -627,20 +620,26 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname)
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, priv->bridges);
|
g_hash_table_iter_init (&iter, priv->bridges);
|
||||||
while (g_hash_table_iter_next (&iter, (gpointer) &bridge_uuid, (gpointer) &ovs_bridge)) {
|
while (g_hash_table_iter_next (&iter, (gpointer) &bridge_uuid, (gpointer) &ovs_bridge)) {
|
||||||
json_array_append_new (bridges, json_pack ("[s,s]", "uuid", bridge_uuid));
|
nm_auto_decref_json json_t *ports = NULL;
|
||||||
|
nm_auto_decref_json json_t *new_ports = NULL;
|
||||||
|
|
||||||
ports = json_array ();
|
ports = json_array ();
|
||||||
new_ports = json_array ();
|
new_ports = json_array ();
|
||||||
ports_changed = FALSE;
|
ports_changed = FALSE;
|
||||||
|
|
||||||
|
json_array_append_new (bridges, json_pack ("[s,s]", "uuid", bridge_uuid));
|
||||||
|
|
||||||
for (pi = 0; pi < ovs_bridge->ports->len; pi++) {
|
for (pi = 0; pi < ovs_bridge->ports->len; pi++) {
|
||||||
|
nm_auto_decref_json json_t *interfaces = NULL;
|
||||||
|
nm_auto_decref_json json_t *new_interfaces = NULL;
|
||||||
|
|
||||||
|
interfaces = json_array ();
|
||||||
|
new_interfaces = json_array ();
|
||||||
port_uuid = g_ptr_array_index (ovs_bridge->ports, pi);
|
port_uuid = g_ptr_array_index (ovs_bridge->ports, pi);
|
||||||
ovs_port = g_hash_table_lookup (priv->ports, port_uuid);
|
ovs_port = g_hash_table_lookup (priv->ports, port_uuid);
|
||||||
|
|
||||||
json_array_append_new (ports, json_pack ("[s,s]", "uuid", port_uuid));
|
json_array_append_new (ports, json_pack ("[s,s]", "uuid", port_uuid));
|
||||||
|
|
||||||
interfaces = json_array ();
|
|
||||||
new_interfaces = json_array ();
|
|
||||||
interfaces_changed = FALSE;
|
interfaces_changed = FALSE;
|
||||||
|
|
||||||
for (ii = 0; ii < ovs_port->interfaces->len; ii++) {
|
for (ii = 0; ii < ovs_port->interfaces->len; ii++) {
|
||||||
|
|
@ -667,9 +666,6 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname)
|
||||||
}
|
}
|
||||||
json_array_append_new (new_ports, json_pack ("[s,s]", "uuid", port_uuid));
|
json_array_append_new (new_ports, json_pack ("[s,s]", "uuid", port_uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
json_decref (interfaces);
|
|
||||||
json_decref (new_interfaces);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_array_size (new_ports) == 0) {
|
if (json_array_size (new_ports) == 0) {
|
||||||
|
|
@ -681,9 +677,6 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname)
|
||||||
}
|
}
|
||||||
json_array_append_new (new_bridges, json_pack ("[s,s]", "uuid", bridge_uuid));
|
json_array_append_new (new_bridges, json_pack ("[s,s]", "uuid", bridge_uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
json_decref (ports);
|
|
||||||
json_decref (new_ports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bridges_changed) {
|
if (bridges_changed) {
|
||||||
|
|
@ -708,7 +701,7 @@ ovsdb_next_command (NMOvsdb *self)
|
||||||
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
||||||
OvsdbMethodCall *call = NULL;
|
OvsdbMethodCall *call = NULL;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
json_t *msg = NULL;
|
nm_auto_decref_json json_t *msg = NULL;
|
||||||
json_t *params;
|
json_t *params;
|
||||||
|
|
||||||
if (!priv->conn)
|
if (!priv->conn)
|
||||||
|
|
@ -764,7 +757,6 @@ ovsdb_next_command (NMOvsdb *self)
|
||||||
cmd = json_dumps (msg, 0);
|
cmd = json_dumps (msg, 0);
|
||||||
|
|
||||||
g_string_append (priv->output, cmd);
|
g_string_append (priv->output, cmd);
|
||||||
json_decref (msg);
|
|
||||||
free (cmd);
|
free (cmd);
|
||||||
|
|
||||||
ovsdb_write (self);
|
ovsdb_write (self);
|
||||||
|
|
@ -1041,7 +1033,7 @@ static void
|
||||||
ovsdb_got_echo (NMOvsdb *self, json_int_t id, json_t *data)
|
ovsdb_got_echo (NMOvsdb *self, json_int_t id, json_t *data)
|
||||||
{
|
{
|
||||||
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
||||||
json_t *msg;
|
nm_auto_decref_json json_t *msg = NULL;
|
||||||
char *reply;
|
char *reply;
|
||||||
gboolean output_was_empty;
|
gboolean output_was_empty;
|
||||||
|
|
||||||
|
|
@ -1050,7 +1042,6 @@ ovsdb_got_echo (NMOvsdb *self, json_int_t id, json_t *data)
|
||||||
msg = json_pack ("{s:I, s:O}", "id", id, "result", data);
|
msg = json_pack ("{s:I, s:O}", "id", id, "result", data);
|
||||||
reply = json_dumps (msg, 0);
|
reply = json_dumps (msg, 0);
|
||||||
g_string_append (priv->output, reply);
|
g_string_append (priv->output, reply);
|
||||||
json_decref (msg);
|
|
||||||
free (reply);
|
free (reply);
|
||||||
|
|
||||||
if (output_was_empty)
|
if (output_was_empty)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue