}
static void
-bond_unixctl_show(struct unixctl_conn *conn,
- int argc OVS_UNUSED, const char *argv[],
- void *aux OVS_UNUSED)
+bond_print_details(struct ds *ds, const struct bond *bond)
{
- struct ds ds = DS_EMPTY_INITIALIZER;
const struct bond_slave *slave;
- const struct bond *bond;
- bond = bond_find(argv[1]);
- if (!bond) {
- unixctl_command_reply(conn, 501, "no such bond");
- return;
- }
-
- ds_put_format(&ds, "bond_mode: %s\n",
+ ds_put_format(ds, "---- %s ----\n", bond->name);
+ ds_put_format(ds, "bond_mode: %s\n",
bond_mode_to_string(bond->balance));
if (bond->balance != BM_AB) {
- ds_put_format(&ds, "bond-hash-algorithm: %s\n",
+ ds_put_format(ds, "bond-hash-algorithm: %s\n",
bond_is_tcp_hash(bond) ? "balance-tcp" : "balance-slb");
}
- ds_put_format(&ds, "bond-hash-basis: %"PRIu32"\n", bond->basis);
+ ds_put_format(ds, "bond-hash-basis: %"PRIu32"\n", bond->basis);
- ds_put_format(&ds, "updelay: %d ms\n", bond->updelay);
- ds_put_format(&ds, "downdelay: %d ms\n", bond->downdelay);
+ ds_put_format(ds, "updelay: %d ms\n", bond->updelay);
+ ds_put_format(ds, "downdelay: %d ms\n", bond->downdelay);
if (bond_is_balanced(bond)) {
- ds_put_format(&ds, "next rebalance: %lld ms\n",
+ ds_put_format(ds, "next rebalance: %lld ms\n",
bond->next_rebalance - time_msec());
}
- ds_put_format(&ds, "lacp_negotiated: %s\n",
+ ds_put_format(ds, "lacp_negotiated: %s\n",
bond->lacp_negotiated ? "true" : "false");
HMAP_FOR_EACH (slave, hmap_node, &bond->slaves) {
struct bond_entry *be;
/* Basic info. */
- ds_put_format(&ds, "\nslave %s: %s\n",
+ ds_put_format(ds, "\nslave %s: %s\n",
slave->name, slave->enabled ? "enabled" : "disabled");
if (slave == bond->active_slave) {
- ds_put_cstr(&ds, "\tactive slave\n");
+ ds_put_cstr(ds, "\tactive slave\n");
}
if (slave->delay_expires != LLONG_MAX) {
- ds_put_format(&ds, "\t%s expires in %lld ms\n",
+ ds_put_format(ds, "\t%s expires in %lld ms\n",
slave->enabled ? "downdelay" : "updelay",
slave->delay_expires - time_msec());
}
- ds_put_format(&ds, "\tmay_enable: %s\n",
+ ds_put_format(ds, "\tmay_enable: %s\n",
slave->may_enable ? "true" : "false");
if (!bond_is_balanced(bond)) {
continue;
}
- ds_put_format(&ds, "\thash %d: %"PRIu64" kB load\n",
+ ds_put_format(ds, "\thash %d: %"PRIu64" kB load\n",
hash, be->tx_bytes / 1024);
/* XXX How can we list the MACs assigned to hashes of SLB bonds? */
}
}
+ ds_put_cstr(ds, "\n");
+}
+
+static void
+bond_unixctl_show(struct unixctl_conn *conn,
+ int argc, const char *argv[],
+ void *aux OVS_UNUSED)
+{
+ struct ds ds = DS_EMPTY_INITIALIZER;
+
+ if (argc > 1) {
+ const struct bond *bond = bond_find(argv[1]);
+
+ if (!bond) {
+ unixctl_command_reply(conn, 501, "no such bond");
+ return;
+ }
+ bond_print_details(&ds, bond);
+ } else {
+ const struct bond *bond;
+
+ HMAP_FOR_EACH (bond, hmap_node, &all_bonds) {
+ bond_print_details(&ds, bond);
+ }
+ }
+
unixctl_command_reply(conn, 200, ds_cstr(&ds));
ds_destroy(&ds);
}
bond_init(void)
{
unixctl_command_register("bond/list", "", 0, 0, bond_unixctl_list, NULL);
- unixctl_command_register("bond/show", "port", 1, 1,
- bond_unixctl_show, NULL);
+ unixctl_command_register("bond/show", "[port]", 0, 1, bond_unixctl_show,
+ NULL);
unixctl_command_register("bond/migrate", "port hash slave", 3, 3,
bond_unixctl_migrate, NULL);
unixctl_command_register("bond/set-active-slave", "port slave", 2, 2,
.IP "\fBbond/list\fR"
Lists all of the bonds, and their slaves, on each bridge.
.
-.IP "\fBbond/show\fR \fIport\fR"
-Lists all of the bond-specific information about the given bonded
-\fIport\fR: updelay, downdelay, time until the next rebalance. Also
-lists information about each slave: whether it is enabled or disabled,
-the time to completion of an updelay or downdelay if one is in
-progress, whether it is the active slave, the MAC hashes assigned to
-the slave, and the MAC learning table entries that hash to each MAC.
-Any LACP information related to this bond may be found using the
-\fBlacp/show\fR command.
+.IP "\fBbond/show\fR [\fIport\fR]"
+Lists all of the bond-specific information (updelay, downdelay, time
+until the next rebalance) about the given bonded \fIport\fR, or all
+bonded ports if no \fIport\fR is given. Also lists information about
+each slave: whether it is enabled or disabled, the time to completion
+of an updelay or downdelay if one is in progress, whether it is the
+active slave, the hashes assigned to the slave. Any LACP information
+related to this bond may be found using the \fBlacp/show\fR command.
+.
.IP "\fBbond/migrate\fR \fIport\fR \fIhash\fR \fIslave\fR"
Only valid for SLB bonds. Assigns a given MAC hash to a new slave.
\fIport\fR specifies the bond port, \fIhash\fR the MAC hash to be