]>
git.proxmox.com Git - ovs.git/blob - lib/lacp.c
1 /* Copyright (c) 2011 Nicira Networks
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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include "dynamic-string.h"
27 #include "poll-loop.h"
33 VLOG_DEFINE_THIS_MODULE(lacp
);
35 /* Masks for lacp_info state member. */
36 #define LACP_STATE_ACT 0x01 /* Activity. Active or passive? */
37 #define LACP_STATE_TIME 0x02 /* Timeout. Short or long timeout? */
38 #define LACP_STATE_AGG 0x04 /* Aggregation. Is the link is bondable? */
39 #define LACP_STATE_SYNC 0x08 /* Synchronization. Is the link in up to date? */
40 #define LACP_STATE_COL 0x10 /* Collecting. Is the link receiving frames? */
41 #define LACP_STATE_DIST 0x20 /* Distributing. Is the link sending frames? */
42 #define LACP_STATE_DEF 0x40 /* Defaulted. Using default partner info? */
43 #define LACP_STATE_EXP 0x80 /* Expired. Using expired partner info? */
45 #define LACP_FAST_TIME_TX 1000 /* Fast transmission rate. */
46 #define LACP_SLOW_TIME_TX 30000 /* Slow transmission rate. */
47 #define LACP_RX_MULTIPLIER 3 /* Multiply by TX rate to get RX rate. */
49 #define LACP_INFO_LEN 15
51 ovs_be16 sys_priority
; /* System priority. */
52 uint8_t sys_id
[ETH_ADDR_LEN
]; /* System ID. */
53 ovs_be16 key
; /* Operational key. */
54 ovs_be16 port_priority
; /* Port priority. */
55 ovs_be16 port_id
; /* Port ID. */
56 uint8_t state
; /* State mask. See LACP_STATE macros. */
57 } __attribute__((packed
));
58 BUILD_ASSERT_DECL(LACP_INFO_LEN
== sizeof(struct lacp_info
));
60 #define LACP_PDU_LEN 110
62 uint8_t subtype
; /* Always 1. */
63 uint8_t version
; /* Always 1. */
65 uint8_t actor_type
; /* Always 1. */
66 uint8_t actor_len
; /* Always 20. */
67 struct lacp_info actor
; /* LACP actor information. */
68 uint8_t z1
[3]; /* Reserved. Always 0. */
70 uint8_t partner_type
; /* Always 2. */
71 uint8_t partner_len
; /* Always 20. */
72 struct lacp_info partner
; /* LACP partner information. */
73 uint8_t z2
[3]; /* Reserved. Always 0. */
75 uint8_t collector_type
; /* Always 3. */
76 uint8_t collector_len
; /* Always 16. */
77 ovs_be16 collector_delay
; /* Maximum collector delay. Set to UINT16_MAX. */
78 uint8_t z3
[64]; /* Combination of several fields. Always 0. */
79 } __attribute__((packed
));
80 BUILD_ASSERT_DECL(LACP_PDU_LEN
== sizeof(struct lacp_pdu
));
85 LACP_CURRENT
, /* Current State. Partner up to date. */
86 LACP_EXPIRED
, /* Expired State. Partner out of date. */
87 LACP_DEFAULTED
, /* Defaulted State. No partner. */
91 struct list node
; /* Node in all_lacps list. */
92 char *name
; /* Name of this lacp object. */
93 uint8_t sys_id
[ETH_ADDR_LEN
]; /* System ID. */
94 uint16_t sys_priority
; /* System Priority. */
95 bool active
; /* Active or Passive. */
97 struct hmap slaves
; /* Slaves this LACP object controls. */
98 struct slave
*key_slave
; /* Slave whose ID will be the aggregation key. */
100 enum lacp_time lacp_time
; /* Fast, Slow or Custom LACP time. */
101 long long int custom_time
; /* LACP_TIME_CUSTOM transmission rate. */
102 bool negotiated
; /* True if LACP negotiations were successful. */
103 bool update
; /* True if lacp_update() needs to be called. */
104 bool heartbeat
; /* LACP heartbeat mode. */
108 void *aux
; /* Handle used to identify this slave. */
109 struct hmap_node node
; /* Node in master's slaves map. */
111 struct lacp
*lacp
; /* LACP object containing this slave. */
112 uint16_t port_id
; /* Port ID. */
113 uint16_t port_priority
; /* Port Priority. */
114 uint16_t key
; /* Aggregation Key. 0 if default. */
115 char *name
; /* Name of this slave. */
117 enum slave_status status
; /* Slave status. */
118 bool attached
; /* Attached. Traffic may flow. */
119 struct lacp_info partner
; /* Partner information. */
120 struct lacp_info ntt_actor
; /* Used to decide if we Need To Transmit. */
121 struct timer tx
; /* Next message transmission timer. */
122 struct timer rx
; /* Expected message receive timer. */
125 static struct list all_lacps
= LIST_INITIALIZER(&all_lacps
);
127 static void lacp_update_attached(struct lacp
*);
129 static void slave_destroy(struct slave
*);
130 static void slave_set_defaulted(struct slave
*);
131 static void slave_set_expired(struct slave
*);
132 static void slave_get_actor(struct slave
*, struct lacp_info
*actor
);
133 static void slave_get_priority(struct slave
*, struct lacp_info
*priority
);
134 static bool slave_may_tx(const struct slave
*);
135 static struct slave
*slave_lookup(const struct lacp
*, const void *slave
);
136 static bool info_tx_equal(struct lacp_info
*, struct lacp_info
*);
138 static void lacp_unixctl_show(struct unixctl_conn
*, const char *args
,
141 /* Populates 'pdu' with a LACP PDU comprised of 'actor' and 'partner'. */
143 compose_lacp_pdu(const struct lacp_info
*actor
,
144 const struct lacp_info
*partner
, struct lacp_pdu
*pdu
)
146 memset(pdu
, 0, sizeof *pdu
);
155 pdu
->partner_type
= 2;
156 pdu
->partner_len
= 20;
157 pdu
->partner
= *partner
;
159 pdu
->collector_type
= 3;
160 pdu
->collector_len
= 16;
161 pdu
->collector_delay
= htons(0);
164 /* Parses 'b' which represents a packet containing a LACP PDU. This function
165 * returns NULL if 'b' is malformed, or does not represent a LACP PDU format
166 * supported by OVS. Otherwise, it returns a pointer to the lacp_pdu contained
168 static const struct lacp_pdu
*
169 parse_lacp_packet(const struct ofpbuf
*b
)
171 const struct lacp_pdu
*pdu
;
173 pdu
= ofpbuf_at(b
, (uint8_t *)b
->l3
- (uint8_t *)b
->data
, LACP_PDU_LEN
);
175 if (pdu
&& pdu
->subtype
== 1
176 && pdu
->actor_type
== 1 && pdu
->actor_len
== 20
177 && pdu
->partner_type
== 2 && pdu
->partner_len
== 20) {
184 /* LACP Protocol Implementation. */
186 /* Initializes the lacp module. */
190 unixctl_command_register("lacp/show", "port", lacp_unixctl_show
, NULL
);
193 /* Creates a LACP object. */
199 lacp
= xzalloc(sizeof *lacp
);
200 hmap_init(&lacp
->slaves
);
201 list_push_back(&all_lacps
, &lacp
->node
);
205 /* Destroys 'lacp' and its slaves. Does nothing if 'lacp' is NULL. */
207 lacp_destroy(struct lacp
*lacp
)
210 struct slave
*slave
, *next
;
212 HMAP_FOR_EACH_SAFE (slave
, next
, node
, &lacp
->slaves
) {
213 slave_destroy(slave
);
216 hmap_destroy(&lacp
->slaves
);
217 list_remove(&lacp
->node
);
223 /* Configures 'lacp' with settings from 's'. */
225 lacp_configure(struct lacp
*lacp
, const struct lacp_settings
*s
)
227 if (!lacp
->name
|| strcmp(s
->name
, lacp
->name
)) {
229 lacp
->name
= xstrdup(s
->name
);
232 if (!eth_addr_equals(lacp
->sys_id
, s
->id
)
233 || lacp
->sys_priority
!= s
->priority
234 || lacp
->heartbeat
!= s
->heartbeat
) {
235 memcpy(lacp
->sys_id
, s
->id
, ETH_ADDR_LEN
);
236 lacp
->sys_priority
= s
->priority
;
237 lacp
->heartbeat
= s
->heartbeat
;
241 lacp
->active
= s
->active
;
242 lacp
->lacp_time
= s
->lacp_time
;
243 lacp
->custom_time
= MAX(TIME_UPDATE_INTERVAL
, s
->custom_time
);
246 /* Returns true if 'lacp' is configured in active mode, false if 'lacp' is
247 * configured for passive mode. */
249 lacp_is_active(const struct lacp
*lacp
)
254 /* Processes 'packet' which was received on 'slave_'. This function should be
255 * called on all packets received on 'slave_' with Ethernet Type ETH_TYPE_LACP.
258 lacp_process_packet(struct lacp
*lacp
, const void *slave_
,
259 const struct ofpbuf
*packet
)
261 static struct vlog_rate_limit rl
= VLOG_RATE_LIMIT_INIT(1, 5);
262 struct slave
*slave
= slave_lookup(lacp
, slave_
);
263 const struct lacp_pdu
*pdu
;
264 long long int tx_rate
;
266 pdu
= parse_lacp_packet(packet
);
268 VLOG_WARN_RL(&rl
, "%s: received an unparsable LACP PDU.", lacp
->name
);
272 switch (lacp
->lacp_time
) {
274 tx_rate
= LACP_FAST_TIME_TX
;
277 tx_rate
= LACP_SLOW_TIME_TX
;
279 case LACP_TIME_CUSTOM
:
280 tx_rate
= lacp
->custom_time
;
282 default: NOT_REACHED();
285 slave
->status
= LACP_CURRENT
;
286 timer_set_duration(&slave
->rx
, LACP_RX_MULTIPLIER
* tx_rate
);
288 slave
->ntt_actor
= pdu
->partner
;
290 /* Update our information about our partner if it's out of date. This may
291 * cause priorities to change so re-calculate attached status of all
293 if (memcmp(&slave
->partner
, &pdu
->actor
, sizeof pdu
->actor
)) {
295 slave
->partner
= pdu
->actor
;
299 /* Returns true if 'lacp' has successfully negotiated with its partner. False
300 * if 'lacp' is NULL. */
302 lacp_negotiated(const struct lacp
*lacp
)
304 return lacp
? lacp
->negotiated
: false;
307 /* Registers 'slave_' as subordinate to 'lacp'. This should be called at least
308 * once per slave in a LACP managed bond. Should also be called whenever a
309 * slave's settings change. */
311 lacp_slave_register(struct lacp
*lacp
, void *slave_
,
312 const struct lacp_slave_settings
*s
)
314 struct slave
*slave
= slave_lookup(lacp
, slave_
);
317 slave
= xzalloc(sizeof *slave
);
320 hmap_insert(&lacp
->slaves
, &slave
->node
, hash_pointer(slave_
, 0));
321 slave_set_defaulted(slave
);
323 if (!lacp
->key_slave
) {
324 lacp
->key_slave
= slave
;
328 if (!slave
->name
|| strcmp(s
->name
, slave
->name
)) {
330 slave
->name
= xstrdup(s
->name
);
333 if (slave
->port_id
!= s
->id
334 || slave
->port_priority
!= s
->priority
335 || slave
->key
!= s
->key
) {
336 slave
->port_id
= s
->id
;
337 slave
->port_priority
= s
->priority
;
342 if (lacp
->active
|| lacp
->negotiated
) {
343 slave_set_expired(slave
);
348 /* Unregisters 'slave_' with 'lacp'. */
350 lacp_slave_unregister(struct lacp
*lacp
, const void *slave_
)
352 struct slave
*slave
= slave_lookup(lacp
, slave_
);
355 slave_destroy(slave
);
360 /* This function should be called whenever the carrier status of 'slave_' has
363 lacp_slave_carrier_changed(const struct lacp
*lacp
, const void *slave_
)
365 struct slave
*slave
= slave_lookup(lacp
, slave_
);
367 if (slave
->status
== LACP_CURRENT
|| slave
->lacp
->active
) {
368 slave_set_expired(slave
);
372 /* This function should be called before enabling 'slave_' to send or receive
373 * traffic. If it returns false, 'slave_' should not enabled. As a
374 * convenience, returns true if 'lacp' is NULL. */
376 lacp_slave_may_enable(const struct lacp
*lacp
, const void *slave_
)
379 struct slave
*slave
= slave_lookup(lacp
, slave_
);
381 /* The slave may be enabled if it's attached to an aggregator and its
382 * partner is synchronized. The only exception is defaulted slaves.
383 * They are not required to have synchronized partners because they
384 * have no partners at all. They will only be attached if negotiations
385 * failed on all slaves in the bond. */
386 return slave
->attached
&& (slave
->partner
.state
& LACP_STATE_SYNC
387 || slave
->status
== LACP_DEFAULTED
);
393 /* Returns the port ID used for 'slave_' in LACP communications. */
395 lacp_slave_get_port_id(const struct lacp
*lacp
, const void *slave_
)
397 struct slave
*slave
= slave_lookup(lacp
, slave_
);
398 return slave
->port_id
;
401 /* Returns true if partner information on 'slave_' is up to date. 'slave_'
402 * not being current, generally indicates a connectivity problem, or a
403 * misconfigured (or broken) partner. */
405 lacp_slave_is_current(const struct lacp
*lacp
, const void *slave_
)
407 return slave_lookup(lacp
, slave_
)->status
!= LACP_DEFAULTED
;
410 /* This function should be called periodically to update 'lacp'. */
412 lacp_run(struct lacp
*lacp
, lacp_send_pdu
*send_pdu
)
416 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
417 if (timer_expired(&slave
->rx
)) {
418 if (slave
->status
== LACP_CURRENT
) {
419 slave_set_expired(slave
);
420 } else if (slave
->status
== LACP_EXPIRED
) {
421 slave_set_defaulted(slave
);
427 lacp_update_attached(lacp
);
430 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
431 struct lacp_info actor
;
433 if (!slave_may_tx(slave
)) {
437 slave_get_actor(slave
, &actor
);
439 if (timer_expired(&slave
->tx
)
440 || !info_tx_equal(&actor
, &slave
->ntt_actor
)) {
441 long long int duration
;
444 slave
->ntt_actor
= actor
;
445 compose_lacp_pdu(&actor
, &slave
->partner
, &pdu
);
446 send_pdu(slave
->aux
, &pdu
, sizeof pdu
);
448 if (lacp
->lacp_time
== LACP_TIME_CUSTOM
) {
449 duration
= lacp
->custom_time
;
451 duration
= (slave
->partner
.state
& LACP_STATE_TIME
453 : LACP_SLOW_TIME_TX
);
456 timer_set_duration(&slave
->tx
, duration
);
461 /* Causes poll_block() to wake up when lacp_run() needs to be called again. */
463 lacp_wait(struct lacp
*lacp
)
467 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
468 if (slave_may_tx(slave
)) {
469 timer_wait(&slave
->tx
);
472 if (slave
->status
!= LACP_DEFAULTED
) {
473 timer_wait(&slave
->rx
);
478 /* Static Helpers. */
480 /* Updates the attached status of all slaves controlled by 'lacp' and sets its
481 * negotiated parameter to true if any slaves are attachable. */
483 lacp_update_attached(struct lacp
*lacp
)
485 struct slave
*lead
, *slave
;
486 struct lacp_info lead_pri
;
487 static struct vlog_rate_limit rl
= VLOG_RATE_LIMIT_INIT(1, 10);
489 if (lacp
->heartbeat
) {
490 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
491 slave
->attached
= slave
->status
!= LACP_DEFAULTED
;
496 lacp
->update
= false;
499 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
500 struct lacp_info pri
;
502 slave
->attached
= true;
504 /* XXX: In the future allow users to configure the expected system ID.
505 * For now just special case loopback. */
506 if (eth_addr_equals(slave
->partner
.sys_id
, slave
->lacp
->sys_id
)) {
507 VLOG_WARN_RL(&rl
, "slave %s: Loopback detected. Slave is "
508 "connected to its own bond", slave
->name
);
509 slave
->attached
= false;
513 if (slave
->status
== LACP_DEFAULTED
) {
517 slave_get_priority(slave
, &pri
);
519 if (!lead
|| memcmp(&pri
, &lead_pri
, sizeof pri
) < 0) {
525 lacp
->negotiated
= lead
!= NULL
;
528 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
529 if (slave
->status
== LACP_DEFAULTED
530 || lead
->partner
.key
!= slave
->partner
.key
531 || !eth_addr_equals(lead
->partner
.sys_id
,
532 slave
->partner
.sys_id
)) {
533 slave
->attached
= false;
540 slave_destroy(struct slave
*slave
)
543 struct lacp
*lacp
= slave
->lacp
;
546 hmap_remove(&lacp
->slaves
, &slave
->node
);
548 if (lacp
->key_slave
== slave
) {
549 struct hmap_node
*slave_node
= hmap_first(&lacp
->slaves
);
552 lacp
->key_slave
= CONTAINER_OF(slave_node
, struct slave
, node
);
554 lacp
->key_slave
= NULL
;
564 slave_set_defaulted(struct slave
*slave
)
566 memset(&slave
->partner
, 0, sizeof slave
->partner
);
568 slave
->lacp
->update
= true;
569 slave
->status
= LACP_DEFAULTED
;
573 slave_set_expired(struct slave
*slave
)
575 struct lacp
*lacp
= slave
->lacp
;
577 slave
->status
= LACP_EXPIRED
;
578 slave
->partner
.state
|= LACP_STATE_TIME
;
579 slave
->partner
.state
&= ~LACP_STATE_SYNC
;
581 /* The spec says we should wait LACP_RX_MULTIPLIER * LACP_FAST_TIME_TX.
582 * This doesn't make sense when using custom times which can be much
583 * smaller than LACP_FAST_TIME. */
584 timer_set_duration(&slave
->rx
, (lacp
->lacp_time
== LACP_TIME_CUSTOM
586 : LACP_RX_MULTIPLIER
* LACP_FAST_TIME_TX
));
590 slave_get_actor(struct slave
*slave
, struct lacp_info
*actor
)
592 struct lacp
*lacp
= slave
->lacp
;
597 state
|= LACP_STATE_ACT
;
600 if (lacp
->lacp_time
!= LACP_TIME_SLOW
) {
601 state
|= LACP_STATE_TIME
;
604 if (slave
->attached
) {
605 state
|= LACP_STATE_SYNC
;
608 if (slave
->status
== LACP_DEFAULTED
) {
609 state
|= LACP_STATE_DEF
;
612 if (slave
->status
== LACP_EXPIRED
) {
613 state
|= LACP_STATE_EXP
;
616 if (lacp
->heartbeat
|| hmap_count(&lacp
->slaves
) > 1) {
617 state
|= LACP_STATE_AGG
;
620 if (slave
->attached
|| !lacp
->negotiated
) {
621 state
|= LACP_STATE_COL
| LACP_STATE_DIST
;
624 key
= lacp
->key_slave
->key
;
626 key
= lacp
->key_slave
->port_id
;
629 actor
->state
= state
;
630 actor
->key
= htons(key
);
631 actor
->port_priority
= htons(slave
->port_priority
);
632 actor
->port_id
= htons(slave
->port_id
);
633 actor
->sys_priority
= htons(lacp
->sys_priority
);
634 memcpy(&actor
->sys_id
, lacp
->sys_id
, ETH_ADDR_LEN
);
637 /* Given 'slave', populates 'priority' with data representing its LACP link
638 * priority. If two priority objects populated by this function are compared
639 * using memcmp, the higher priority link will be less than the lower priority
642 slave_get_priority(struct slave
*slave
, struct lacp_info
*priority
)
644 uint16_t partner_priority
, actor_priority
;
646 /* Choose the lacp_info of the higher priority system by comparing their
647 * system priorities and mac addresses. */
648 actor_priority
= slave
->lacp
->sys_priority
;
649 partner_priority
= ntohs(slave
->partner
.sys_priority
);
650 if (actor_priority
< partner_priority
) {
651 slave_get_actor(slave
, priority
);
652 } else if (partner_priority
< actor_priority
) {
653 *priority
= slave
->partner
;
654 } else if (eth_addr_compare_3way(slave
->lacp
->sys_id
,
655 slave
->partner
.sys_id
) < 0) {
656 slave_get_actor(slave
, priority
);
658 *priority
= slave
->partner
;
661 /* Key and state are not used in priority comparisons. */
667 slave_may_tx(const struct slave
*slave
)
669 return slave
->lacp
->active
|| slave
->status
!= LACP_DEFAULTED
;
672 static struct slave
*
673 slave_lookup(const struct lacp
*lacp
, const void *slave_
)
677 HMAP_FOR_EACH_IN_BUCKET (slave
, node
, hash_pointer(slave_
, 0),
679 if (slave
->aux
== slave_
) {
687 /* Two lacp_info structures are tx_equal if and only if they do not differ in
688 * ways which would require a lacp_pdu transmission. */
690 info_tx_equal(struct lacp_info
*a
, struct lacp_info
*b
)
693 /* LACP specification dictates that we transmit whenever the actor and
694 * remote_actor differ in the following fields: Port, Port Priority,
695 * System, System Priority, Aggregation Key, Activity State, Timeout State,
696 * Sync State, and Aggregation State. The state flags are most likely to
697 * change so are checked first. */
698 return !((a
->state
^ b
->state
) & (LACP_STATE_ACT
702 && a
->port_id
== b
->port_id
703 && a
->port_priority
== b
->port_priority
705 && a
->sys_priority
== b
->sys_priority
706 && eth_addr_equals(a
->sys_id
, b
->sys_id
);
710 lacp_find(const char *name
)
714 LIST_FOR_EACH (lacp
, node
, &all_lacps
) {
715 if (!strcmp(lacp
->name
, name
)) {
724 ds_put_lacp_state(struct ds
*ds
, uint8_t state
)
726 if (state
& LACP_STATE_ACT
) {
727 ds_put_cstr(ds
, "activity ");
730 if (state
& LACP_STATE_TIME
) {
731 ds_put_cstr(ds
, "timeout ");
734 if (state
& LACP_STATE_AGG
) {
735 ds_put_cstr(ds
, "aggregation ");
738 if (state
& LACP_STATE_SYNC
) {
739 ds_put_cstr(ds
, "synchronized ");
742 if (state
& LACP_STATE_COL
) {
743 ds_put_cstr(ds
, "collecting ");
746 if (state
& LACP_STATE_DIST
) {
747 ds_put_cstr(ds
, "distributing ");
750 if (state
& LACP_STATE_DEF
) {
751 ds_put_cstr(ds
, "defaulted ");
754 if (state
& LACP_STATE_EXP
) {
755 ds_put_cstr(ds
, "expired ");
760 lacp_unixctl_show(struct unixctl_conn
*conn
,
761 const char *args
, void *aux OVS_UNUSED
)
763 struct ds ds
= DS_EMPTY_INITIALIZER
;
767 lacp
= lacp_find(args
);
769 unixctl_command_reply(conn
, 501, "no such lacp object");
773 ds_put_format(&ds
, "lacp: %s\n", lacp
->name
);
775 ds_put_format(&ds
, "\tstatus: %s", lacp
->active
? "active" : "passive");
776 if (lacp
->heartbeat
) {
777 ds_put_cstr(&ds
, " heartbeat");
779 if (lacp
->negotiated
) {
780 ds_put_cstr(&ds
, " negotiated");
782 ds_put_cstr(&ds
, "\n");
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: ");
787 if (lacp
->key_slave
) {
788 ds_put_format(&ds
, "%u", lacp
->key_slave
->port_id
);
790 ds_put_cstr(&ds
, "none");
792 ds_put_cstr(&ds
, "\n");
794 ds_put_cstr(&ds
, "\tlacp_time: ");
795 switch (lacp
->lacp_time
) {
797 ds_put_cstr(&ds
, "fast\n");
800 ds_put_cstr(&ds
, "slow\n");
802 case LACP_TIME_CUSTOM
:
803 ds_put_format(&ds
, "custom (%lld)\n", lacp
->custom_time
);
806 ds_put_cstr(&ds
, "unknown\n");
809 HMAP_FOR_EACH (slave
, node
, &lacp
->slaves
) {
811 struct lacp_info actor
;
813 slave_get_actor(slave
, &actor
);
814 switch (slave
->status
) {
822 status
= "defaulted";
828 ds_put_format(&ds
, "\nslave: %s: %s %s\n", slave
->name
, status
,
829 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
);
833 ds_put_format(&ds
, "\n\tactor sys_id: " ETH_ADDR_FMT
"\n",
834 ETH_ADDR_ARGS(actor
.sys_id
));
835 ds_put_format(&ds
, "\tactor sys_priority: %u\n",
836 ntohs(actor
.sys_priority
));
837 ds_put_format(&ds
, "\tactor port_id: %u\n",
838 ntohs(actor
.port_id
));
839 ds_put_format(&ds
, "\tactor port_priority: %u\n",
840 ntohs(actor
.port_priority
));
841 ds_put_format(&ds
, "\tactor key: %u\n",
843 ds_put_cstr(&ds
, "\tactor state: ");
844 ds_put_lacp_state(&ds
, actor
.state
);
845 ds_put_cstr(&ds
, "\n\n");
847 ds_put_format(&ds
, "\tpartner sys_id: " ETH_ADDR_FMT
"\n",
848 ETH_ADDR_ARGS(slave
->partner
.sys_id
));
849 ds_put_format(&ds
, "\tpartner sys_priority: %u\n",
850 ntohs(slave
->partner
.sys_priority
));
851 ds_put_format(&ds
, "\tpartner port_id: %u\n",
852 ntohs(slave
->partner
.port_id
));
853 ds_put_format(&ds
, "\tpartner port_priority: %u\n",
854 ntohs(slave
->partner
.port_priority
));
855 ds_put_format(&ds
, "\tpartner key: %u\n",
856 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");
862 unixctl_command_reply(conn
, 200, ds_cstr(&ds
));