summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Fernandes <flavio@flaviof.com>2018-05-01 19:07:36 -0400
committerBen Pfaff <blp@ovn.org>2018-05-07 14:18:04 -0700
commitac260bd252d4812995120f6d11b27f2409acdf7f (patch)
treeae148564dce9e8bed5b68fec4aa857c9d10b8c32
parent1fe7363c03e096f9e6211698b2fc166c3e4bd531 (diff)
downloadopenvswitch-ac260bd252d4812995120f6d11b27f2409acdf7f.tar.gz
ovs-vsctl: Fix segfault when attempting to del-port from parent bridge.
The error message in the check for improper bridge param is de-referencing parent from the wrong bridge. Also, the message itself had the parent and child bridges reversed, so that got a small tweak as well. Also, add a regression test. Signed-off-by: Flavio Fernandes <flavio@flaviof.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--tests/ovs-vsctl.at17
-rw-r--r--utilities/ovs-vsctl.c4
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index 034681ba4..fe15793f0 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -552,6 +552,23 @@ CHECK_PORTS([xapi1], [eth0.$1])
CHECK_IFACES([xapi1], [eth0.$1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
+
+AT_SETUP([simple fake bridge + del-port from parent (VLAN $1)])
+AT_KEYWORDS([ovs-vsctl fake-bridge del-port])
+OVS_VSCTL_SETUP
+OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
+AT_CHECK([RUN_OVS_VSCTL([del-port xenbr0 eth0.$1])], [1], [],
+ [ovs-vsctl: bridge xenbr0 does not have a port eth0.$1 (although its child bridge xapi1 does)
+])
+CHECK_PORTS([xenbr0], [eth0])
+CHECK_IFACES([xenbr0], [eth0])
+CHECK_PORTS([xapi1], [eth0.$1])
+CHECK_IFACES([xapi1], [eth0.$1])
+AT_CHECK([RUN_OVS_VSCTL([del-port xapi1 eth0.$1])])
+CHECK_PORTS([xenbr0], [eth0])
+CHECK_IFACES([xenbr0], [eth0])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP
]) # OVS_VSCTL_FAKE_BRIDGE_TESTS
OVS_VSCTL_FAKE_BRIDGE_TESTS([9])
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 36290db79..c25e1ff38 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -1661,9 +1661,9 @@ cmd_del_port(struct ctl_context *ctx)
if (port->bridge != bridge) {
if (port->bridge->parent == bridge) {
ctl_fatal("bridge %s does not have a port %s (although "
- "its parent bridge %s does)",
+ "its child bridge %s does)",
ctx->argv[1], ctx->argv[2],
- bridge->parent->name);
+ port->bridge->name);
} else {
ctl_fatal("bridge %s does not have a port %s",
ctx->argv[1], ctx->argv[2]);