From 341c4e59f50a842a2974d06e448a57af372a7edd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 5 Sep 2012 10:35:20 -0700 Subject: ovsdb: Enforce immutability of immutable columns. OVSDB has always had the ability to mark a column as "immutable", so that its value cannot be changed in a given row after that row is initially inserted. However, we discovered recently that ovsdb-server has never enforced this constraint. This commit implements enforcement. Reported-by: Paul Ingram Signed-off-by: Ben Pfaff Acked-by: Kyle Mestery --- ovsdb/mutation.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ovsdb/mutation.c') diff --git a/ovsdb/mutation.c b/ovsdb/mutation.c index 0dcd16fec..5fd983a4b 100644 --- a/ovsdb/mutation.c +++ b/ovsdb/mutation.c @@ -1,4 +1,4 @@ -/* 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. @@ -95,6 +95,12 @@ ovsdb_mutation_from_json(const struct ovsdb_table_schema *ts, "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]); -- cgit v1.2.1