mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
ovsdb: Assert and check return values of ovsdb_table_schema_get_column
.
This commit adds a few null pointer assertions and checks to some return values of `ovsdb_table_schema_get_column`. If a null pointer is encountered in these blocks, either the assertion will fail or the control flow will now be redirected to alternative paths which will output the appropriate error messages. A few ovsdb-rbac and ovsdb-server tests are also updated to verify the expected warning logs by adding said logs to the ALLOWLIST of the OVSDB_SERVER_SHUTDOWN statements. Reviewed-by: Simon Horman <simon.horman@corigine.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
parent
00782baac0
commit
e71f1a2da1
@ -47,7 +47,10 @@ ovsdb_clause_from_json(const struct ovsdb_table_schema *ts,
|
||||
|
||||
/* Column and arg fields are not being used with boolean functions.
|
||||
* Use dummy values */
|
||||
clause->column = ovsdb_table_schema_get_column(ts, "_uuid");
|
||||
const struct ovsdb_column *uuid_column =
|
||||
ovsdb_table_schema_get_column(ts, "_uuid");
|
||||
ovs_assert(uuid_column);
|
||||
clause->column = uuid_column;
|
||||
clause->index = clause->column->index;
|
||||
ovsdb_datum_init_default(&clause->arg, &clause->column->type);
|
||||
return NULL;
|
||||
|
@ -1232,8 +1232,11 @@ parse_monitor_columns(char *arg, const char *server, const char *database,
|
||||
}
|
||||
free(nodes);
|
||||
|
||||
add_column(server, ovsdb_table_schema_get_column(table, "_version"),
|
||||
columns, columns_json);
|
||||
const struct ovsdb_column *version_column =
|
||||
ovsdb_table_schema_get_column(table, "_version");
|
||||
|
||||
ovs_assert(version_column);
|
||||
add_column(server, version_column, columns, columns_json);
|
||||
}
|
||||
|
||||
if (!initial || !insert || !delete || !modify) {
|
||||
|
@ -291,9 +291,15 @@ ovsdb_util_write_string_string_column(struct ovsdb_row *row,
|
||||
size_t i;
|
||||
|
||||
column = ovsdb_table_schema_get_column(row->table->schema, column_name);
|
||||
if (!column) {
|
||||
VLOG_WARN("No %s column present in the %s table",
|
||||
column_name, row->table->schema->name);
|
||||
goto unwind;
|
||||
}
|
||||
datum = ovsdb_util_get_datum(row, column_name, OVSDB_TYPE_STRING,
|
||||
OVSDB_TYPE_STRING, UINT_MAX);
|
||||
if (!datum) {
|
||||
unwind:
|
||||
for (i = 0; i < n; i++) {
|
||||
free(keys[i]);
|
||||
free(values[i]);
|
||||
|
@ -371,5 +371,7 @@ cat stdout >> output
|
||||
AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]]
|
||||
], [ignore])
|
||||
|
||||
OVSDB_SERVER_SHUTDOWN
|
||||
OVSDB_SERVER_SHUTDOWN(["
|
||||
/No status column present in the Connection table/d
|
||||
"])
|
||||
AT_CLEANUP
|
||||
|
@ -428,7 +428,9 @@ AT_CHECK(
|
||||
[[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
|
||||
]],
|
||||
[ignore])
|
||||
OVSDB_SERVER_SHUTDOWN
|
||||
OVSDB_SERVER_SHUTDOWN(["
|
||||
/No status column present in the Manager table/d
|
||||
"])
|
||||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([ovsdb-server/add-remote and remove-remote])
|
||||
@ -2110,7 +2112,9 @@ AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT \
|
||||
cat stdout >> output
|
||||
AT_CHECK([uuidfilt output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]]
|
||||
], [ignore])
|
||||
OVSDB_SERVER_SHUTDOWN
|
||||
OVSDB_SERVER_SHUTDOWN(["
|
||||
/No status column present in the Manager table/d
|
||||
"])
|
||||
AT_CLEANUP
|
||||
|
||||
AT_SETUP([ovsdb-server replication with schema mismatch])
|
||||
|
Loading…
x
Reference in New Issue
Block a user