X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Flacp.c;h=374d915a94549e27c6b513d3b7d4b1da30d26ef1;hb=038341d1c1c33107a7f2ad06a5acb47c5fff7967;hp=9d6fb9b18df568ca4e9e647f3bb62b365a9d01ac;hpb=b20a8f7c11fbff647cc65cc3db22a22e5d5cad0b;p=openvswitch diff --git a/lib/lacp.c b/lib/lacp.c index 9d6fb9b1..374d915a 100644 --- a/lib/lacp.c +++ b/lib/lacp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 Nicira Networks +/* Copyright (c) 2011 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -362,6 +362,14 @@ lacp_slave_carrier_changed(const struct lacp *lacp, const void *slave_) } } +static bool +slave_may_enable__(struct slave *slave) +{ + /* The slave may be enabled if it's attached to an aggregator and its + * partner is synchronized.*/ + return slave->attached && (slave->partner.state & LACP_STATE_SYNC); +} + /* This function should be called before enabling 'slave_' to send or receive * traffic. If it returns false, 'slave_' should not enabled. As a * convenience, returns true if 'lacp' is NULL. */ @@ -369,11 +377,7 @@ bool lacp_slave_may_enable(const struct lacp *lacp, const void *slave_) { if (lacp) { - struct slave *slave = slave_lookup(lacp, slave_); - - /* The slave may be enabled if it's attached to an aggregator and its - * partner is synchronized.*/ - return slave->attached && (slave->partner.state & LACP_STATE_SYNC); + return slave_may_enable__(slave_lookup(lacp, slave_)); } else { return true; } @@ -788,6 +792,8 @@ lacp_print_details(struct ds *ds, struct lacp *lacp) slave->attached ? "attached" : "detached"); ds_put_format(ds, "\tport_id: %u\n", slave->port_id); ds_put_format(ds, "\tport_priority: %u\n", slave->port_priority); + ds_put_format(ds, "\tmay_enable: %s\n", (slave_may_enable__(slave) + ? "true" : "false")); ds_put_format(ds, "\n\tactor sys_id: " ETH_ADDR_FMT "\n", ETH_ADDR_ARGS(actor.sys_id));