X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-vsctl.c;h=573c9481d29f3f335f9c8bf848700904502d5c1e;hb=ce867b4c7358a48c1644c382c18f23db13c13508;hp=c6fc8a47e6e2696dbd91d2ab5a91213057a1eb62;hpb=2096903b45d28594c04b47b592a5b7e62b5e1ccc;p=sliver-openvswitch.git diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index c6fc8a47e..573c9481d 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -262,7 +262,7 @@ parse_options(int argc, char *argv[]) usage(); case 'V': - OVS_PRINT_VERSION(0, 0); + ovs_print_version(0, 0); exit(EXIT_SUCCESS); case 't': @@ -444,7 +444,7 @@ vsctl_fatal(const char *format, ...) message = xvasprintf(format, args); va_end(args); - vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_EMER); + vlog_set_levels(&VLM_vsctl, VLF_CONSOLE, VLL_OFF); VLOG_ERR("%s", message); ovs_error(0, "%s", message); vsctl_exit(EXIT_FAILURE); @@ -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; } @@ -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; @@ -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; } @@ -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; } @@ -855,7 +876,6 @@ get_info(struct vsctl_context *ctx, struct vsctl_info *info) } } sset_destroy(&bridges); - sset_destroy(&ports); } static void @@ -3660,6 +3680,10 @@ do_vsctl(const char *args, struct vsctl_command *commands, size_t n_commands, case TXN_ERROR: vsctl_fatal("transaction error: %s", error); + case TXN_NOT_LOCKED: + /* Should not happen--we never call ovsdb_idl_set_lock(). */ + vsctl_fatal("database not locked"); + default: NOT_REACHED(); }