lacp: Remove LACP_[FAST|SLOW]_TIME_RX macros.
[sliver-openvswitch.git] / lib / lacp.c
1 /* Copyright (c) 2011 Nicira Networks
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <config.h>
17 #include "lacp.h"
18
19 #include <assert.h>
20 #include <stdlib.h>
21
22 #include "dynamic-string.h"
23 #include "hash.h"
24 #include "hmap.h"
25 #include "ofpbuf.h"
26 #include "packets.h"
27 #include "poll-loop.h"
28 #include "timer.h"
29 #include "timeval.h"
30 #include "unixctl.h"
31 #include "vlog.h"
32
33 VLOG_DEFINE_THIS_MODULE(lacp);
34
35 enum slave_status {
36     LACP_CURRENT,   /* Current State.  Partner up to date. */
37     LACP_EXPIRED,   /* Expired State.  Partner out of date. */
38     LACP_DEFAULTED, /* Defaulted State.  No partner. */
39 };
40
41 struct lacp {
42     struct list node;             /* Node in all_lacps list. */
43     char *name;                   /* Name of this lacp object. */
44     uint8_t sys_id[ETH_ADDR_LEN]; /* System ID. */
45     uint16_t sys_priority;        /* System Priority. */
46     bool active;                  /* Active or Passive. */
47
48     struct hmap slaves;      /* Slaves this LACP object controls. */
49     struct slave *key_slave; /* Slave whose ID will be the aggregation key. */
50
51     bool fast;                /* Fast or Slow LACP time. */
52     bool strict;             /* True if in strict mode. */
53     bool negotiated;         /* True if LACP negotiations were successful. */
54     bool update;             /* True if lacp_update() needs to be called. */
55 };
56
57 struct slave {
58     void *aux;                    /* Handle used to identify this slave. */
59     struct hmap_node node;        /* Node in master's slaves map. */
60
61     struct lacp *lacp;            /* LACP object containing this slave. */
62     uint16_t port_id;             /* Port ID. */
63     uint16_t port_priority;       /* Port Priority. */
64     char *name;                   /* Name of this slave. */
65
66     enum slave_status status;     /* Slave status. */
67     bool attached;                /* Attached. Traffic may flow. */
68     struct lacp_info partner;     /* Partner information. */
69     struct lacp_info ntt_actor;   /* Used to decide if we Need To Transmit. */
70     struct timer tx;              /* Next message transmission timer. */
71     struct timer rx;              /* Expected message receive timer. */
72 };
73
74 static struct list all_lacps = LIST_INITIALIZER(&all_lacps);
75
76 static void lacp_update_attached(struct lacp *);
77
78 static void slave_destroy(struct slave *);
79 static void slave_set_defaulted(struct slave *);
80 static void slave_set_expired(struct slave *);
81 static void slave_get_actor(struct slave *, struct lacp_info *actor);
82 static void slave_get_priority(struct slave *, struct lacp_info *priority);
83 static bool slave_may_tx(const struct slave *);
84 static struct slave *slave_lookup(const struct lacp *, const void *slave);
85 static bool info_tx_equal(struct lacp_info *, struct lacp_info *);
86
87 static void lacp_unixctl_show(struct unixctl_conn *, const char *args,
88                               void *aux);
89
90 /* Populates 'pdu' with a LACP PDU comprised of 'actor' and 'partner'. */
91 void
92 compose_lacp_pdu(const struct lacp_info *actor,
93                  const struct lacp_info *partner, struct lacp_pdu *pdu)
94 {
95     memset(pdu, 0, sizeof *pdu);
96
97     pdu->subtype = 1;
98     pdu->version = 1;
99
100     pdu->actor_type = 1;
101     pdu->actor_len = 20;
102     pdu->actor = *actor;
103
104     pdu->partner_type = 2;
105     pdu->partner_len = 20;
106     pdu->partner = *partner;
107
108     pdu->collector_type = 3;
109     pdu->collector_len = 16;
110     pdu->collector_delay = htons(0);
111 }
112
113 /* Parses 'b' which represents a packet containing a LACP PDU.  This function
114  * returns NULL if 'b' is malformed, or does not represent a LACP PDU format
115  * supported by OVS.  Otherwise, it returns a pointer to the lacp_pdu contained
116  * within 'b'. */
117 const struct lacp_pdu *
118 parse_lacp_packet(const struct ofpbuf *b)
119 {
120     const struct lacp_pdu *pdu;
121
122     pdu = ofpbuf_at(b, (uint8_t *)b->l3 - (uint8_t *)b->data, LACP_PDU_LEN);
123
124     if (pdu && pdu->subtype == 1
125         && pdu->actor_type == 1 && pdu->actor_len == 20
126         && pdu->partner_type == 2 && pdu->partner_len == 20) {
127         return pdu;
128     } else {
129         return NULL;
130     }
131 }
132 \f
133 /* LACP Protocol Implementation. */
134
135 /* Initializes the lacp module. */
136 void
137 lacp_init(void)
138 {
139     unixctl_command_register("lacp/show", lacp_unixctl_show, NULL);
140 }
141
142 /* Creates a LACP object. */
143 struct lacp *
144 lacp_create(void)
145 {
146     struct lacp *lacp;
147
148     lacp = xzalloc(sizeof *lacp);
149     hmap_init(&lacp->slaves);
150     list_push_back(&all_lacps, &lacp->node);
151     return lacp;
152 }
153
154 /* Destroys 'lacp' and its slaves. Does nothing if 'lacp' is NULL. */
155 void
156 lacp_destroy(struct lacp *lacp)
157 {
158     if (lacp) {
159         struct slave *slave, *next;
160
161         HMAP_FOR_EACH_SAFE (slave, next, node, &lacp->slaves) {
162             slave_destroy(slave);
163         }
164
165         hmap_destroy(&lacp->slaves);
166         list_remove(&lacp->node);
167         free(lacp->name);
168         free(lacp);
169     }
170 }
171
172 /* Configures 'lacp' with settings from 's'. */
173 void
174 lacp_configure(struct lacp *lacp, const struct lacp_settings *s)
175 {
176     if (!lacp->name || strcmp(s->name, lacp->name)) {
177         free(lacp->name);
178         lacp->name = xstrdup(s->name);
179     }
180
181     if (!eth_addr_equals(lacp->sys_id, s->id)
182         || lacp->sys_priority != s->priority
183         || lacp->strict != s->strict) {
184         memcpy(lacp->sys_id, s->id, ETH_ADDR_LEN);
185         lacp->sys_priority = s->priority;
186         lacp->strict = s->strict;
187         lacp->update = true;
188     }
189
190     lacp->active = s->active;
191     lacp->fast = s->fast;
192 }
193
194 /* Returns true if 'lacp' is configured in active mode, false if 'lacp' is
195  * configured for passive mode. */
196 bool
197 lacp_is_active(const struct lacp *lacp)
198 {
199     return lacp->active;
200 }
201
202 /* Processes 'pdu', a parsed LACP packet received on 'slave_'.  This function
203  * should be called on all packets received on 'slave_' with Ethernet Type
204  * ETH_TYPE_LACP and parsable by parse_lacp_packet(). */
205 void
206 lacp_process_pdu(struct lacp *lacp, const void *slave_,
207                  const struct lacp_pdu *pdu)
208 {
209     struct slave *slave = slave_lookup(lacp, slave_);
210
211     slave->status = LACP_CURRENT;
212     timer_set_duration(&slave->rx, LACP_RX_MULTIPLIER *
213                        (lacp->fast ? LACP_FAST_TIME_TX : LACP_SLOW_TIME_TX));
214
215     slave->ntt_actor = pdu->partner;
216
217     /* Update our information about our partner if it's out of date.  This may
218      * cause priorities to change so re-calculate attached status of all
219      * slaves.  */
220     if (memcmp(&slave->partner, &pdu->actor, sizeof pdu->actor)) {
221         lacp->update = true;
222         slave->partner = pdu->actor;
223     }
224 }
225
226 /* Returns true if 'lacp' has successfully negotiated with its partner.  False
227  * if 'lacp' is NULL. */
228 bool
229 lacp_negotiated(const struct lacp *lacp)
230 {
231     return lacp ? lacp->negotiated : false;
232 }
233
234 /* Registers 'slave_' as subordinate to 'lacp'.  This should be called at least
235  * once per slave in a LACP managed bond.  Should also be called whenever a
236  * slave's settings change. */
237 void
238 lacp_slave_register(struct lacp *lacp, void *slave_,
239                     const struct lacp_slave_settings *s)
240 {
241     struct slave *slave = slave_lookup(lacp, slave_);
242
243     if (!slave) {
244         slave = xzalloc(sizeof *slave);
245         slave->lacp = lacp;
246         slave->aux = slave_;
247         hmap_insert(&lacp->slaves, &slave->node, hash_pointer(slave_, 0));
248         slave_set_defaulted(slave);
249
250         if (!lacp->key_slave) {
251             lacp->key_slave = slave;
252         }
253     }
254
255     if (!slave->name || strcmp(s->name, slave->name)) {
256         free(slave->name);
257         slave->name = xstrdup(s->name);
258     }
259
260     if (slave->port_id != s->id || slave->port_priority != s->priority) {
261         slave->port_id = s->id;
262         slave->port_priority = s->priority;
263
264         lacp->update = true;
265
266         if (lacp->active || lacp->negotiated) {
267             slave_set_expired(slave);
268         }
269     }
270 }
271
272 /* Unregisters 'slave_' with 'lacp'.  */
273 void
274 lacp_slave_unregister(struct lacp *lacp, const void *slave_)
275 {
276     struct slave *slave = slave_lookup(lacp, slave_);
277
278     if (slave) {
279         slave_destroy(slave);
280         lacp->update = true;
281     }
282 }
283
284 /* This function should be called whenever the carrier status of 'slave_' has
285  * changed. */
286 void
287 lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_)
288 {
289     struct slave *slave = slave_lookup(lacp, slave_);
290
291     if (slave->status == LACP_CURRENT || slave->lacp->active) {
292         slave_set_expired(slave);
293     }
294 }
295
296 /* This function should be called before enabling 'slave_' to send or receive
297  * traffic.  If it returns false, 'slave_' should not enabled.  As a
298  * convenience, returns true if 'lacp' is NULL. */
299 bool
300 lacp_slave_may_enable(const struct lacp *lacp, const void *slave_)
301 {
302     if (lacp) {
303         struct slave *slave = slave_lookup(lacp, slave_);
304
305         /* The slave may be enabled if it's attached to an aggregator and its
306          * partner is synchronized.  The only exception is defaulted slaves.
307          * They are not required to have synchronized partners because they
308          * have no partners at all.  They will only be attached if negotiations
309          * failed on all slaves in the bond. */
310         return slave->attached && (slave->partner.state & LACP_STATE_SYNC
311                                    || slave->status == LACP_DEFAULTED);
312     } else {
313         return true;
314     }
315 }
316
317 /* Returns the port ID used for 'slave_' in LACP communications. */
318 uint16_t
319 lacp_slave_get_port_id(const struct lacp *lacp, const void *slave_)
320 {
321     struct slave *slave = slave_lookup(lacp, slave_);
322     return slave->port_id;
323 }
324
325 /* Returns true if partner information on 'slave_' is up to date.  'slave_'
326  * not being current, generally indicates a connectivity problem, or a
327  * misconfigured (or broken) partner. */
328 bool
329 lacp_slave_is_current(const struct lacp *lacp, const void *slave_)
330 {
331     return slave_lookup(lacp, slave_)->status == LACP_CURRENT;
332 }
333
334 /* This function should be called periodically to update 'lacp'. */
335 void
336 lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu)
337 {
338     struct slave *slave;
339
340     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
341         if (timer_expired(&slave->rx)) {
342             if (slave->status == LACP_CURRENT) {
343                 slave_set_expired(slave);
344             } else if (slave->status == LACP_EXPIRED) {
345                 slave_set_defaulted(slave);
346             }
347         }
348     }
349
350     if (lacp->update) {
351         lacp_update_attached(lacp);
352     }
353
354     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
355         struct lacp_pdu pdu;
356         struct lacp_info actor;
357
358         if (!slave_may_tx(slave)) {
359             continue;
360         }
361
362         slave_get_actor(slave, &actor);
363
364         if (timer_expired(&slave->tx)
365             || !info_tx_equal(&actor, &slave->ntt_actor)) {
366
367             slave->ntt_actor = actor;
368             compose_lacp_pdu(&actor, &slave->partner, &pdu);
369             send_pdu(slave->aux, &pdu);
370
371             timer_set_duration(&slave->tx,
372                                (slave->partner.state & LACP_STATE_TIME
373                                 ? LACP_FAST_TIME_TX
374                                 : LACP_SLOW_TIME_TX));
375         }
376     }
377 }
378
379 /* Causes poll_block() to wake up when lacp_run() needs to be called again. */
380 void
381 lacp_wait(struct lacp *lacp)
382 {
383     struct slave *slave;
384
385     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
386         if (slave_may_tx(slave)) {
387             timer_wait(&slave->tx);
388         }
389
390         if (slave->status != LACP_DEFAULTED) {
391             timer_wait(&slave->rx);
392         }
393     }
394 }
395 \f
396 /* Static Helpers. */
397
398 /* Updates the attached status of all slaves controlled by 'lacp' and sets its
399  * negotiated parameter to true if any slaves are attachable. */
400 static void
401 lacp_update_attached(struct lacp *lacp)
402 {
403     struct slave *lead, *slave;
404     struct lacp_info lead_pri;
405     static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10);
406
407     lacp->update = false;
408
409     lead = NULL;
410     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
411         struct lacp_info pri;
412
413         slave->attached = true;
414
415         /* XXX: In the future allow users to configure the expected system ID.
416          * For now just special case loopback. */
417         if (eth_addr_equals(slave->partner.sys_id, slave->lacp->sys_id)) {
418             VLOG_WARN_RL(&rl, "slave %s: Loopback detected. Slave is "
419                          "connected to its own bond", slave->name);
420             slave->attached = false;
421             continue;
422         }
423
424         if (slave->status == LACP_DEFAULTED) {
425             continue;
426         }
427
428         slave_get_priority(slave, &pri);
429
430         if (!lead || memcmp(&pri, &lead_pri, sizeof pri) < 0) {
431             lead = slave;
432             lead_pri = pri;
433         }
434     }
435
436     lacp->negotiated = lead != NULL;
437
438     if (lead) {
439         HMAP_FOR_EACH (slave, node, &lacp->slaves) {
440             if (slave->status == LACP_DEFAULTED
441                 || lead->partner.key != slave->partner.key
442                 || !eth_addr_equals(lead->partner.sys_id,
443                                     slave->partner.sys_id)) {
444                 slave->attached = false;
445             }
446         }
447     } else if (lacp->strict) {
448         HMAP_FOR_EACH (slave, node, &lacp->slaves) {
449             slave->attached = false;
450         }
451     }
452 }
453
454 static void
455 slave_destroy(struct slave *slave)
456 {
457     if (slave) {
458         struct lacp *lacp = slave->lacp;
459
460         lacp->update = true;
461         hmap_remove(&lacp->slaves, &slave->node);
462
463         if (lacp->key_slave == slave) {
464             struct hmap_node *slave_node = hmap_first(&lacp->slaves);
465
466             if (slave_node) {
467                 lacp->key_slave = CONTAINER_OF(slave_node, struct slave, node);
468             } else {
469                 lacp->key_slave = NULL;
470             }
471         }
472
473         free(slave->name);
474         free(slave);
475     }
476 }
477
478 static void
479 slave_set_defaulted(struct slave *slave)
480 {
481     memset(&slave->partner, 0, sizeof slave->partner);
482
483     slave->lacp->update = true;
484     slave->status = LACP_DEFAULTED;
485 }
486
487 static void
488 slave_set_expired(struct slave *slave)
489 {
490     slave->status = LACP_EXPIRED;
491     slave->partner.state |= LACP_STATE_TIME;
492     slave->partner.state &= ~LACP_STATE_SYNC;
493     timer_set_duration(&slave->rx, LACP_RX_MULTIPLIER * LACP_FAST_TIME_TX);
494 }
495
496 static void
497 slave_get_actor(struct slave *slave, struct lacp_info *actor)
498 {
499     uint8_t state = 0;
500
501     if (slave->lacp->active) {
502         state |= LACP_STATE_ACT;
503     }
504
505     if (slave->lacp->fast) {
506         state |= LACP_STATE_TIME;
507     }
508
509     if (slave->attached) {
510         state |= LACP_STATE_SYNC;
511     }
512
513     if (slave->status == LACP_DEFAULTED) {
514         state |= LACP_STATE_DEF;
515     }
516
517     if (slave->status == LACP_EXPIRED) {
518         state |= LACP_STATE_EXP;
519     }
520
521     if (hmap_count(&slave->lacp->slaves) > 1) {
522         state |= LACP_STATE_AGG;
523     }
524
525     if (slave->attached || !slave->lacp->negotiated) {
526         state |= LACP_STATE_COL | LACP_STATE_DIST;
527     }
528
529     actor->state = state;
530     actor->key = htons(slave->lacp->key_slave->port_id);
531     actor->port_priority = htons(slave->port_priority);
532     actor->port_id = htons(slave->port_id);
533     actor->sys_priority = htons(slave->lacp->sys_priority);
534     memcpy(&actor->sys_id, slave->lacp->sys_id, ETH_ADDR_LEN);
535 }
536
537 /* Given 'slave', populates 'priority' with data representing its LACP link
538  * priority.  If two priority objects populated by this function are compared
539  * using memcmp, the higher priority link will be less than the lower priority
540  * link. */
541 static void
542 slave_get_priority(struct slave *slave, struct lacp_info *priority)
543 {
544     uint16_t partner_priority, actor_priority;
545
546     /* Choose the lacp_info of the higher priority system by comparing their
547      * system priorities and mac addresses. */
548     actor_priority = slave->lacp->sys_priority;
549     partner_priority = ntohs(slave->partner.sys_priority);
550     if (actor_priority < partner_priority) {
551         slave_get_actor(slave, priority);
552     } else if (partner_priority < actor_priority) {
553         *priority = slave->partner;
554     } else if (eth_addr_compare_3way(slave->lacp->sys_id,
555                                      slave->partner.sys_id) < 0) {
556         slave_get_actor(slave, priority);
557     } else {
558         *priority = slave->partner;
559     }
560
561     /* Key and state are not used in priority comparisons. */
562     priority->key = 0;
563     priority->state = 0;
564 }
565
566 static bool
567 slave_may_tx(const struct slave *slave)
568 {
569     return slave->lacp->active || slave->status != LACP_DEFAULTED;
570 }
571
572 static struct slave *
573 slave_lookup(const struct lacp *lacp, const void *slave_)
574 {
575     struct slave *slave;
576
577     HMAP_FOR_EACH_IN_BUCKET (slave, node, hash_pointer(slave_, 0),
578                              &lacp->slaves) {
579         if (slave->aux == slave_) {
580             return slave;
581         }
582     }
583
584     return NULL;
585 }
586
587 /* Two lacp_info structures are tx_equal if and only if they do not differ in
588  * ways which would require a lacp_pdu transmission. */
589 static bool
590 info_tx_equal(struct lacp_info *a, struct lacp_info *b)
591 {
592
593     /* LACP specification dictates that we transmit whenever the actor and
594      * remote_actor differ in the following fields: Port, Port Priority,
595      * System, System Priority, Aggregation Key, Activity State, Timeout State,
596      * Sync State, and Aggregation State. The state flags are most likely to
597      * change so are checked first. */
598     return !((a->state ^ b->state) & (LACP_STATE_ACT
599                                       | LACP_STATE_TIME
600                                       | LACP_STATE_SYNC
601                                       | LACP_STATE_AGG))
602         && a->port_id == b->port_id
603         && a->port_priority == b->port_priority
604         && a->key == b->key
605         && a->sys_priority == b->sys_priority
606         && eth_addr_equals(a->sys_id, b->sys_id);
607 }
608 \f
609 static struct lacp *
610 lacp_find(const char *name)
611 {
612     struct lacp *lacp;
613
614     LIST_FOR_EACH (lacp, node, &all_lacps) {
615         if (!strcmp(lacp->name, name)) {
616             return lacp;
617         }
618     }
619
620     return NULL;
621 }
622
623 static void
624 ds_put_lacp_state(struct ds *ds, uint8_t state)
625 {
626     if (state & LACP_STATE_ACT) {
627         ds_put_cstr(ds, "activity ");
628     }
629
630     if (state & LACP_STATE_TIME) {
631         ds_put_cstr(ds, "timeout ");
632     }
633
634     if (state & LACP_STATE_AGG) {
635         ds_put_cstr(ds, "aggregation ");
636     }
637
638     if (state & LACP_STATE_SYNC) {
639         ds_put_cstr(ds, "synchronized ");
640     }
641
642     if (state & LACP_STATE_COL) {
643         ds_put_cstr(ds, "collecting ");
644     }
645
646     if (state & LACP_STATE_DIST) {
647         ds_put_cstr(ds, "distributing ");
648     }
649
650     if (state & LACP_STATE_DEF) {
651         ds_put_cstr(ds, "defaulted ");
652     }
653
654     if (state & LACP_STATE_EXP) {
655         ds_put_cstr(ds, "expired ");
656     }
657 }
658
659 static void
660 lacp_unixctl_show(struct unixctl_conn *conn,
661                   const char *args, void *aux OVS_UNUSED)
662 {
663     struct ds ds = DS_EMPTY_INITIALIZER;
664     struct lacp *lacp;
665     struct slave *slave;
666
667     lacp = lacp_find(args);
668     if (!lacp) {
669         unixctl_command_reply(conn, 501, "no such lacp object");
670         return;
671     }
672
673     ds_put_format(&ds, "lacp: %s\n", lacp->name);
674
675     ds_put_format(&ds, "\tstatus: %s", lacp->active ? "active" : "passive");
676     if (lacp->strict) {
677         ds_put_cstr(&ds, " strict");
678     }
679     if (lacp->negotiated) {
680         ds_put_cstr(&ds, " negotiated");
681     }
682     ds_put_cstr(&ds, "\n");
683
684     ds_put_format(&ds, "\tsys_id: " ETH_ADDR_FMT "\n", ETH_ADDR_ARGS(lacp->sys_id));
685     ds_put_format(&ds, "\tsys_priority: %u\n", lacp->sys_priority);
686     ds_put_cstr(&ds, "\taggregation key: ");
687     if (lacp->key_slave) {
688         ds_put_format(&ds, "%u", lacp->key_slave->port_id);
689     } else {
690         ds_put_cstr(&ds, "none");
691     }
692     ds_put_cstr(&ds, "\n");
693
694     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
695         char *status;
696         struct lacp_info actor;
697
698         slave_get_actor(slave, &actor);
699         switch (slave->status) {
700         case LACP_CURRENT:
701             status = "current";
702             break;
703         case LACP_EXPIRED:
704             status = "expired";
705             break;
706         case LACP_DEFAULTED:
707             status = "defaulted";
708             break;
709         default:
710             NOT_REACHED();
711         }
712
713         ds_put_format(&ds, "\nslave: %s: %s %s\n", slave->name, status,
714                       slave->attached ? "attached" : "detached");
715         ds_put_format(&ds, "\tport_id: %u\n", slave->port_id);
716         ds_put_format(&ds, "\tport_priority: %u\n", slave->port_priority);
717
718         ds_put_format(&ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n",
719                       ETH_ADDR_ARGS(actor.sys_id));
720         ds_put_format(&ds, "\tactor sys_priority: %u\n",
721                       ntohs(actor.sys_priority));
722         ds_put_format(&ds, "\tactor port_id: %u\n",
723                       ntohs(actor.port_id));
724         ds_put_format(&ds, "\tactor port_priority: %u\n",
725                       ntohs(actor.port_priority));
726         ds_put_format(&ds, "\tactor key: %u\n",
727                       ntohs(actor.key));
728         ds_put_cstr(&ds, "\tactor state: ");
729         ds_put_lacp_state(&ds, actor.state);
730         ds_put_cstr(&ds, "\n\n");
731
732         ds_put_format(&ds, "\tpartner sys_id: " ETH_ADDR_FMT "\n",
733                       ETH_ADDR_ARGS(slave->partner.sys_id));
734         ds_put_format(&ds, "\tpartner sys_priority: %u\n",
735                       ntohs(slave->partner.sys_priority));
736         ds_put_format(&ds, "\tpartner port_id: %u\n",
737                       ntohs(slave->partner.port_id));
738         ds_put_format(&ds, "\tpartner port_priority: %u\n",
739                       ntohs(slave->partner.port_priority));
740         ds_put_format(&ds, "\tpartner key: %u\n",
741                       ntohs(slave->partner.key));
742         ds_put_cstr(&ds, "\tpartner state: ");
743         ds_put_lacp_state(&ds, slave->partner.state);
744         ds_put_cstr(&ds, "\n");
745     }
746
747     unixctl_command_reply(conn, 200, ds_cstr(&ds));
748     ds_destroy(&ds);
749 }