diff options
author | Thomas Haller <thaller@redhat.com> | 2020-11-05 21:16:58 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-11-09 17:53:17 +0100 |
commit | e403f7654461b116c2318746b135e21a6b40d1a3 (patch) | |
tree | b3dce9bb7340f8b3913e383ef93ae4c77a0fadf1 | |
parent | 51495e4e9ad4a1d463388e44e07fa79595b2d95d (diff) | |
download | NetworkManager-e403f7654461b116c2318746b135e21a6b40d1a3.tar.gz |
core/ovs: track key for OpenvswitchInterface in same struct
-rw-r--r-- | src/devices/ovs/nm-ovsdb.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index d25e40b0ba..181633fae8 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -36,6 +36,7 @@ typedef struct { } OpenvswitchBridge; typedef struct { + char *interface_uuid; char *name; char *type; char *connection_uuid; @@ -790,7 +791,7 @@ _add_interface(NMOvsdb * self, for (ii = 0; ii < ovs_port->interfaces->len; ii++) { interface_uuid = g_ptr_array_index(ovs_port->interfaces, ii); - ovs_interface = g_hash_table_lookup(priv->interfaces, interface_uuid); + ovs_interface = g_hash_table_lookup(priv->interfaces, &interface_uuid); json_array_append_new(interfaces, json_pack("[s, s]", "uuid", interface_uuid)); @@ -906,7 +907,7 @@ _delete_interface(NMOvsdb *self, json_t *params, const char *ifname) for (ii = 0; ii < ovs_port->interfaces->len; ii++) { interface_uuid = g_ptr_array_index(ovs_port->interfaces, ii); - ovs_interface = g_hash_table_lookup(priv->interfaces, interface_uuid); + ovs_interface = g_hash_table_lookup(priv->interfaces, &interface_uuid); json_array_append_new(interfaces, json_pack("[s,s]", "uuid", interface_uuid)); @@ -1227,7 +1228,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) new = TRUE; if (old) { - ovs_interface = g_hash_table_lookup(priv->interfaces, key); + ovs_interface = g_hash_table_lookup(priv->interfaces, &key); if (!ovs_interface) { _LOGW("Interface '%s' was not seen", key); } else if (!new || !nm_streq(ovs_interface->name, name)) { @@ -1247,17 +1248,18 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) NM_DEVICE_TYPE_OVS_INTERFACE); } } - g_hash_table_remove(priv->interfaces, key); + g_hash_table_remove(priv->interfaces, &key); } if (new) { ovs_interface = g_slice_new(OpenvswitchInterface); *ovs_interface = (OpenvswitchInterface){ + .interface_uuid = g_strdup(key), .name = g_strdup(name), .type = g_strdup(type), .connection_uuid = _connection_uuid_from_external_ids(external_ids), }; - g_hash_table_insert(priv->interfaces, g_strdup(key), ovs_interface); + g_hash_table_add(priv->interfaces, ovs_interface); if (old) { _LOGT("changed an '%s' interface: %s%s%s", type, @@ -2015,6 +2017,7 @@ _free_interface(gpointer data) { OpenvswitchInterface *ovs_interface = data; + g_free(ovs_interface->interface_uuid); g_free(ovs_interface->name); g_free(ovs_interface->connection_uuid); g_free(ovs_interface->type); @@ -2032,7 +2035,7 @@ nm_ovsdb_init(NMOvsdb *self) priv->output = g_string_new(NULL); priv->bridges = g_hash_table_new_full(nm_pstr_hash, nm_pstr_equal, _free_bridge, NULL); priv->ports = g_hash_table_new_full(nm_pstr_hash, nm_pstr_equal, _free_port, NULL); - priv->interfaces = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, _free_interface); + priv->interfaces = g_hash_table_new_full(nm_pstr_hash, nm_pstr_equal, _free_interface, NULL); ovsdb_try_connect(self); } |