Skip to content

Commit

Permalink
ovs-vsctl: Log better warnings for duplicate ports and interfaces.
Browse files Browse the repository at this point in the history
The database prevents multiple ports or interfaces with a single name, but
duplicates can still occur if, for example, two bridges' "ports" columns
both point to a single Port record.  The existing warning just says in this
case that the database contains a duplicate port name.  This prompts users
to dump the Port table to look for the duplicate.  Of course there isn't
one, so then they ask me to point out the problem.

This commit improves the log message to point out the actual problem.
  • Loading branch information
blp committed Jul 26, 2011
1 parent 211b05b commit 48a6950
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions utilities/ovs-vsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,7 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info)
struct ovsrec_port *port_cfg = br_cfg->ports[j];

if (!sset_add(&ports, port_cfg->name)) {
VLOG_WARN("%s: database contains duplicate port name",
port_cfg->name);
/* Duplicate port name. (We will warn about that later.) */
continue;
}

Expand All @@ -800,7 +799,6 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info)
sset_destroy(&ports);

sset_init(&bridges);
sset_init(&ports);
for (i = 0; i < ovs->n_bridges; i++) {
struct ovsrec_bridge *br_cfg = ovs->bridges[i];
struct vsctl_bridge *br;
Expand All @@ -815,7 +813,18 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info)
struct vsctl_port *port;
size_t k;

if (!sset_add(&ports, port_cfg->name)) {
port = shash_find_data(&info->ports, port_cfg->name);
if (port) {
if (port_cfg == port->port_cfg) {
VLOG_WARN("%s: port is in multiple bridges (%s and %s)",
port_cfg->name, br->name, port->bridge->name);
} else {
/* Log as an error because this violates the database's
* uniqueness constraints, so the database server shouldn't
* have allowed it. */
VLOG_ERR("%s: database contains duplicate port name",
port_cfg->name);
}
continue;
}

Expand All @@ -841,9 +850,21 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info)
struct ovsrec_interface *iface_cfg = port_cfg->interfaces[k];
struct vsctl_iface *iface;

if (shash_find(&info->ifaces, iface_cfg->name)) {
VLOG_WARN("%s: database contains duplicate interface name",
iface_cfg->name);
iface = shash_find_data(&info->ifaces, iface_cfg->name);
if (iface) {
if (iface_cfg == iface->iface_cfg) {
VLOG_WARN("%s: interface is in multiple ports "
"(%s and %s)",
iface_cfg->name,
iface->port->port_cfg->name,
port->port_cfg->name);
} else {
/* Log as an error because this violates the database's
* uniqueness constraints, so the database server
* shouldn't have allowed it. */
VLOG_ERR("%s: database contains duplicate interface "
"name", iface_cfg->name);
}
continue;
}

Expand All @@ -855,7 +876,6 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info)
}
}
sset_destroy(&bridges);
sset_destroy(&ports);
}

static void
Expand Down

0 comments on commit 48a6950

Please sign in to comment.