mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 02:18:00 +02:00
ovs: rename internal code to make independent of "external-ids"
We will add support for "other_config". This is in many aspects similar to "external-ids". So first do a renaming, so that the code can be sensibly reused. This is a separate patch, so that the followup commit has less noise in the diff. This function *only* renames (and reformats). No other changes.
This commit is contained in:
parent
d219527dba
commit
79ca9b6412
3 changed files with 118 additions and 119 deletions
|
|
@ -124,13 +124,12 @@ nm_device_ovs_reapply_connection(NMDevice *self, NMConnection *con_old, NMConnec
|
||||||
device_type = NM_DEVICE_TYPE_OVS_BRIDGE;
|
device_type = NM_DEVICE_TYPE_OVS_BRIDGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_ovsdb_set_external_ids(
|
nm_ovsdb_set_reapply(nm_ovsdb_get(),
|
||||||
nm_ovsdb_get(),
|
device_type,
|
||||||
device_type,
|
nm_device_get_ip_iface(self),
|
||||||
nm_device_get_ip_iface(self),
|
nm_connection_get_uuid(con_new),
|
||||||
nm_connection_get_uuid(con_new),
|
_nm_connection_get_setting(con_old, NM_TYPE_SETTING_OVS_EXTERNAL_IDS),
|
||||||
_nm_connection_get_setting(con_old, NM_TYPE_SETTING_OVS_EXTERNAL_IDS),
|
_nm_connection_get_setting(con_new, NM_TYPE_SETTING_OVS_EXTERNAL_IDS));
|
||||||
_nm_connection_get_setting(con_new, NM_TYPE_SETTING_OVS_EXTERNAL_IDS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ typedef enum {
|
||||||
OVSDB_ADD_INTERFACE,
|
OVSDB_ADD_INTERFACE,
|
||||||
OVSDB_DEL_INTERFACE,
|
OVSDB_DEL_INTERFACE,
|
||||||
OVSDB_SET_INTERFACE_MTU,
|
OVSDB_SET_INTERFACE_MTU,
|
||||||
OVSDB_SET_EXTERNAL_IDS,
|
OVSDB_SET_REAPPLY,
|
||||||
} OvsdbCommand;
|
} OvsdbCommand;
|
||||||
|
|
||||||
#define CALL_ID_UNSPEC G_MAXUINT64
|
#define CALL_ID_UNSPEC G_MAXUINT64
|
||||||
|
|
@ -92,9 +92,9 @@ typedef union {
|
||||||
NMDeviceType device_type;
|
NMDeviceType device_type;
|
||||||
char *ifname;
|
char *ifname;
|
||||||
char *connection_uuid;
|
char *connection_uuid;
|
||||||
GHashTable *exid_old;
|
GHashTable *external_ids_old;
|
||||||
GHashTable *exid_new;
|
GHashTable *external_ids_new;
|
||||||
} set_external_ids;
|
} set_reapply;
|
||||||
} OvsdbMethodPayload;
|
} OvsdbMethodPayload;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -223,20 +223,20 @@ static void cleanup_check_ready(NMOvsdb *self);
|
||||||
}, \
|
}, \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
#define OVSDB_METHOD_PAYLOAD_SET_EXTERNAL_IDS(xdevice_type, \
|
#define OVSDB_METHOD_PAYLOAD_SET_REAPPLY(xdevice_type, \
|
||||||
xifname, \
|
xifname, \
|
||||||
xconnection_uuid, \
|
xconnection_uuid, \
|
||||||
xexid_old, \
|
xexternal_ids_old, \
|
||||||
xexid_new) \
|
xexternal_ids_new) \
|
||||||
(&((const OvsdbMethodPayload){ \
|
(&((const OvsdbMethodPayload){ \
|
||||||
.set_external_ids = \
|
.set_reapply = \
|
||||||
{ \
|
{ \
|
||||||
.device_type = xdevice_type, \
|
.device_type = xdevice_type, \
|
||||||
.ifname = (char *) NM_CONSTCAST(char, (xifname)), \
|
.ifname = (char *) NM_CONSTCAST(char, (xifname)), \
|
||||||
.connection_uuid = (char *) NM_CONSTCAST(char, (xconnection_uuid)), \
|
.connection_uuid = (char *) NM_CONSTCAST(char, (xconnection_uuid)), \
|
||||||
.exid_old = (xexid_old), \
|
.external_ids_old = (xexternal_ids_old), \
|
||||||
.exid_new = (xexid_new), \
|
.external_ids_new = (xexternal_ids_new), \
|
||||||
}, \
|
}, \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
@ -291,11 +291,11 @@ _call_complete(OvsdbMethodCall *call, json_t *response, GError *error)
|
||||||
case OVSDB_SET_INTERFACE_MTU:
|
case OVSDB_SET_INTERFACE_MTU:
|
||||||
nm_clear_g_free(&call->payload.set_interface_mtu.ifname);
|
nm_clear_g_free(&call->payload.set_interface_mtu.ifname);
|
||||||
break;
|
break;
|
||||||
case OVSDB_SET_EXTERNAL_IDS:
|
case OVSDB_SET_REAPPLY:
|
||||||
nm_clear_g_free(&call->payload.set_external_ids.ifname);
|
nm_clear_g_free(&call->payload.set_reapply.ifname);
|
||||||
nm_clear_g_free(&call->payload.set_external_ids.connection_uuid);
|
nm_clear_g_free(&call->payload.set_reapply.connection_uuid);
|
||||||
nm_clear_pointer(&call->payload.set_external_ids.exid_old, g_hash_table_destroy);
|
nm_clear_pointer(&call->payload.set_reapply.external_ids_old, g_hash_table_destroy);
|
||||||
nm_clear_pointer(&call->payload.set_external_ids.exid_new, g_hash_table_destroy);
|
nm_clear_pointer(&call->payload.set_reapply.external_ids_new, g_hash_table_destroy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,19 +447,18 @@ ovsdb_call_method(NMOvsdb *self,
|
||||||
call->payload.set_interface_mtu.ifname,
|
call->payload.set_interface_mtu.ifname,
|
||||||
call->payload.set_interface_mtu.mtu);
|
call->payload.set_interface_mtu.mtu);
|
||||||
break;
|
break;
|
||||||
case OVSDB_SET_EXTERNAL_IDS:
|
case OVSDB_SET_REAPPLY:
|
||||||
call->payload.set_external_ids.device_type = payload->set_external_ids.device_type;
|
call->payload.set_reapply.device_type = payload->set_reapply.device_type;
|
||||||
call->payload.set_external_ids.ifname = g_strdup(payload->set_external_ids.ifname);
|
call->payload.set_reapply.ifname = g_strdup(payload->set_reapply.ifname);
|
||||||
call->payload.set_external_ids.connection_uuid =
|
call->payload.set_reapply.connection_uuid = g_strdup(payload->set_reapply.connection_uuid);
|
||||||
g_strdup(payload->set_external_ids.connection_uuid);
|
call->payload.set_reapply.external_ids_old =
|
||||||
call->payload.set_external_ids.exid_old =
|
nm_g_hash_table_ref(payload->set_reapply.external_ids_old);
|
||||||
nm_g_hash_table_ref(payload->set_external_ids.exid_old);
|
call->payload.set_reapply.external_ids_new =
|
||||||
call->payload.set_external_ids.exid_new =
|
nm_g_hash_table_ref(payload->set_reapply.external_ids_new);
|
||||||
nm_g_hash_table_ref(payload->set_external_ids.exid_new);
|
|
||||||
_LOGT_call(call,
|
_LOGT_call(call,
|
||||||
"new: set-external-ids con-uuid=%s, interface=%s",
|
"new: set-external-ids con-uuid=%s, interface=%s",
|
||||||
call->payload.set_external_ids.connection_uuid,
|
call->payload.set_reapply.connection_uuid,
|
||||||
call->payload.set_external_ids.ifname);
|
call->payload.set_reapply.ifname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -677,14 +676,14 @@ _set_port_interfaces(json_t *params, const char *ifname, json_t *new_interfaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
static json_t *
|
static json_t *
|
||||||
_j_create_external_ids_array_new(NMConnection *connection)
|
_j_create_strdict_new(NMConnection *connection)
|
||||||
{
|
{
|
||||||
json_t *array;
|
json_t *array;
|
||||||
const char *const *external_ids = NULL;
|
const char *const *strv = NULL;
|
||||||
guint n_external_ids = 0;
|
guint n_strv = 0;
|
||||||
guint i;
|
guint i;
|
||||||
const char *uuid;
|
const char *uuid;
|
||||||
NMSettingOvsExternalIDs *s_exid;
|
NMSettingOvsExternalIDs *s_external_ids;
|
||||||
|
|
||||||
nm_assert(NM_IS_CONNECTION(connection));
|
nm_assert(NM_IS_CONNECTION(connection));
|
||||||
|
|
||||||
|
|
@ -694,24 +693,22 @@ _j_create_external_ids_array_new(NMConnection *connection)
|
||||||
nm_assert(uuid);
|
nm_assert(uuid);
|
||||||
json_array_append_new(array, json_pack("[s, s]", NM_OVS_EXTERNAL_ID_NM_CONNECTION_UUID, uuid));
|
json_array_append_new(array, json_pack("[s, s]", NM_OVS_EXTERNAL_ID_NM_CONNECTION_UUID, uuid));
|
||||||
|
|
||||||
s_exid = _nm_connection_get_setting(connection, NM_TYPE_SETTING_OVS_EXTERNAL_IDS);
|
s_external_ids = _nm_connection_get_setting(connection, NM_TYPE_SETTING_OVS_EXTERNAL_IDS);
|
||||||
if (s_exid)
|
if (s_external_ids)
|
||||||
external_ids = nm_setting_ovs_external_ids_get_data_keys(s_exid, &n_external_ids);
|
strv = nm_setting_ovs_external_ids_get_data_keys(s_external_ids, &n_strv);
|
||||||
for (i = 0; i < n_external_ids; i++) {
|
for (i = 0; i < n_strv; i++) {
|
||||||
const char *k = external_ids[i];
|
const char *k = strv[i];
|
||||||
|
|
||||||
json_array_append_new(
|
json_array_append_new(
|
||||||
array,
|
array,
|
||||||
json_pack("[s, s]", k, nm_setting_ovs_external_ids_get_data(s_exid, k)));
|
json_pack("[s, s]", k, nm_setting_ovs_external_ids_get_data(s_external_ids, k)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_pack("[s, o]", "map", array);
|
return json_pack("[s, o]", "map", array);
|
||||||
}
|
}
|
||||||
|
|
||||||
static json_t *
|
static json_t *
|
||||||
_j_create_external_ids_array_update(const char *connection_uuid,
|
_j_create_strv_array_update(const char *connection_uuid, GHashTable *hash_old, GHashTable *hash_new)
|
||||||
GHashTable *exid_old,
|
|
||||||
GHashTable *exid_new)
|
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
json_t *mutations;
|
json_t *mutations;
|
||||||
|
|
@ -724,22 +721,22 @@ _j_create_external_ids_array_update(const char *connection_uuid,
|
||||||
mutations = json_array();
|
mutations = json_array();
|
||||||
|
|
||||||
array = json_array();
|
array = json_array();
|
||||||
if (exid_old) {
|
if (hash_old) {
|
||||||
g_hash_table_iter_init(&iter, exid_old);
|
g_hash_table_iter_init(&iter, hash_old);
|
||||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
||||||
json_array_append_new(array, json_string(key));
|
json_array_append_new(array, json_string(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exid_new) {
|
if (hash_new) {
|
||||||
g_hash_table_iter_init(&iter, exid_new);
|
g_hash_table_iter_init(&iter, hash_new);
|
||||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
while (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) {
|
||||||
if (nm_g_hash_table_contains(exid_old, key))
|
if (nm_g_hash_table_contains(hash_old, key))
|
||||||
continue;
|
continue;
|
||||||
json_array_append_new(array, json_string(key));
|
json_array_append_new(array, json_string(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nm_g_hash_table_contains(exid_old, NM_OVS_EXTERNAL_ID_NM_PREFIX)
|
if (!nm_g_hash_table_contains(hash_old, NM_OVS_EXTERNAL_ID_NM_PREFIX)
|
||||||
&& !nm_g_hash_table_contains(exid_new, NM_OVS_EXTERNAL_ID_NM_PREFIX)) {
|
&& !nm_g_hash_table_contains(hash_new, NM_OVS_EXTERNAL_ID_NM_PREFIX)) {
|
||||||
json_array_append_new(array, json_string(NM_OVS_EXTERNAL_ID_NM_PREFIX));
|
json_array_append_new(array, json_string(NM_OVS_EXTERNAL_ID_NM_PREFIX));
|
||||||
}
|
}
|
||||||
json_array_append_new(mutations,
|
json_array_append_new(mutations,
|
||||||
|
|
@ -751,8 +748,8 @@ _j_create_external_ids_array_update(const char *connection_uuid,
|
||||||
array,
|
array,
|
||||||
json_pack("[s, s]", NM_OVS_EXTERNAL_ID_NM_CONNECTION_UUID, connection_uuid));
|
json_pack("[s, s]", NM_OVS_EXTERNAL_ID_NM_CONNECTION_UUID, connection_uuid));
|
||||||
|
|
||||||
if (exid_new) {
|
if (hash_new) {
|
||||||
g_hash_table_iter_init(&iter, exid_new);
|
g_hash_table_iter_init(&iter, hash_new);
|
||||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) {
|
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) {
|
||||||
if (NM_STR_HAS_PREFIX(key, NM_OVS_EXTERNAL_ID_NM_PREFIX))
|
if (NM_STR_HAS_PREFIX(key, NM_OVS_EXTERNAL_ID_NM_PREFIX))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -842,7 +839,7 @@ _insert_interface(json_t *params,
|
||||||
"options",
|
"options",
|
||||||
options,
|
options,
|
||||||
"external_ids",
|
"external_ids",
|
||||||
_j_create_external_ids_array_new(interface));
|
_j_create_strdict_new(interface));
|
||||||
|
|
||||||
if (cloned_mac)
|
if (cloned_mac)
|
||||||
json_object_set_new(row, "mac", json_string(cloned_mac));
|
json_object_set_new(row, "mac", json_string(cloned_mac));
|
||||||
|
|
@ -927,7 +924,7 @@ _insert_port(json_t *params, NMConnection *port, json_t *new_interfaces)
|
||||||
|
|
||||||
json_object_set_new(row, "name", json_string(nm_connection_get_interface_name(port)));
|
json_object_set_new(row, "name", json_string(nm_connection_get_interface_name(port)));
|
||||||
json_object_set_new(row, "interfaces", json_pack("[s, O]", "set", new_interfaces));
|
json_object_set_new(row, "interfaces", json_pack("[s, O]", "set", new_interfaces));
|
||||||
json_object_set_new(row, "external_ids", _j_create_external_ids_array_new(port));
|
json_object_set_new(row, "external_ids", _j_create_strdict_new(port));
|
||||||
|
|
||||||
/* Create a new one. */
|
/* Create a new one. */
|
||||||
json_array_append_new(params,
|
json_array_append_new(params,
|
||||||
|
|
@ -987,7 +984,7 @@ _insert_bridge(json_t *params,
|
||||||
|
|
||||||
json_object_set_new(row, "name", json_string(nm_connection_get_interface_name(bridge)));
|
json_object_set_new(row, "name", json_string(nm_connection_get_interface_name(bridge)));
|
||||||
json_object_set_new(row, "ports", json_pack("[s, O]", "set", new_ports));
|
json_object_set_new(row, "ports", json_pack("[s, O]", "set", new_ports));
|
||||||
json_object_set_new(row, "external_ids", _j_create_external_ids_array_new(bridge));
|
json_object_set_new(row, "external_ids", _j_create_strdict_new(bridge));
|
||||||
|
|
||||||
if (cloned_mac) {
|
if (cloned_mac) {
|
||||||
json_object_set_new(row,
|
json_object_set_new(row,
|
||||||
|
|
@ -1421,23 +1418,22 @@ ovsdb_next_command(NMOvsdb *self)
|
||||||
"==",
|
"==",
|
||||||
call->payload.set_interface_mtu.ifname));
|
call->payload.set_interface_mtu.ifname));
|
||||||
break;
|
break;
|
||||||
case OVSDB_SET_EXTERNAL_IDS:
|
case OVSDB_SET_REAPPLY:
|
||||||
json_array_append_new(
|
json_array_append_new(
|
||||||
params,
|
params,
|
||||||
json_pack("{s:s, s:s, s:o, s:[[s, s, s]]}",
|
json_pack("{s:s, s:s, s:o, s:[[s, s, s]]}",
|
||||||
"op",
|
"op",
|
||||||
"mutate",
|
"mutate",
|
||||||
"table",
|
"table",
|
||||||
_device_type_to_table(call->payload.set_external_ids.device_type),
|
_device_type_to_table(call->payload.set_reapply.device_type),
|
||||||
"mutations",
|
"mutations",
|
||||||
_j_create_external_ids_array_update(
|
_j_create_strv_array_update(call->payload.set_reapply.connection_uuid,
|
||||||
call->payload.set_external_ids.connection_uuid,
|
call->payload.set_reapply.external_ids_old,
|
||||||
call->payload.set_external_ids.exid_old,
|
call->payload.set_reapply.external_ids_new),
|
||||||
call->payload.set_external_ids.exid_new),
|
|
||||||
"where",
|
"where",
|
||||||
"name",
|
"name",
|
||||||
"==",
|
"==",
|
||||||
call->payload.set_external_ids.ifname));
|
call->payload.set_reapply.ifname));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -1523,7 +1519,7 @@ _uuids_to_array(const json_t *items)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_external_ids_extract(json_t *external_ids, GArray **out_array, const char **out_connection_uuid)
|
_strdict_extract(json_t *strdict, GArray **out_array, const char **out_connection_uuid)
|
||||||
{
|
{
|
||||||
json_t *array;
|
json_t *array;
|
||||||
json_t *value;
|
json_t *value;
|
||||||
|
|
@ -1532,10 +1528,10 @@ _external_ids_extract(json_t *external_ids, GArray **out_array, const char **out
|
||||||
nm_assert(out_array && !*out_array);
|
nm_assert(out_array && !*out_array);
|
||||||
nm_assert(!out_connection_uuid || !*out_connection_uuid);
|
nm_assert(!out_connection_uuid || !*out_connection_uuid);
|
||||||
|
|
||||||
if (!nm_streq0("map", json_string_value(json_array_get(external_ids, 0))))
|
if (!nm_streq0("map", json_string_value(json_array_get(strdict, 0))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
array = json_array_get(external_ids, 1);
|
array = json_array_get(strdict, 1);
|
||||||
|
|
||||||
json_array_foreach (array, index, value) {
|
json_array_foreach (array, index, value) {
|
||||||
const char *key = json_string_value(json_array_get(value, 0));
|
const char *key = json_string_value(json_array_get(value, 0));
|
||||||
|
|
@ -1565,7 +1561,7 @@ _external_ids_extract(json_t *external_ids, GArray **out_array, const char **out
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_external_ids_equal(const GArray *arr1, const GArray *arr2)
|
_strdict_equal(const GArray *arr1, const GArray *arr2)
|
||||||
{
|
{
|
||||||
guint n;
|
guint n;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
@ -1724,7 +1720,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
nm_clear_pointer(&ovs_interface, _free_interface);
|
nm_clear_pointer(&ovs_interface, _free_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
_external_ids_extract(external_ids, &external_ids_arr, &connection_uuid);
|
_strdict_extract(external_ids, &external_ids_arr, &connection_uuid);
|
||||||
|
|
||||||
if (ovs_interface) {
|
if (ovs_interface) {
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
@ -1733,12 +1729,12 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
|
|
||||||
changed |= nm_strdup_reset(&ovs_interface->type, type);
|
changed |= nm_strdup_reset(&ovs_interface->type, type);
|
||||||
changed |= nm_strdup_reset(&ovs_interface->connection_uuid, connection_uuid);
|
changed |= nm_strdup_reset(&ovs_interface->connection_uuid, connection_uuid);
|
||||||
if (!_external_ids_equal(ovs_interface->external_ids, external_ids_arr)) {
|
if (!_strdict_equal(ovs_interface->external_ids, external_ids_arr)) {
|
||||||
NM_SWAP(&ovs_interface->external_ids, &external_ids_arr);
|
NM_SWAP(&ovs_interface->external_ids, &external_ids_arr);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
_LOGT("obj[iface:%s]: changed an '%s' interface: %s%s%s, external-ids=%s",
|
_LOGT("obj[iface:%s]: changed an '%s' interface: %s%s%s, external-ids=%s",
|
||||||
key,
|
key,
|
||||||
|
|
@ -1748,10 +1744,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_interface->connection_uuid,
|
ovs_interface->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_interface->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_interface->external_ids)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
ovs_interface = g_slice_new(OpenvswitchInterface);
|
ovs_interface = g_slice_new(OpenvswitchInterface);
|
||||||
*ovs_interface = (OpenvswitchInterface){
|
*ovs_interface = (OpenvswitchInterface){
|
||||||
|
|
@ -1770,7 +1766,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_interface->connection_uuid,
|
ovs_interface->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_interface->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_interface->external_ids)));
|
||||||
_signal_emit_device_added(self,
|
_signal_emit_device_added(self,
|
||||||
ovs_interface->name,
|
ovs_interface->name,
|
||||||
NM_DEVICE_TYPE_OVS_INTERFACE,
|
NM_DEVICE_TYPE_OVS_INTERFACE,
|
||||||
|
|
@ -1834,7 +1830,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
nm_clear_pointer(&ovs_port, _free_port);
|
nm_clear_pointer(&ovs_port, _free_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
_external_ids_extract(external_ids, &external_ids_arr, &connection_uuid);
|
_strdict_extract(external_ids, &external_ids_arr, &connection_uuid);
|
||||||
interfaces = _uuids_to_array(items);
|
interfaces = _uuids_to_array(items);
|
||||||
|
|
||||||
if (ovs_port) {
|
if (ovs_port) {
|
||||||
|
|
@ -1848,12 +1844,12 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
NM_SWAP(&ovs_port->interfaces, &interfaces);
|
NM_SWAP(&ovs_port->interfaces, &interfaces);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (!_external_ids_equal(ovs_port->external_ids, external_ids_arr)) {
|
if (!_strdict_equal(ovs_port->external_ids, external_ids_arr)) {
|
||||||
NM_SWAP(&ovs_port->external_ids, &external_ids_arr);
|
NM_SWAP(&ovs_port->external_ids, &external_ids_arr);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
_LOGT("obj[port:%s]: changed a port: %s%s%s, external-ids=%s",
|
_LOGT("obj[port:%s]: changed a port: %s%s%s, external-ids=%s",
|
||||||
key,
|
key,
|
||||||
|
|
@ -1862,10 +1858,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_port->connection_uuid,
|
ovs_port->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_port->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_port->external_ids)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
ovs_port = g_slice_new(OpenvswitchPort);
|
ovs_port = g_slice_new(OpenvswitchPort);
|
||||||
*ovs_port = (OpenvswitchPort){
|
*ovs_port = (OpenvswitchPort){
|
||||||
|
|
@ -1883,7 +1879,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_port->connection_uuid,
|
ovs_port->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_port->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_port->external_ids)));
|
||||||
_signal_emit_device_added(self, ovs_port->name, NM_DEVICE_TYPE_OVS_PORT, NULL);
|
_signal_emit_device_added(self, ovs_port->name, NM_DEVICE_TYPE_OVS_PORT, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1939,7 +1935,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
nm_clear_pointer(&ovs_bridge, _free_bridge);
|
nm_clear_pointer(&ovs_bridge, _free_bridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
_external_ids_extract(external_ids, &external_ids_arr, &connection_uuid);
|
_strdict_extract(external_ids, &external_ids_arr, &connection_uuid);
|
||||||
ports = _uuids_to_array(items);
|
ports = _uuids_to_array(items);
|
||||||
|
|
||||||
if (ovs_bridge) {
|
if (ovs_bridge) {
|
||||||
|
|
@ -1953,12 +1949,12 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
NM_SWAP(&ovs_bridge->ports, &ports);
|
NM_SWAP(&ovs_bridge->ports, &ports);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (!_external_ids_equal(ovs_bridge->external_ids, external_ids_arr)) {
|
if (!_strdict_equal(ovs_bridge->external_ids, external_ids_arr)) {
|
||||||
NM_SWAP(&ovs_bridge->external_ids, &external_ids_arr);
|
NM_SWAP(&ovs_bridge->external_ids, &external_ids_arr);
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
_LOGT("obj[bridge:%s]: changed a bridge: %s%s%s, external-ids=%s",
|
_LOGT("obj[bridge:%s]: changed a bridge: %s%s%s, external-ids=%s",
|
||||||
key,
|
key,
|
||||||
|
|
@ -1967,10 +1963,10 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_bridge->connection_uuid,
|
ovs_bridge->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_bridge->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_bridge->external_ids)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gs_free char *strtmp = NULL;
|
gs_free char *strtmp1 = NULL;
|
||||||
|
|
||||||
ovs_bridge = g_slice_new(OpenvswitchBridge);
|
ovs_bridge = g_slice_new(OpenvswitchBridge);
|
||||||
*ovs_bridge = (OpenvswitchBridge){
|
*ovs_bridge = (OpenvswitchBridge){
|
||||||
|
|
@ -1988,7 +1984,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg)
|
||||||
", ",
|
", ",
|
||||||
ovs_bridge->connection_uuid,
|
ovs_bridge->connection_uuid,
|
||||||
""),
|
""),
|
||||||
(strtmp = _external_ids_to_string(ovs_bridge->external_ids)));
|
(strtmp1 = _external_ids_to_string(ovs_bridge->external_ids)));
|
||||||
_signal_emit_device_added(self, ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE, NULL);
|
_signal_emit_device_added(self, ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2726,31 +2722,35 @@ nm_ovsdb_set_interface_mtu(NMOvsdb *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ovsdb_set_external_ids(NMOvsdb *self,
|
nm_ovsdb_set_reapply(NMOvsdb *self,
|
||||||
NMDeviceType device_type,
|
NMDeviceType device_type,
|
||||||
const char *ifname,
|
const char *ifname,
|
||||||
const char *connection_uuid,
|
const char *connection_uuid,
|
||||||
NMSettingOvsExternalIDs *s_exid_old,
|
NMSettingOvsExternalIDs *s_external_ids_old,
|
||||||
NMSettingOvsExternalIDs *s_exid_new)
|
NMSettingOvsExternalIDs *s_external_ids_new)
|
||||||
{
|
{
|
||||||
gs_unref_hashtable GHashTable *exid_old = NULL;
|
gs_unref_hashtable GHashTable *external_ids_old = NULL;
|
||||||
gs_unref_hashtable GHashTable *exid_new = NULL;
|
gs_unref_hashtable GHashTable *external_ids_new = NULL;
|
||||||
|
|
||||||
exid_old =
|
external_ids_old =
|
||||||
s_exid_old ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_old)) : NULL;
|
s_external_ids_old
|
||||||
exid_new =
|
? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_external_ids_old))
|
||||||
s_exid_new ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_new)) : NULL;
|
: NULL;
|
||||||
|
external_ids_new =
|
||||||
|
s_external_ids_new
|
||||||
|
? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_external_ids_new))
|
||||||
|
: NULL;
|
||||||
|
|
||||||
ovsdb_call_method(self,
|
ovsdb_call_method(self,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
OVSDB_SET_EXTERNAL_IDS,
|
OVSDB_SET_REAPPLY,
|
||||||
OVSDB_METHOD_PAYLOAD_SET_EXTERNAL_IDS(device_type,
|
OVSDB_METHOD_PAYLOAD_SET_REAPPLY(device_type,
|
||||||
ifname,
|
ifname,
|
||||||
connection_uuid,
|
connection_uuid,
|
||||||
exid_old,
|
external_ids_old,
|
||||||
exid_new));
|
external_ids_new));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ void nm_ovsdb_set_interface_mtu(NMOvsdb *self,
|
||||||
|
|
||||||
struct _NMSettingOvsExternalIDs;
|
struct _NMSettingOvsExternalIDs;
|
||||||
|
|
||||||
void nm_ovsdb_set_external_ids(NMOvsdb *self,
|
void nm_ovsdb_set_reapply(NMOvsdb *self,
|
||||||
NMDeviceType device_type,
|
NMDeviceType device_type,
|
||||||
const char *ifname,
|
const char *ifname,
|
||||||
const char *connection_uuid,
|
const char *connection_uuid,
|
||||||
struct _NMSettingOvsExternalIDs *s_exid_old,
|
struct _NMSettingOvsExternalIDs *s_external_ids_old,
|
||||||
struct _NMSettingOvsExternalIDs *s_exid_new);
|
struct _NMSettingOvsExternalIDs *s_external_ids_new);
|
||||||
|
|
||||||
gboolean nm_ovsdb_is_ready(NMOvsdb *self);
|
gboolean nm_ovsdb_is_ready(NMOvsdb *self);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue