mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
db-ctl-base: Allow retrieving rows of type OVSDB_TYPE_UUID.
The ctl_get_row() function attempts to match a user-provided string to a particular database row. This works by comparing the user-provided string to the values of columns provided by the ctl utility (e.g. ovs-vsctl). Before this commit, this comparison could only be made for columns of type OVSDB_TYPE_INTEGER and OVSDB_TYPE_STRING. If a ctl utility provided a column of a different type, then db-ctl-base.c would assert in get_row_by_id(). This commit enhances the ability of ctl_get_row() to also retrieve rows based on columns of type OVSDB_TYPE_UUID. The user-provided string is converted to a UUID and compared against the column's value. If it matches, then the row matches. Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
parent
8a1a0ea7c0
commit
8ee7ecb8a2
@ -260,6 +260,12 @@ record_id_equals(const union ovsdb_atom *name, enum ovsdb_atomic_type type,
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (type == OVSDB_TYPE_UUID) {
|
||||
struct uuid record_uuid;
|
||||
if (!uuid_from_string(&record_uuid, record_id)) {
|
||||
return false;
|
||||
}
|
||||
return uuid_equals(&record_uuid, &name->uuid);
|
||||
} else {
|
||||
ovs_assert(type == OVSDB_TYPE_INTEGER);
|
||||
return name->integer == strtoll(record_id, NULL, 10);
|
||||
@ -293,12 +299,12 @@ get_row_by_id(struct ctl_context *ctx,
|
||||
name_type = value = id->name_column->type.value.type;
|
||||
}
|
||||
|
||||
/* We only support integer and string names (so far). */
|
||||
/* We only support integer, UUID, and string names (so far). */
|
||||
if (name_type == OVSDB_TYPE_INTEGER) {
|
||||
if (!record_id[0] || record_id[strspn(record_id, "0123456789")]) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else if (name_type != OVSDB_TYPE_UUID) {
|
||||
ovs_assert(name_type == OVSDB_TYPE_STRING);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user