Before this patch, logical switch ports were using name as key but
logical router ports using uuid, which confuses user when trouble-
shooting, and names of patch ports unreadable. This patch unifies
it by using "name" field also for logical router ports.

Signed-off-by: Han Zhou <[email protected]>
---
 ovn/northd/ovn-northd.c | 14 ++++----------
 ovn/ovn-nb.ovsschema    |  5 +++--
 tests/ovn.at            |  2 +-
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index b196837..d071dfa 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -594,23 +594,20 @@ join_logical_ports(struct northd_context *ctx,
                     continue;
                 }

-                char name[UUID_LEN + 1];
-                snprintf(name, sizeof name, UUID_FMT,
-                         UUID_ARGS(&nbr->header_.uuid));
-                struct ovn_port *op = ovn_port_find(ports, name);
+                struct ovn_port *op = ovn_port_find(ports, nbr->name);
                 if (op) {
                     if (op->nbs || op->nbr) {
                         static struct vlog_rate_limit rl
                             = VLOG_RATE_LIMIT_INIT(5, 1);
                         VLOG_WARN_RL(&rl, "duplicate logical router port
%s",
-                                     name);
+                                     nbr->name);
                         continue;
                     }
                     op->nbr = nbr;
                     list_remove(&op->list);
                     list_push_back(both, &op->list);
                 } else {
-                    op = ovn_port_create(ports, name, NULL, nbr, NULL);
+                    op = ovn_port_create(ports, nbr->name, NULL, nbr,
NULL);
                     list_push_back(nb_only, &op->list);
                 }

@@ -647,10 +644,7 @@ join_logical_ports(struct northd_context *ctx,
                 sizeof *op->od->router_ports * (op->od->n_router_ports +
1));
             op->od->router_ports[op->od->n_router_ports++] = op;
         } else if (op->nbr && op->nbr->peer) {
-            char peer_name[UUID_LEN + 1];
-            snprintf(peer_name, sizeof peer_name, UUID_FMT,
-                     UUID_ARGS(&op->nbr->peer->header_.uuid));
-            op->peer = ovn_port_find(ports, peer_name);
+            op->peer = ovn_port_find(ports, op->nbr->name);
         }
     }
 }
diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema
index b338c3f..9fb8cd1 100644
--- a/ovn/ovn-nb.ovsschema
+++ b/ovn/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
 {
     "name": "OVN_Northbound",
-    "version": "2.0.0",
-    "cksum": "3515938918 4583",
+    "version": "2.0.1",
+    "cksum": "660370796 4618",
     "tables": {
         "Logical_Switch": {
             "columns": {
@@ -89,6 +89,7 @@
                 "external_ids": {
                     "type": {"key": "string", "value": "string",
                              "min": 0, "max": "unlimited"}}},
+            "indexes": [["name"]],
             "isRoot": false}
     }
 }
diff --git a/tests/ovn.at b/tests/ovn.at
index 3e58ff3..a078e0c 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -877,7 +877,7 @@ for i in 1 2 3; do
         -- lport-add ls$i lrp$i$j-attachment`
     ovn-nbctl \
         set Logical_Port lrp$i$j-attachment type=router \
-                             options:router-port=$lrp_uuid \
+                             options:router-port=lrp$i$j \
                              addresses='"00:00:00:00:ff:'$i$j'"'
     done
 done
-- 
2.1.0
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to