summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/ovs-vsctl.at16
-rw-r--r--utilities/ovs-vsctl.8.in5
-rw-r--r--utilities/ovs-vsctl.c14
3 files changed, 31 insertions, 4 deletions
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index 4d4ce10b8..9552469db 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -439,6 +439,22 @@ CHECK_IFACES([xapi1], [eth0.$1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
+AT_SETUP([list bridges -- real and fake (VLAN $1)])
+AT_KEYWORDS([ovs-vsctl fake-bridge])
+OVS_VSCTL_SETUP
+OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- list-br])], [0],
+ [xapi1\nxenbr0
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0],
+ [xenbr0
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0],
+ [xapi1
+], [], [OVS_VSCTL_CLEANUP])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP
+
AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in
index 1b80d050d..79269db76 100644
--- a/utilities/ovs-vsctl.8.in
+++ b/utilities/ovs-vsctl.8.in
@@ -195,9 +195,10 @@ Without \fB\-\-if\-exists\fR, attempting to delete a bridge that does
not exist is an error. With \fB\-\-if\-exists\fR, attempting to
delete a bridge that does not exist has no effect.
.
-.IP "\fBlist\-br\fR"
+.IP "[\fB\-\-real\fR|\fB\-\-fake\fR] \fBlist\-br\fR"
Lists all existing real and fake bridges on standard output, one per
-line.
+line. With \fB\-\-real\fR or \fB\-\-fake\fR, only bridges of that type
+are returned.
.
.IP "\fBbr\-exists \fIbridge\fR"
Tests whether \fIbridge\fR exists as a real or fake bridge. If so,
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index fda3a89db..69e37e002 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -1582,13 +1582,23 @@ cmd_list_br(struct vsctl_context *ctx)
{
struct shash_node *node;
struct svec bridges;
+ bool real = shash_find(&ctx->options, "--real");
+ bool fake = shash_find(&ctx->options, "--fake");
+
+ /* If neither fake nor real were requested, return both. */
+ if (!real && !fake) {
+ real = fake = true;
+ }
vsctl_context_populate_cache(ctx);
svec_init(&bridges);
SHASH_FOR_EACH (node, &ctx->bridges) {
struct vsctl_bridge *br = node->data;
- svec_add(&bridges, br->name);
+
+ if (br->parent ? fake : real) {
+ svec_add(&bridges, br->name);
+ }
}
output_sorted(&bridges, &ctx->output);
svec_destroy(&bridges);
@@ -3961,7 +3971,7 @@ static const struct vsctl_command_syntax all_commands[] = {
/* Bridge commands. */
{"add-br", 1, 3, pre_get_info, cmd_add_br, NULL, "--may-exist", RW},
{"del-br", 1, 1, pre_get_info, cmd_del_br, NULL, "--if-exists", RW},
- {"list-br", 0, 0, pre_get_info, cmd_list_br, NULL, "", RO},
+ {"list-br", 0, 0, pre_get_info, cmd_list_br, NULL, "--real,--fake", RO},
{"br-exists", 1, 1, pre_get_info, cmd_br_exists, NULL, "", RO},
{"br-to-vlan", 1, 1, pre_get_info, cmd_br_to_vlan, NULL, "", RO},
{"br-to-parent", 1, 1, pre_get_info, cmd_br_to_parent, NULL, "", RO},