lacp: Move LACP packet data to lacp header file.
[cascardo/ovs.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->fast
213                                     ? LACP_FAST_TIME_RX
214                                     : LACP_SLOW_TIME_RX));
215
216     slave->ntt_actor = pdu->partner;
217
218     /* Update our information about our partner if it's out of date.  This may
219      * cause priorities to change so re-calculate attached status of all
220      * slaves.  */
221     if (memcmp(&slave->partner, &pdu->actor, sizeof pdu->actor)) {
222         lacp->update = true;
223         slave->partner = pdu->actor;
224     }
225 }
226
227 /* Returns true if 'lacp' has successfully negotiated with its partner.  False
228  * if 'lacp' is NULL. */
229 bool
230 lacp_negotiated(const struct lacp *lacp)
231 {
232     return lacp ? lacp->negotiated : false;
233 }
234
235 /* Registers 'slave_' as subordinate to 'lacp'.  This should be called at least
236  * once per slave in a LACP managed bond.  Should also be called whenever a
237  * slave's settings change. */
238 void
239 lacp_slave_register(struct lacp *lacp, void *slave_,
240                     const struct lacp_slave_settings *s)
241 {
242     struct slave *slave = slave_lookup(lacp, slave_);
243
244     if (!slave) {
245         slave = xzalloc(sizeof *slave);
246         slave->lacp = lacp;
247         slave->aux = slave_;
248         hmap_insert(&lacp->slaves, &slave->node, hash_pointer(slave_, 0));
249         slave_set_defaulted(slave);
250
251         if (!lacp->key_slave) {
252             lacp->key_slave = slave;
253         }
254     }
255
256     if (!slave->name || strcmp(s->name, slave->name)) {
257         free(slave->name);
258         slave->name = xstrdup(s->name);
259     }
260
261     if (slave->port_id != s->id || slave->port_priority != s->priority) {
262         slave->port_id = s->id;
263         slave->port_priority = s->priority;
264
265         lacp->update = true;
266
267         if (lacp->active || lacp->negotiated) {
268             slave_set_expired(slave);
269         }
270     }
271 }
272
273 /* Unregisters 'slave_' with 'lacp'.  */
274 void
275 lacp_slave_unregister(struct lacp *lacp, const void *slave_)
276 {
277     struct slave *slave = slave_lookup(lacp, slave_);
278
279     if (slave) {
280         slave_destroy(slave);
281         lacp->update = true;
282     }
283 }
284
285 /* This function should be called whenever the carrier status of 'slave_' has
286  * changed. */
287 void
288 lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_)
289 {
290     struct slave *slave = slave_lookup(lacp, slave_);
291
292     if (slave->status == LACP_CURRENT || slave->lacp->active) {
293         slave_set_expired(slave);
294     }
295 }
296
297 /* This function should be called before enabling 'slave_' to send or receive
298  * traffic.  If it returns false, 'slave_' should not enabled.  As a
299  * convenience, returns true if 'lacp' is NULL. */
300 bool
301 lacp_slave_may_enable(const struct lacp *lacp, const void *slave_)
302 {
303     if (lacp) {
304         struct slave *slave = slave_lookup(lacp, slave_);
305
306         /* The slave may be enabled if it's attached to an aggregator and its
307          * partner is synchronized.  The only exception is defaulted slaves.
308          * They are not required to have synchronized partners because they
309          * have no partners at all.  They will only be attached if negotiations
310          * failed on all slaves in the bond. */
311         return slave->attached && (slave->partner.state & LACP_STATE_SYNC
312                                    || slave->status == LACP_DEFAULTED);
313     } else {
314         return true;
315     }
316 }
317
318 /* Returns the port ID used for 'slave_' in LACP communications. */
319 uint16_t
320 lacp_slave_get_port_id(const struct lacp *lacp, const void *slave_)
321 {
322     struct slave *slave = slave_lookup(lacp, slave_);
323     return slave->port_id;
324 }
325
326 /* Returns true if partner information on 'slave_' is up to date.  'slave_'
327  * not being current, generally indicates a connectivity problem, or a
328  * misconfigured (or broken) partner. */
329 bool
330 lacp_slave_is_current(const struct lacp *lacp, const void *slave_)
331 {
332     return slave_lookup(lacp, slave_)->status == LACP_CURRENT;
333 }
334
335 /* This function should be called periodically to update 'lacp'. */
336 void
337 lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu)
338 {
339     struct slave *slave;
340
341     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
342         if (timer_expired(&slave->rx)) {
343             if (slave->status == LACP_CURRENT) {
344                 slave_set_expired(slave);
345             } else if (slave->status == LACP_EXPIRED) {
346                 slave_set_defaulted(slave);
347             }
348         }
349     }
350
351     if (lacp->update) {
352         lacp_update_attached(lacp);
353     }
354
355     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
356         struct lacp_pdu pdu;
357         struct lacp_info actor;
358
359         if (!slave_may_tx(slave)) {
360             continue;
361         }
362
363         slave_get_actor(slave, &actor);
364
365         if (timer_expired(&slave->tx)
366             || !info_tx_equal(&actor, &slave->ntt_actor)) {
367
368             slave->ntt_actor = actor;
369             compose_lacp_pdu(&actor, &slave->partner, &pdu);
370             send_pdu(slave->aux, &pdu);
371
372             timer_set_duration(&slave->tx,
373                                (slave->partner.state & LACP_STATE_TIME
374                                 ? LACP_FAST_TIME_TX
375                                 : LACP_SLOW_TIME_TX));
376         }
377     }
378 }
379
380 /* Causes poll_block() to wake up when lacp_run() needs to be called again. */
381 void
382 lacp_wait(struct lacp *lacp)
383 {
384     struct slave *slave;
385
386     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
387         if (slave_may_tx(slave)) {
388             timer_wait(&slave->tx);
389         }
390
391         if (slave->status != LACP_DEFAULTED) {
392             timer_wait(&slave->rx);
393         }
394     }
395 }
396 \f
397 /* Static Helpers. */
398
399 /* Updates the attached status of all slaves controlled by 'lacp' and sets its
400  * negotiated parameter to true if any slaves are attachable. */
401 static void
402 lacp_update_attached(struct lacp *lacp)
403 {
404     struct slave *lead, *slave;
405     struct lacp_info lead_pri;
406     static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10);
407
408     lacp->update = false;
409
410     lead = NULL;
411     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
412         struct lacp_info pri;
413
414         slave->attached = true;
415
416         /* XXX: In the future allow users to configure the expected system ID.
417          * For now just special case loopback. */
418         if (eth_addr_equals(slave->partner.sys_id, slave->lacp->sys_id)) {
419             VLOG_WARN_RL(&rl, "slave %s: Loopback detected. Slave is "
420                          "connected to its own bond", slave->name);
421             slave->attached = false;
422             continue;
423         }
424
425         if (slave->status == LACP_DEFAULTED) {
426             continue;
427         }
428
429         slave_get_priority(slave, &pri);
430
431         if (!lead || memcmp(&pri, &lead_pri, sizeof pri) < 0) {
432             lead = slave;
433             lead_pri = pri;
434         }
435     }
436
437     lacp->negotiated = lead != NULL;
438
439     if (lead) {
440         HMAP_FOR_EACH (slave, node, &lacp->slaves) {
441             if (slave->status == LACP_DEFAULTED
442                 || lead->partner.key != slave->partner.key
443                 || !eth_addr_equals(lead->partner.sys_id,
444                                     slave->partner.sys_id)) {
445                 slave->attached = false;
446             }
447         }
448     } else if (lacp->strict) {
449         HMAP_FOR_EACH (slave, node, &lacp->slaves) {
450             slave->attached = false;
451         }
452     }
453 }
454
455 static void
456 slave_destroy(struct slave *slave)
457 {
458     if (slave) {
459         struct lacp *lacp = slave->lacp;
460
461         lacp->update = true;
462         hmap_remove(&lacp->slaves, &slave->node);
463
464         if (lacp->key_slave == slave) {
465             struct hmap_node *slave_node = hmap_first(&lacp->slaves);
466
467             if (slave_node) {
468                 lacp->key_slave = CONTAINER_OF(slave_node, struct slave, node);
469             } else {
470                 lacp->key_slave = NULL;
471             }
472         }
473
474         free(slave->name);
475         free(slave);
476     }
477 }
478
479 static void
480 slave_set_defaulted(struct slave *slave)
481 {
482     memset(&slave->partner, 0, sizeof slave->partner);
483
484     slave->lacp->update = true;
485     slave->status = LACP_DEFAULTED;
486 }
487
488 static void
489 slave_set_expired(struct slave *slave)
490 {
491     slave->status = LACP_EXPIRED;
492     slave->partner.state |= LACP_STATE_TIME;
493     slave->partner.state &= ~LACP_STATE_SYNC;
494     timer_set_duration(&slave->rx, LACP_FAST_TIME_RX);
495 }
496
497 static void
498 slave_get_actor(struct slave *slave, struct lacp_info *actor)
499 {
500     uint8_t state = 0;
501
502     if (slave->lacp->active) {
503         state |= LACP_STATE_ACT;
504     }
505
506     if (slave->lacp->fast) {
507         state |= LACP_STATE_TIME;
508     }
509
510     if (slave->attached) {
511         state |= LACP_STATE_SYNC;
512     }
513
514     if (slave->status == LACP_DEFAULTED) {
515         state |= LACP_STATE_DEF;
516     }
517
518     if (slave->status == LACP_EXPIRED) {
519         state |= LACP_STATE_EXP;
520     }
521
522     if (hmap_count(&slave->lacp->slaves) > 1) {
523         state |= LACP_STATE_AGG;
524     }
525
526     if (slave->attached || !slave->lacp->negotiated) {
527         state |= LACP_STATE_COL | LACP_STATE_DIST;
528     }
529
530     actor->state = state;
531     actor->key = htons(slave->lacp->key_slave->port_id);
532     actor->port_priority = htons(slave->port_priority);
533     actor->port_id = htons(slave->port_id);
534     actor->sys_priority = htons(slave->lacp->sys_priority);
535     memcpy(&actor->sys_id, slave->lacp->sys_id, ETH_ADDR_LEN);
536 }
537
538 /* Given 'slave', populates 'priority' with data representing its LACP link
539  * priority.  If two priority objects populated by this function are compared
540  * using memcmp, the higher priority link will be less than the lower priority
541  * link. */
542 static void
543 slave_get_priority(struct slave *slave, struct lacp_info *priority)
544 {
545     uint16_t partner_priority, actor_priority;
546
547     /* Choose the lacp_info of the higher priority system by comparing their
548      * system priorities and mac addresses. */
549     actor_priority = slave->lacp->sys_priority;
550     partner_priority = ntohs(slave->partner.sys_priority);
551     if (actor_priority < partner_priority) {
552         slave_get_actor(slave, priority);
553     } else if (partner_priority < actor_priority) {
554         *priority = slave->partner;
555     } else if (eth_addr_compare_3way(slave->lacp->sys_id,
556                                      slave->partner.sys_id) < 0) {
557         slave_get_actor(slave, priority);
558     } else {
559         *priority = slave->partner;
560     }
561
562     /* Key and state are not used in priority comparisons. */
563     priority->key = 0;
564     priority->state = 0;
565 }
566
567 static bool
568 slave_may_tx(const struct slave *slave)
569 {
570     return slave->lacp->active || slave->status != LACP_DEFAULTED;
571 }
572
573 static struct slave *
574 slave_lookup(const struct lacp *lacp, const void *slave_)
575 {
576     struct slave *slave;
577
578     HMAP_FOR_EACH_IN_BUCKET (slave, node, hash_pointer(slave_, 0),
579                              &lacp->slaves) {
580         if (slave->aux == slave_) {
581             return slave;
582         }
583     }
584
585     return NULL;
586 }
587
588 /* Two lacp_info structures are tx_equal if and only if they do not differ in
589  * ways which would require a lacp_pdu transmission. */
590 static bool
591 info_tx_equal(struct lacp_info *a, struct lacp_info *b)
592 {
593
594     /* LACP specification dictates that we transmit whenever the actor and
595      * remote_actor differ in the following fields: Port, Port Priority,
596      * System, System Priority, Aggregation Key, Activity State, Timeout State,
597      * Sync State, and Aggregation State. The state flags are most likely to
598      * change so are checked first. */
599     return !((a->state ^ b->state) & (LACP_STATE_ACT
600                                       | LACP_STATE_TIME
601                                       | LACP_STATE_SYNC
602                                       | LACP_STATE_AGG))
603         && a->port_id == b->port_id
604         && a->port_priority == b->port_priority
605         && a->key == b->key
606         && a->sys_priority == b->sys_priority
607         && eth_addr_equals(a->sys_id, b->sys_id);
608 }
609 \f
610 static struct lacp *
611 lacp_find(const char *name)
612 {
613     struct lacp *lacp;
614
615     LIST_FOR_EACH (lacp, node, &all_lacps) {
616         if (!strcmp(lacp->name, name)) {
617             return lacp;
618         }
619     }
620
621     return NULL;
622 }
623
624 static void
625 ds_put_lacp_state(struct ds *ds, uint8_t state)
626 {
627     if (state & LACP_STATE_ACT) {
628         ds_put_cstr(ds, "activity ");
629     }
630
631     if (state & LACP_STATE_TIME) {
632         ds_put_cstr(ds, "timeout ");
633     }
634
635     if (state & LACP_STATE_AGG) {
636         ds_put_cstr(ds, "aggregation ");
637     }
638
639     if (state & LACP_STATE_SYNC) {
640         ds_put_cstr(ds, "synchronized ");
641     }
642
643     if (state & LACP_STATE_COL) {
644         ds_put_cstr(ds, "collecting ");
645     }
646
647     if (state & LACP_STATE_DIST) {
648         ds_put_cstr(ds, "distributing ");
649     }
650
651     if (state & LACP_STATE_DEF) {
652         ds_put_cstr(ds, "defaulted ");
653     }
654
655     if (state & LACP_STATE_EXP) {
656         ds_put_cstr(ds, "expired ");
657     }
658 }
659
660 static void
661 lacp_unixctl_show(struct unixctl_conn *conn,
662                   const char *args, void *aux OVS_UNUSED)
663 {
664     struct ds ds = DS_EMPTY_INITIALIZER;
665     struct lacp *lacp;
666     struct slave *slave;
667
668     lacp = lacp_find(args);
669     if (!lacp) {
670         unixctl_command_reply(conn, 501, "no such lacp object");
671         return;
672     }
673
674     ds_put_format(&ds, "lacp: %s\n", lacp->name);
675
676     ds_put_format(&ds, "\tstatus: %s", lacp->active ? "active" : "passive");
677     if (lacp->strict) {
678         ds_put_cstr(&ds, " strict");
679     }
680     if (lacp->negotiated) {
681         ds_put_cstr(&ds, " negotiated");
682     }
683     ds_put_cstr(&ds, "\n");
684
685     ds_put_format(&ds, "\tsys_id: " ETH_ADDR_FMT "\n", ETH_ADDR_ARGS(lacp->sys_id));
686     ds_put_format(&ds, "\tsys_priority: %u\n", lacp->sys_priority);
687     ds_put_cstr(&ds, "\taggregation key: ");
688     if (lacp->key_slave) {
689         ds_put_format(&ds, "%u", lacp->key_slave->port_id);
690     } else {
691         ds_put_cstr(&ds, "none");
692     }
693     ds_put_cstr(&ds, "\n");
694
695     HMAP_FOR_EACH (slave, node, &lacp->slaves) {
696         char *status;
697         struct lacp_info actor;
698
699         slave_get_actor(slave, &actor);
700         switch (slave->status) {
701         case LACP_CURRENT:
702             status = "current";
703             break;
704         case LACP_EXPIRED:
705             status = "expired";
706             break;
707         case LACP_DEFAULTED:
708             status = "defaulted";
709             break;
710         default:
711             NOT_REACHED();
712         }
713
714         ds_put_format(&ds, "\nslave: %s: %s %s\n", slave->name, status,
715                       slave->attached ? "attached" : "detached");
716         ds_put_format(&ds, "\tport_id: %u\n", slave->port_id);
717         ds_put_format(&ds, "\tport_priority: %u\n", slave->port_priority);
718
719         ds_put_format(&ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n",
720                       ETH_ADDR_ARGS(actor.sys_id));
721         ds_put_format(&ds, "\tactor sys_priority: %u\n",
722                       ntohs(actor.sys_priority));
723         ds_put_format(&ds, "\tactor port_id: %u\n",
724                       ntohs(actor.port_id));
725         ds_put_format(&ds, "\tactor port_priority: %u\n",
726                       ntohs(actor.port_priority));
727         ds_put_format(&ds, "\tactor key: %u\n",
728                       ntohs(actor.key));
729         ds_put_cstr(&ds, "\tactor state: ");
730         ds_put_lacp_state(&ds, actor.state);
731         ds_put_cstr(&ds, "\n\n");
732
733         ds_put_format(&ds, "\tpartner sys_id: " ETH_ADDR_FMT "\n",
734                       ETH_ADDR_ARGS(slave->partner.sys_id));
735         ds_put_format(&ds, "\tpartner sys_priority: %u\n",
736                       ntohs(slave->partner.sys_priority));
737         ds_put_format(&ds, "\tpartner port_id: %u\n",
738                       ntohs(slave->partner.port_id));
739         ds_put_format(&ds, "\tpartner port_priority: %u\n",
740                       ntohs(slave->partner.port_priority));
741         ds_put_format(&ds, "\tpartner key: %u\n",
742                       ntohs(slave->partner.key));
743         ds_put_cstr(&ds, "\tpartner state: ");
744         ds_put_lacp_state(&ds, slave->partner.state);
745         ds_put_cstr(&ds, "\n");
746     }
747
748     unixctl_command_reply(conn, 200, ds_cstr(&ds));
749     ds_destroy(&ds);
750 }