are true, but because we do not know of any users for this
feature it seems better on balance to remove it. (The ovs-pki-cgi
program was not included in distribution packaging.)
+ - ovsdb-server now enforces the immutability of immutable columns. This
+ was not enforced in earlier versions due to an oversight.
- Stable bond mode is deprecated and will be removed no earlier than
February 2013. Please email dev@openvswitch.org with concerns.
- The autopath action is deprecated and will be removed no earlier than
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
struct ovsdb_idl_column {
char *name;
struct ovsdb_type type;
+ bool mutable;
void (*parse)(struct ovsdb_idl_row *, const struct ovsdb_datum *);
void (*unparse)(struct ovsdb_idl_row *);
};
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (!error) {
error = parse_row(row_json, table, x->symtab, &row, &columns);
}
+ if (!error) {
+ size_t i;
+
+ for (i = 0; i < columns.n_columns; i++) {
+ const struct ovsdb_column *column = columns.columns[i];
+
+ if (!column->mutable) {
+ error = ovsdb_syntax_error(parser->json,
+ "constraint violation",
+ "Cannot update immutable column %s "
+ "in table %s.",
+ column->name, table->schema->name);
+ break;
+ }
+ }
+ }
if (!error) {
error = ovsdb_condition_from_json(table->schema, where, x->symtab,
&condition);
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
"No column %s in table %s.",
column_name, ts->name);
}
+ if (!m->column->mutable) {
+ return ovsdb_syntax_error(json, "constraint violation",
+ "Cannot mutate immutable column %s in "
+ "table %s.", column_name, ts->name);
+ }
+
ovsdb_type_clone(&m->type, &m->column->type);
mutator_name = json_string(array->elems[1]);
for columnName, column in sorted(table.columns.iteritems()):
cs = "%s_col_%s" % (structName, columnName)
d = {'cs': cs, 'c': columnName, 's': structName}
+ if column.mutable:
+ mutable = "true"
+ else:
+ mutable = "false"
print
print " /* Initialize %(cs)s. */" % d
print " c = &%(cs)s;" % d
print " c->name = \"%(c)s\";" % d
print column.type.cInitType(" ", "c->type")
+ print " c->mutable = %s;" % mutable
print " c->parse = %(s)s_parse_%(c)s;" % d
print " c->unparse = %(s)s_unparse_%(c)s;" % d
print "}"
AT_CHECK([RUN_OVS_VSCTL([destroy b br2])],
[1], [], [ovs-vsctl: no row "br2" in table Bridge
], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([add i br1 name x])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([set port br1 name br2])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Port
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([remove b br1 name br1])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([clear b br1 name])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
+], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
"isRoot": false}}}
EOF
}
+
+immutable_schema () {
+ cat <<'EOF'
+{"name": "immutable",
+ "tables": {
+ "a": {
+ "columns": {"i": {"type": "integer", "mutable": false}}}}}
+EOF
+}
]
m4_divert_pop([PREPARE_TESTS])
[{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]
]])
+OVSDB_CHECK_EXECUTION([immutable columns],
+ [immutable_schema],
+ [[[["immutable",
+ {"op": "insert",
+ "table": "a",
+ "row": {"i": 5},
+ "uuid-name": "row1"}]]],
+ [[["immutable",
+ {"op": "update",
+ "table": "a",
+ "row": {"i": 10},
+ "where": []}]]],
+ [[["immutable",
+ {"op": "update",
+ "table": "a",
+ "row": {"i": 5},
+ "where": []}]]],
+ [[["immutable",
+ {"op": "mutate",
+ "table": "a",
+ "where": [],
+ "mutations": [["i", "-=", 5]]}]]],
+ [[["immutable",
+ {"op": "mutate",
+ "table": "a",
+ "where": [],
+ "mutations": [["i", "*=", 1]]}]]]],
+ [[[{"uuid":["uuid","<0>"]}]
+[{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":10},\"table\":\"a\",\"where\":[]}"}]
+[{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":5},\"table\":\"a\",\"where\":[]}"}]
+[{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"-=\",5]"}]
+[{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"*=\",1]"}]
+]])
+
OVSDB_CHECK_EXECUTION([garbage collection],
[gc_schema],
[dnl Check that inserting a row without any references is a no-op.
]])
AT_CLEANUP
+AT_SETUP([disallowed mutations on immutable columns])
+AT_KEYWORDS([ovsdb negative mutation])
+AT_CHECK([[test-ovsdb parse-mutations \
+ '{"columns":
+ {"i": {"type": "integer", "mutable": false}}}' \
+ '[["i", "+=", 1]]'
+]],
+ [1], [],
+ [[test-ovsdb: syntax "["i","+=",1]": constraint violation: Cannot mutate immutable column i in table mytable.
+]])
+AT_CLEANUP
+
OVSDB_CHECK_POSITIVE([mutations on sets],
[[parse-mutations \
'{"columns":
return error;
}
-static void
+static const struct ovsdb_idl_column *
pre_parse_column_key_value(struct vsctl_context *ctx,
const char *arg,
const struct vsctl_table_class *table)
pre_get_column(ctx, table, column_name, &column);
free(column_name);
+
+ return column;
+}
+
+static void
+check_mutable(const struct vsctl_table_class *table,
+ const struct ovsdb_idl_column *column)
+{
+ if (!column->mutable) {
+ vsctl_fatal("cannot modify read-only column %s in table %s",
+ column->name, table->class->name);
+ }
}
static void
table = pre_get_table(ctx, table_name);
for (i = 3; i < ctx->argc; i++) {
- pre_parse_column_key_value(ctx, ctx->argv[i], table);
+ const struct ovsdb_idl_column *column;
+
+ column = pre_parse_column_key_value(ctx, ctx->argv[i], table);
+ check_mutable(table, column);
}
}
table = pre_get_table(ctx, table_name);
pre_get_column(ctx, table, column_name, &column);
+ check_mutable(table, column);
}
static void
table = pre_get_table(ctx, table_name);
pre_get_column(ctx, table, column_name, &column);
+ check_mutable(table, column);
}
static void
const struct ovsdb_idl_column *column;
pre_get_column(ctx, table, ctx->argv[i], &column);
+ check_mutable(table, column);
}
}