2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

lib: avoid set size check when generating diff datum from json

Added ovsdb_transient_datum_from_json() to avoid size check for
the diff datum that is transient in nature.
Suppose a datum contains set, and the max number of elements is 2.
If we are changing from set that contains [A, B], to a set contains
[C, D], the diff datum will contains 4 elements [A, B, C, D].

Thus diff datum should not be constrained by the size limit. However
the datum after diff is applied should not violate the size limit.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Andy Zhou
2015-10-14 16:57:52 -07:00
committed by Andy Zhou
parent 6cef8e87b3
commit aefd97b779
2 changed files with 24 additions and 0 deletions

View File

@@ -1268,6 +1268,25 @@ ovsdb_datum_from_json(struct ovsdb_datum *datum,
return error;
}
/* Parses 'json' as a datum of the type described by 'type' for internal
* use. This function is similar to 'ovsdb_datum_from_json', except the
* member size of set or map is not checked.
*
* The datum generated should be used then discard. It is not suitable
* for storing into IDL because of the possible member size violation. */
struct ovsdb_error *
ovsdb_transient_datum_from_json(struct ovsdb_datum *datum,
const struct ovsdb_type *type,
const struct json *json)
{
struct ovsdb_type relaxed_type = *type;
relaxed_type.n_min = 0;
relaxed_type.n_max = UINT_MAX;
return ovsdb_datum_from_json(datum, &relaxed_type, json, NULL);
}
/* Converts 'datum', of the specified 'type', to JSON format, and returns the
* JSON. The caller is responsible for freeing the returned JSON.
*