]> git.proxmox.com Git - ovs.git/commitdiff
ovsdb: Require database, table, column names to be valid identifiers.
authorBen Pfaff <blp@nicira.com>
Fri, 20 Nov 2009 00:48:12 +0000 (16:48 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 20 Nov 2009 00:48:12 +0000 (16:48 -0800)
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.

lib/ovsdb-parser.c
lib/ovsdb-parser.h
ovsdb/ovsdb.c
ovsdb/table.c
vswitchd/vswitch.ovsschema

index 5419467c71068a719b262fee70789a415d0c03fb..2a4c3d99e89abd06a8c10f7cfe382712b2d96e39 100644 (file)
@@ -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;
index 6a3e32df6e47285796bb1e7a6c0c47182656b967..6efa0a73c8bb5f5bd937502b280e8b0254b0206e 100644 (file)
@@ -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 */
index 4d5f1c5e5270b7267e8290ad4bde05cf99fdac71..27254e633e2e38867212e2d26f45b25cbf13a342 100644 (file)
@@ -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);
index d017a6ba0ec1c16c05fab8d9d1d14561fb6d1ef7..b520580c09439b68dd8f80bbf5617da576423442 100644 (file)
@@ -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);
         }
index f4c63fb34214a9a4c587e4cc715b26d56713d776..3f32d7ae0413ed2cf42cb5c8e9551aaab7a44a0e 100644 (file)
             "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"}}}}}