X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Ftransaction.c;h=218fbce3edd34710422192f14e7966d18c3e99c7;hb=fb0d597fb64308c60001e3afc9b31eb295dedb6b;hp=2e4c73a82b867a922233997b506aad3573fdae29;hpb=7360012bdf64effd898242a58634267e203a2795;p=openvswitch diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c index 2e4c73a8..218fbce3 100644 --- a/ovsdb/transaction.c +++ b/ovsdb/transaction.c @@ -441,6 +441,27 @@ determine_changes(struct ovsdb_txn *txn, struct ovsdb_txn_row *txn_row) return NULL; } +static struct ovsdb_error * WARN_UNUSED_RESULT +check_max_rows(struct ovsdb_txn *txn) +{ + struct ovsdb_txn_table *t; + + LIST_FOR_EACH (t, struct ovsdb_txn_table, node, &txn->txn_tables) { + size_t n_rows = hmap_count(&t->table->rows); + unsigned int max_rows = t->table->schema->max_rows; + + if (n_rows > max_rows) { + return ovsdb_error("constraint violation", + "transaction causes \"%s\" table to contain " + "%zu rows, greater than the schema-defined " + "limit of %u row(s)", + t->table->schema->name, n_rows, max_rows); + } + } + + return NULL; +} + struct ovsdb_error * ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable) { @@ -459,6 +480,13 @@ ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable) return NULL; } + /* Check maximum rows table constraints. */ + error = check_max_rows(txn); + if (error) { + ovsdb_txn_abort(txn); + return error; + } + /* Update reference counts and check referential integrity. */ error = update_ref_counts(txn); if (error) {