Skip to content

Commit 5dab8ec

Browse files
author
Justin Pettit
committed
lacp: Make argument to ovs-appctl "lacp/show" command optional.
If an argument isn't passed to "lacp/show", it will print information about all interfaces with LACP enabled.
1 parent ae75dae commit 5dab8ec

3 files changed

Lines changed: 64 additions & 49 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Post-v1.2.0
88
- New "version" command to determine version of running daemon.
99
- If no argument is provided for "cfm/show", displays detailed
1010
information about all interfaces with CFM enabled.
11+
- If no argument is provided for "lacp/show", displays detailed
12+
information about all ports with LACP enabled.
1113
- ovs-vswitchd:
1214
- The software switch now supports 255 OpenFlow tables, instead
1315
of just one. By default, only table 0 is consulted, but the

lib/lacp.c

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ parse_lacp_packet(const struct ofpbuf *b)
187187
void
188188
lacp_init(void)
189189
{
190-
unixctl_command_register("lacp/show", "port", lacp_unixctl_show, NULL);
190+
unixctl_command_register("lacp/show", "[port]", lacp_unixctl_show, NULL);
191191
}
192192

193193
/* Creates a LACP object. */
@@ -757,53 +757,43 @@ ds_put_lacp_state(struct ds *ds, uint8_t state)
757757
}
758758

759759
static void
760-
lacp_unixctl_show(struct unixctl_conn *conn,
761-
const char *args, void *aux OVS_UNUSED)
760+
lacp_print_details(struct ds *ds, struct lacp *lacp)
762761
{
763-
struct ds ds = DS_EMPTY_INITIALIZER;
764-
struct lacp *lacp;
765762
struct slave *slave;
766763

767-
lacp = lacp_find(args);
768-
if (!lacp) {
769-
unixctl_command_reply(conn, 501, "no such lacp object");
770-
return;
771-
}
772-
773-
ds_put_format(&ds, "lacp: %s\n", lacp->name);
774-
775-
ds_put_format(&ds, "\tstatus: %s", lacp->active ? "active" : "passive");
764+
ds_put_format(ds, "---- %s ----\n", lacp->name);
765+
ds_put_format(ds, "\tstatus: %s", lacp->active ? "active" : "passive");
776766
if (lacp->heartbeat) {
777-
ds_put_cstr(&ds, " heartbeat");
767+
ds_put_cstr(ds, " heartbeat");
778768
}
779769
if (lacp->negotiated) {
780-
ds_put_cstr(&ds, " negotiated");
770+
ds_put_cstr(ds, " negotiated");
781771
}
782-
ds_put_cstr(&ds, "\n");
772+
ds_put_cstr(ds, "\n");
783773

784-
ds_put_format(&ds, "\tsys_id: " ETH_ADDR_FMT "\n", ETH_ADDR_ARGS(lacp->sys_id));
785-
ds_put_format(&ds, "\tsys_priority: %u\n", lacp->sys_priority);
786-
ds_put_cstr(&ds, "\taggregation key: ");
774+
ds_put_format(ds, "\tsys_id: " ETH_ADDR_FMT "\n", ETH_ADDR_ARGS(lacp->sys_id));
775+
ds_put_format(ds, "\tsys_priority: %u\n", lacp->sys_priority);
776+
ds_put_cstr(ds, "\taggregation key: ");
787777
if (lacp->key_slave) {
788-
ds_put_format(&ds, "%u", lacp->key_slave->port_id);
778+
ds_put_format(ds, "%u", lacp->key_slave->port_id);
789779
} else {
790-
ds_put_cstr(&ds, "none");
780+
ds_put_cstr(ds, "none");
791781
}
792-
ds_put_cstr(&ds, "\n");
782+
ds_put_cstr(ds, "\n");
793783

794-
ds_put_cstr(&ds, "\tlacp_time: ");
784+
ds_put_cstr(ds, "\tlacp_time: ");
795785
switch (lacp->lacp_time) {
796786
case LACP_TIME_FAST:
797-
ds_put_cstr(&ds, "fast\n");
787+
ds_put_cstr(ds, "fast\n");
798788
break;
799789
case LACP_TIME_SLOW:
800-
ds_put_cstr(&ds, "slow\n");
790+
ds_put_cstr(ds, "slow\n");
801791
break;
802792
case LACP_TIME_CUSTOM:
803-
ds_put_format(&ds, "custom (%lld)\n", lacp->custom_time);
793+
ds_put_format(ds, "custom (%lld)\n", lacp->custom_time);
804794
break;
805795
default:
806-
ds_put_cstr(&ds, "unknown\n");
796+
ds_put_cstr(ds, "unknown\n");
807797
}
808798

809799
HMAP_FOR_EACH (slave, node, &lacp->slaves) {
@@ -825,38 +815,59 @@ lacp_unixctl_show(struct unixctl_conn *conn,
825815
NOT_REACHED();
826816
}
827817

828-
ds_put_format(&ds, "\nslave: %s: %s %s\n", slave->name, status,
818+
ds_put_format(ds, "\nslave: %s: %s %s\n", slave->name, status,
829819
slave->attached ? "attached" : "detached");
830-
ds_put_format(&ds, "\tport_id: %u\n", slave->port_id);
831-
ds_put_format(&ds, "\tport_priority: %u\n", slave->port_priority);
820+
ds_put_format(ds, "\tport_id: %u\n", slave->port_id);
821+
ds_put_format(ds, "\tport_priority: %u\n", slave->port_priority);
832822

833-
ds_put_format(&ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n",
823+
ds_put_format(ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n",
834824
ETH_ADDR_ARGS(actor.sys_id));
835-
ds_put_format(&ds, "\tactor sys_priority: %u\n",
825+
ds_put_format(ds, "\tactor sys_priority: %u\n",
836826
ntohs(actor.sys_priority));
837-
ds_put_format(&ds, "\tactor port_id: %u\n",
827+
ds_put_format(ds, "\tactor port_id: %u\n",
838828
ntohs(actor.port_id));
839-
ds_put_format(&ds, "\tactor port_priority: %u\n",
829+
ds_put_format(ds, "\tactor port_priority: %u\n",
840830
ntohs(actor.port_priority));
841-
ds_put_format(&ds, "\tactor key: %u\n",
831+
ds_put_format(ds, "\tactor key: %u\n",
842832
ntohs(actor.key));
843-
ds_put_cstr(&ds, "\tactor state: ");
844-
ds_put_lacp_state(&ds, actor.state);
845-
ds_put_cstr(&ds, "\n\n");
833+
ds_put_cstr(ds, "\tactor state: ");
834+
ds_put_lacp_state(ds, actor.state);
835+
ds_put_cstr(ds, "\n\n");
846836

847-
ds_put_format(&ds, "\tpartner sys_id: " ETH_ADDR_FMT "\n",
837+
ds_put_format(ds, "\tpartner sys_id: " ETH_ADDR_FMT "\n",
848838
ETH_ADDR_ARGS(slave->partner.sys_id));
849-
ds_put_format(&ds, "\tpartner sys_priority: %u\n",
839+
ds_put_format(ds, "\tpartner sys_priority: %u\n",
850840
ntohs(slave->partner.sys_priority));
851-
ds_put_format(&ds, "\tpartner port_id: %u\n",
841+
ds_put_format(ds, "\tpartner port_id: %u\n",
852842
ntohs(slave->partner.port_id));
853-
ds_put_format(&ds, "\tpartner port_priority: %u\n",
843+
ds_put_format(ds, "\tpartner port_priority: %u\n",
854844
ntohs(slave->partner.port_priority));
855-
ds_put_format(&ds, "\tpartner key: %u\n",
845+
ds_put_format(ds, "\tpartner key: %u\n",
856846
ntohs(slave->partner.key));
857-
ds_put_cstr(&ds, "\tpartner state: ");
858-
ds_put_lacp_state(&ds, slave->partner.state);
859-
ds_put_cstr(&ds, "\n");
847+
ds_put_cstr(ds, "\tpartner state: ");
848+
ds_put_lacp_state(ds, slave->partner.state);
849+
ds_put_cstr(ds, "\n");
850+
}
851+
}
852+
853+
static void
854+
lacp_unixctl_show(struct unixctl_conn *conn,
855+
const char *args, void *aux OVS_UNUSED)
856+
{
857+
struct ds ds = DS_EMPTY_INITIALIZER;
858+
struct lacp *lacp;
859+
860+
if (strlen(args)) {
861+
lacp = lacp_find(args);
862+
if (!lacp) {
863+
unixctl_command_reply(conn, 501, "no such lacp object");
864+
return;
865+
}
866+
lacp_print_details(&ds, lacp);
867+
} else {
868+
LIST_FOR_EACH (lacp, node, &all_lacps) {
869+
lacp_print_details(&ds, lacp);
870+
}
860871
}
861872

862873
unixctl_command_reply(conn, 200, ds_cstr(&ds));

vswitchd/ovs-vswitchd.8.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,14 @@ status of \fIslave\fR changes.
183183
Returns the hash value which would be used for \fImac\fR with \fIvlan\fR
184184
and \fIbasis\fR if specified.
185185
.
186-
.IP "\fBlacp/show\fR \fIport\fR"
186+
.IP "\fBlacp/show\fR [\fIport\fR]"
187187
Lists all of the LACP related information about the given \fIport\fR:
188188
active or passive, aggregation key, system id, and system priority. Also
189189
lists information about each slave: whether it is enabled or disabled,
190190
whether it is attached or detached, port id and priority, actor
191-
information, and partner information.
191+
information, and partner information. If \fIport\fR is not specified,
192+
then displays detailed information about all interfaces with CFM
193+
enabled.
192194
.
193195
.so ofproto/ofproto-unixctl.man
194196
.so lib/vlog-unixctl.man

0 commit comments

Comments
 (0)