[ovs-dev] [PATCH v1] ovn: rename Address_Set to Set to reflect a more broad purpose

Zong Kai LI zealokii at gmail.com
Wed Aug 10 03:55:08 UTC 2016


This patch renames table Address_Set to Set, Address_Set.addresses to
Set.members to reflect a more broad purpose, that we can define other types
of sets than address set.

Per discussion around [1] and [2], this patch only does rename work on table
Address_Set, and consider put future purpose on using table Set, to create
port set which will be used to improve and skinny ACLs, in following pacthes.

Since it only renames table Address_Set, and up to now, only address set get
supported, so this patch doesn't rename variables and methods which used for
address set, such as [3].

[1] http://openvswitch.org/pipermail/dev/2016-August/077121.html
[2] http://openvswitch.org/pipermail/dev/2016-August/077224.html
[3]
https://github.com/openvswitch/ovs/blob/master/ovn/controller/lflow.c#L41-L42
https://github.com/openvswitch/ovs/blob/master/ovn/controller/lflow.c#L62-L205

Signed-off-by: Zong Kai LI <zealokii at gmail.com>
---
 ovn/controller/lflow.c    | 22 +++++++++++-----------
 ovn/northd/ovn-northd.c   | 26 +++++++++++++-------------
 ovn/ovn-nb.ovsschema      | 12 ++++++------
 ovn/ovn-nb.xml            | 13 +++++++------
 ovn/ovn-sb.ovsschema      | 12 ++++++------
 ovn/ovn-sb.xml            |  6 +++---
 ovn/utilities/ovn-nbctl.c |  4 ++--
 ovn/utilities/ovn-sbctl.c |  4 ++--
 tests/ovn.at              |  2 +-
 9 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c
index ece464b..9faada4 100644
--- a/ovn/controller/lflow.c
+++ b/ovn/controller/lflow.c
@@ -82,20 +82,20 @@ addr_cmp(const void *p1, const void *p2)
 /* Return true if the address sets match, false otherwise. */
 static bool
 address_sets_match(const struct address_set *addr_set,
-                   const struct sbrec_address_set *addr_set_rec)
+                   const struct sbrec_set *addr_set_rec)
 {
     char **addrs1;
     char **addrs2;
 
-    if (addr_set->n_addresses != addr_set_rec->n_addresses) {
+    if (addr_set->n_addresses != addr_set_rec->n_members) {
         return false;
     }
     size_t n_addresses = addr_set->n_addresses;
 
     addrs1 = xmemdup(addr_set->addresses,
                      n_addresses * sizeof addr_set->addresses[0]);
-    addrs2 = xmemdup(addr_set_rec->addresses,
-                     n_addresses * sizeof addr_set_rec->addresses[0]);
+    addrs2 = xmemdup(addr_set_rec->members,
+                     n_addresses * sizeof addr_set_rec->members[0]);
 
     qsort(addrs1, n_addresses, sizeof *addrs1, addr_cmp);
     qsort(addrs2, n_addresses, sizeof *addrs2, addr_cmp);
@@ -142,8 +142,8 @@ update_address_sets(struct controller_ctx *ctx)
 
     /* Iterate address sets in the southbound database.  Create and update the
      * corresponding symtab entries as necessary. */
-    const struct sbrec_address_set *addr_set_rec;
-    SBREC_ADDRESS_SET_FOR_EACH (addr_set_rec, ctx->ovnsb_idl) {
+    const struct sbrec_set *addr_set_rec;
+    SBREC_SET_FOR_EACH (addr_set_rec, ctx->ovnsb_idl) {
         struct address_set *addr_set =
             shash_find_data(&local_address_sets, addr_set_rec->name);
 
@@ -169,13 +169,13 @@ update_address_sets(struct controller_ctx *ctx)
              * that resolves to the full set of addresses.  Store it in
              * address_sets to remember that we created this symbol. */
             addr_set = xzalloc(sizeof *addr_set);
-            addr_set->n_addresses = addr_set_rec->n_addresses;
-            if (addr_set_rec->n_addresses) {
-                addr_set->addresses = xmalloc(addr_set_rec->n_addresses
+            addr_set->n_addresses = addr_set_rec->n_members;
+            if (addr_set_rec->n_members) {
+                addr_set->addresses = xmalloc(addr_set_rec->n_members
                                               * sizeof addr_set->addresses[0]);
                 size_t i;
-                for (i = 0; i < addr_set_rec->n_addresses; i++) {
-                    addr_set->addresses[i] = xstrdup(addr_set_rec->addresses[i]);
+                for (i = 0; i < addr_set_rec->n_members; i++) {
+                    addr_set->addresses[i] = xstrdup(addr_set_rec->members[i]);
                 }
             }
             shash_add(&local_address_sets, addr_set_rec->name, addr_set);
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 861f872..acd9726 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -3787,29 +3787,29 @@ sync_address_sets(struct northd_context *ctx)
 {
     struct shash sb_address_sets = SHASH_INITIALIZER(&sb_address_sets);
 
-    const struct sbrec_address_set *sb_address_set;
-    SBREC_ADDRESS_SET_FOR_EACH (sb_address_set, ctx->ovnsb_idl) {
+    const struct sbrec_set *sb_address_set;
+    SBREC_SET_FOR_EACH (sb_address_set, ctx->ovnsb_idl) {
         shash_add(&sb_address_sets, sb_address_set->name, sb_address_set);
     }
 
-    const struct nbrec_address_set *nb_address_set;
-    NBREC_ADDRESS_SET_FOR_EACH (nb_address_set, ctx->ovnnb_idl) {
+    const struct nbrec_set *nb_address_set;
+    NBREC_SET_FOR_EACH (nb_address_set, ctx->ovnnb_idl) {
         sb_address_set = shash_find_and_delete(&sb_address_sets,
                                                nb_address_set->name);
         if (!sb_address_set) {
-            sb_address_set = sbrec_address_set_insert(ctx->ovnsb_txn);
-            sbrec_address_set_set_name(sb_address_set, nb_address_set->name);
+            sb_address_set = sbrec_set_insert(ctx->ovnsb_txn);
+            sbrec_set_set_name(sb_address_set, nb_address_set->name);
         }
 
-        sbrec_address_set_set_addresses(sb_address_set,
+        sbrec_set_set_members(sb_address_set,
                 /* "char **" is not compatible with "const char **" */
-                (const char **) nb_address_set->addresses,
-                nb_address_set->n_addresses);
+                (const char **) nb_address_set->members,
+                nb_address_set->n_members);
     }
 
     struct shash_node *node, *next;
     SHASH_FOR_EACH_SAFE (node, next, &sb_address_sets) {
-        sbrec_address_set_delete(node->data);
+        sbrec_set_delete(node->data);
         shash_delete(&sb_address_sets, node);
     }
     shash_destroy(&sb_address_sets);
@@ -4191,9 +4191,9 @@ main(int argc, char *argv[])
     add_column_noalert(ovnsb_idl_loop.idl, &sbrec_dhcp_options_col_type);
     add_column_noalert(ovnsb_idl_loop.idl, &sbrec_dhcp_options_col_name);
 
-    ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_address_set);
-    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_address_set_col_name);
-    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_address_set_col_addresses);
+    ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_set);
+    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_set_col_name);
+    add_column_noalert(ovnsb_idl_loop.idl, &sbrec_set_col_members);
 
     ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_chassis);
     ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_nb_cfg);
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index 660db76..ca6a3be 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Northbound",
-    "version": "5.3.0",
-    "cksum": "1305504870 9051",
+    "version": "5.4.0",
+    "cksum": "1647938297 9037",
     "tables": {
         "NB_Global": {
             "columns": {
@@ -74,12 +74,12 @@
                              "min": 0, "max": "unlimited"}}},
             "indexes": [["name"]],
             "isRoot": false},
-        "Address_Set": {
+        "Set": {
             "columns": {
                 "name": {"type": "string"},
-                "addresses": {"type": {"key": "string",
-                                       "min": 0,
-                                       "max": "unlimited"}},
+                "members": {"type": {"key": "string",
+                                     "min": 0,
+                                     "max": "unlimited"}},
                 "external_ids": {
                     "type": {"key": "string", "value": "string",
                              "min": 0, "max": "unlimited"}}},
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 4ce295a..ff28d3f 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -599,9 +599,10 @@
     </group>
   </table>
 
-  <table name="Address_Set" title="Address Sets">
+  <table name="Set" title="Sets">
     <p>
-      Each row in this table represents a named set of addresses.
+      Each row in this table represents a named set of values.
+      Currently, only address set are supported.
       An address set may contain Ethernet, IPv4, or IPv6 addresses
       with optional bitwise or CIDR masks.
       Address set may ultimately be used in ACLs to compare against
@@ -612,7 +613,7 @@
     </p>
 
     <pre>
-      ovn-nbctl create Address_Set name=set1 addresses='10.0.0.1 10.0.0.2 10.0.0.3'
+      ovn-nbctl create Set name=set1 members='10.0.0.1 10.0.0.2 10.0.0.3'
     </pre>
 
     <p>
@@ -625,11 +626,11 @@
     </p>
 
     <column name="name">
-      A name for the address set.  This must be unique among all address sets.
+      A name for the set.  This must be unique among all sets.
     </column>
 
-    <column name="addresses">
-      The set of addresses in string form.
+    <column name="members">
+      The set of values in string form.
     </column>
 
     <group title="Common Columns">
diff --git a/ovn/ovn-sb.ovsschema b/ovn/ovn-sb.ovsschema
index b1737f5..8cecae3 100644
--- a/ovn/ovn-sb.ovsschema
+++ b/ovn/ovn-sb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Southbound",
-    "version": "1.7.0",
-    "cksum": "3677179333 6917",
+    "version": "1.8.0",
+    "cksum": "307706976 6903",
     "tables": {
         "SB_Global": {
             "columns": {
@@ -37,12 +37,12 @@
                                      "min": 0,
                                      "max": "unlimited"}},
                 "ip": {"type": "string"}}},
-        "Address_Set": {
+        "Set": {
             "columns": {
                 "name": {"type": "string"},
-                "addresses": {"type": {"key": "string",
-                                       "min": 0,
-                                       "max": "unlimited"}}},
+                "members": {"type": {"key": "string",
+                                     "min": 0,
+                                     "max": "unlimited"}}},
             "indexes": [["name"]],
             "isRoot": true},
         "Logical_Flow": {
diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml
index 13c9526..38659bc 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -283,15 +283,15 @@
     </column>
   </table>
 
-  <table name="Address_Set" title="Address Sets">
+  <table name="Set" title="Sets">
     <p>
-      See the documentation for the <ref table="Address_Set"
+      See the documentation for the <ref table="Set"
       db="OVN_Northbound"/> table in the <ref db="OVN_Northbound"/> database
       for details.
     </p>
 
     <column name="name"/>
-    <column name="addresses"/>
+    <column name="members"/>
   </table>
 
   <table name="Logical_Flow" title="Logical Network Flows">
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 9d5b1df..135c7b2 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -2164,8 +2164,8 @@ static const struct ctl_table_class tables[] = {
        NULL},
       {NULL, NULL, NULL}}},
 
-    {&nbrec_table_address_set,
-     {{&nbrec_table_address_set, &nbrec_address_set_col_name, NULL},
+    {&nbrec_table_set,
+     {{&nbrec_table_set, &nbrec_set_col_name, NULL},
       {NULL, NULL, NULL}}},
 
     {&nbrec_table_dhcp_options,
diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index 50c9f17..95e3e56 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -781,8 +781,8 @@ static const struct ctl_table_class tables[] = {
      {{&sbrec_table_mac_binding, &sbrec_mac_binding_col_logical_port, NULL},
       {NULL, NULL, NULL}}},
 
-    {&sbrec_table_address_set,
-     {{&sbrec_table_address_set, &sbrec_address_set_col_name, NULL},
+    {&sbrec_table_set,
+     {{&sbrec_table_set, &sbrec_set_col_name, NULL},
       {NULL, NULL, NULL}}},
 
     {NULL, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}
diff --git a/tests/ovn.at b/tests/ovn.at
index 72868be..7f88105 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -804,7 +804,7 @@ done
 ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1234' drop
 ovn-nbctl acl-add lsw0 from-lport 1000 'eth.type == 0x1235 && inport == "lp11"' drop
 ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1236 && outport == "lp33"' drop
-ovn-nbctl create Address_Set name=set1 addresses=\"f0:00:00:00:00:11\",\"f0:00:00:00:00:21\",\"f0:00:00:00:00:31\"
+ovn-nbctl create Set name=set1 members=\"f0:00:00:00:00:11\",\"f0:00:00:00:00:21\",\"f0:00:00:00:00:31\"
 ovn-nbctl acl-add lsw0 to-lport 1000 'eth.type == 0x1237 && eth.src == $set1 && outport == "lp33"' drop
 
 # Pre-populate the hypervisors' ARP tables so that we don't lose any
-- 
1.9.1




More information about the dev mailing list