summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-11-19 16:48:12 -0800
committerBen Pfaff <blp@nicira.com>2009-11-19 16:48:12 -0800
commitb966380b45d66ae058c31fbcab67ccfcb8751005 (patch)
treee6baf05fff92d7c53e224325bd4a1f515ba44d54
parentb9edf64b05c7de01f39b7d88aa45af3d13b5cc72 (diff)
downloadopenvswitch-b966380b45d66ae058c31fbcab67ccfcb8751005.tar.gz
ovsdb: Require database, table, column names to be valid identifiers.
Database, table, and column names have always been required by the OVSDB specification to be identifiers (e.g. valid C identifiers), but this has never been enforced. This commit adds enforcement and fixes one instance of an invalid column name in the vswitch schema.
-rw-r--r--lib/ovsdb-parser.c6
-rw-r--r--lib/ovsdb-parser.h2
-rw-r--r--ovsdb/ovsdb.c2
-rw-r--r--ovsdb/table.c2
-rw-r--r--vswitchd/vswitch.ovsschema2
5 files changed, 10 insertions, 4 deletions
diff --git a/lib/ovsdb-parser.c b/lib/ovsdb-parser.c
index 5419467c7..2a4c3d99e 100644
--- a/lib/ovsdb-parser.c
+++ b/lib/ovsdb-parser.c
@@ -41,8 +41,8 @@ ovsdb_parser_init(struct ovsdb_parser *parser, const struct json *json,
}
}
-static bool
-is_id(const char *string)
+bool
+ovsdb_parser_is_id(const char *string)
{
unsigned char c;
@@ -83,7 +83,7 @@ ovsdb_parser_member(struct ovsdb_parser *parser, const char *name,
if ((value->type >= 0 && value->type < JSON_N_TYPES
&& types & (1u << value->type))
|| (types & OP_ID && value->type == JSON_STRING
- && is_id(value->u.string)))
+ && ovsdb_parser_is_id(value->u.string)))
{
svec_add(&parser->used, name);
return value;
diff --git a/lib/ovsdb-parser.h b/lib/ovsdb-parser.h
index 6a3e32df6..6efa0a73c 100644
--- a/lib/ovsdb-parser.h
+++ b/lib/ovsdb-parser.h
@@ -71,4 +71,6 @@ struct ovsdb_error *ovsdb_parser_get_error(const struct ovsdb_parser *);
struct ovsdb_error *ovsdb_parser_finish(struct ovsdb_parser *)
WARN_UNUSED_RESULT;
+bool ovsdb_parser_is_id(const char *string);
+
#endif /* ovsdb-parser.h */
diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c
index 4d5f1c5e5..27254e633 100644
--- a/ovsdb/ovsdb.c
+++ b/ovsdb/ovsdb.c
@@ -107,6 +107,8 @@ ovsdb_schema_from_json(struct json *json, struct ovsdb_schema **schemap)
if (node->name[0] == '_') {
error = ovsdb_syntax_error(json, NULL, "names beginning with "
"\"_\" are reserved");
+ } else if (!ovsdb_parser_is_id(node->name)) {
+ error = ovsdb_syntax_error(json, NULL, "name must be a valid id");
} else {
error = ovsdb_table_schema_from_json(node->data, node->name,
&table);
diff --git a/ovsdb/table.c b/ovsdb/table.c
index d017a6ba0..b520580c0 100644
--- a/ovsdb/table.c
+++ b/ovsdb/table.c
@@ -111,6 +111,8 @@ ovsdb_table_schema_from_json(const struct json *json, const char *name,
if (node->name[0] == '_') {
error = ovsdb_syntax_error(json, NULL, "names beginning with "
"\"_\" are reserved");
+ } else if (!ovsdb_parser_is_id(node->name)) {
+ error = ovsdb_syntax_error(json, NULL, "name must be a valid id");
} else {
error = ovsdb_column_from_json(node->data, node->name, &column);
}
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index f4c63fb34..3f32d7ae0 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -160,6 +160,6 @@
"certificate": {
"comment": "Name of a PEM file containing a certificate, signed by the certificate authority (CA) used by the controller and manager, that certifies the switch's private key, identifying a trustworthy switch.",
"type": "string"},
- "ca-cert": {
+ "ca_cert": {
"comment": "Name of a PEM file containing the CA certificate used to verify that the switch is connected to a trustworthy controller.",
"type": "string"}}}}}