Konstantin Khorenko khorenko@openvz.org
Kris zhang zhang.kris@gmail.com
Krishna Miriyala krishna@nicira.com
+Krishna Mohan Elluru elluru.kri.mohan@hpe.com
Len Gao leng@vmware.com
Logan Rosen logatronico@gmail.com
Luca Falavigna dktrkranz@debian.org
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
ovsdb_column_from_json(const struct json *json, const char *name,
struct ovsdb_column **columnp)
{
- const struct json *mutable, *ephemeral, *type_json;
+ const struct json *mutable_json, *ephemeral, *type_json;
struct ovsdb_error *error;
struct ovsdb_type type;
struct ovsdb_parser parser;
- bool persistent;
*columnp = NULL;
ovsdb_parser_init(&parser, json, "schema for column %s", name);
- mutable = ovsdb_parser_member(&parser, "mutable",
- OP_TRUE | OP_FALSE | OP_OPTIONAL);
+ mutable_json = ovsdb_parser_member(&parser, "mutable",
+ OP_TRUE | OP_FALSE | OP_OPTIONAL);
ephemeral = ovsdb_parser_member(&parser, "ephemeral",
OP_TRUE | OP_FALSE | OP_OPTIONAL);
type_json = ovsdb_parser_member(&parser, "type", OP_STRING | OP_OBJECT);
return error;
}
- persistent = ephemeral ? !json_boolean(ephemeral) : true;
- *columnp = ovsdb_column_create(name,
- mutable ? json_boolean(mutable) : true,
- persistent, &type);
+ bool mutable = !mutable_json || json_boolean(mutable_json);
+ if (!mutable
+ && (ovsdb_base_type_is_weak_ref(&type.key) ||
+ ovsdb_base_type_is_weak_ref(&type.value))) {
+ /* We cannot allow a weak reference to be immutable: if referenced rows
+ * are deleted, then the weak reference needs to change. */
+ mutable = true;
+ }
+
+ bool persistent = ephemeral ? !json_boolean(ephemeral) : true;
+ *columnp = ovsdb_column_create(name, mutable, persistent, &type);
ovsdb_type_destroy(&type);
RFC 7047 requires the "version" field in <database-schema>. Current
versions of \fBovsdb\-server\fR allow it to be omitted (future
versions are likely to require it).
+.IP
+RFC 7047 allows columns that contain weak references to be immutable.
+This raises the issue of the behavior of the weak reference when the
+rows that it references are deleted. Since version 2.6,
+\fBovsdb\-server\fR forces columns that contain weak references to be
+mutable.
.
.IP "4. Wire Protocol"
The original OVSDB specifications included the following reason,
-# Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+# Copyright (c) 2009, 2010, 2011, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
type_ = ovs.db.types.Type.from_json(parser.get("type", _types))
parser.finish()
+ if not mutable and (type_.key.is_weak_ref()
+ or (type_.value and type_.value.is_weak_ref())):
+ # We cannot allow a weak reference to be immutable: if referenced
+ # rows are deleted, then the weak reference needs to change.
+ mutable = True
+
return ColumnSchema(name, mutable, not ephemeral, type_)
def to_json(self):
"refTable": "a"}}}},
"isRoot": true}}}']],
[[{"name":"mydb","tables":{"a":{"columns":{"x":{"ephemeral":true,"type":{"key":{"refTable":"b","type":"uuid"}}},"y":{"type":{"key":{"refTable":"a","type":"uuid"}}}}},"b":{"columns":{"aRef":{"type":{"key":{"refTable":"a","type":"uuid"}}}},"isRoot":true}},"version":"4.2.1"}]])
-
+
+dnl Immutable weak references are forced to be mutable.
+OVSDB_CHECK_POSITIVE_CPY([schema with immutable weak references],
+ [[parse-schema \
+ '{"name": "mydb",
+ "version": "4.2.1",
+ "tables": {
+ "a": {
+ "columns": {
+ "x": {
+ "type": {
+ "key": {
+ "type": "uuid",
+ "refTable": "a",
+ "refType": "weak"}},
+ "mutable": false}}}}}']],
+ [[{"name":"mydb","tables":{"a":{"columns":{"x":{"type":{"key":{"refTable":"a","refType":"weak","type":"uuid"}}}}}},"version":"4.2.1"}]])
+
dnl Schemas without version numbers are accepted for backward
dnl compatibility, but this is a deprecated feature.
OVSDB_CHECK_POSITIVE_CPY([schema without version number],