Skip to content

Commit

Permalink
ovn: use name instead of uuid as key of logical router ports
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
hzhou8 authored and blp committed Nov 30, 2015
1 parent f86f54a commit 0000744
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
14 changes: 4 additions & 10 deletions ovn/northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions ovn/ovn-nb.ovsschema
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -89,6 +89,7 @@
"external_ids": {
"type": {"key": "string", "value": "string",
"min": 0, "max": "unlimited"}}},
"indexes": [["name"]],
"isRoot": false}
}
}
27 changes: 17 additions & 10 deletions ovn/ovn-nb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@
subnets).
</p>

<column name="options" key="router-port" type='{"type": "uuid"}'>
Required. The UUID of the <ref table="Logical_Router_Port"/> to
which this logical switch port is connected.
<column name="options" key="router-port">
Required. The <ref column="name"/> of the <ref
table="Logical_Router_Port"/> to which this logical switch port is
connected.
</column>
</group>

Expand Down Expand Up @@ -468,10 +469,14 @@

<column name="name">
<p>
A name for the logical router port. This name has no special meaning or purpose
other than to provide convenience for human interaction with the ovn-nb
database. There is no requirement for the name to be unique. The
logical router port's UUID should be used as the unique identifier.
A name for the logical router port.
</p>

<p>
In addition to provide convenience for human interaction with the
ovn-nb database, this column is used as reference by its patch port in
<ref table="Logical_Port"/> or another logical router port in <ref
table="Logical_Router_Port"/>.
</p>
</column>

Expand Down Expand Up @@ -502,8 +507,10 @@
<li>
To attach a logical switch to a logical router. A logical router
port of this type is referenced by exactly one <ref
table="Logical_Port"/> of type <code>router</code>. The <ref
column="peer"/> column is empty.
table="Logical_Port"/> of type <code>router</code>. The value of
<ref column="name"/> is set as <code>router-port</code> in column
<ref column="options"/> of <ref table="Logical_Port"/>.
In this case <ref column="peer"/> column is empty.
</li>

<li>
Expand All @@ -518,7 +525,7 @@
<column name="peer">
<p>
For a router port used to connect two logical routers, this
identifies the other router port in the pair.
identifies the other router port in the pair by <ref column="name"/>.
</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,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
Expand Down

0 comments on commit 0000744

Please sign in to comment.