lacp: Remove unused lacp_slave_get_port_id().
[sliver-openvswitch.git] / lib / lacp.c
index e1d365d..8bc115d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 Nicira, Inc.
+/* Copyright (c) 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 #include <config.h>
 #include "lacp.h"
 
-#include <assert.h>
 #include <stdlib.h>
 
 #include "dynamic-string.h"
@@ -223,7 +222,7 @@ lacp_destroy(struct lacp *lacp)
 void
 lacp_configure(struct lacp *lacp, const struct lacp_settings *s)
 {
-    assert(!eth_addr_is_zero(s->id));
+    ovs_assert(!eth_addr_is_zero(s->id));
 
     if (!lacp->name || strcmp(s->name, lacp->name)) {
         free(lacp->name);
@@ -362,6 +361,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,24 +376,12 @@ 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;
     }
 }
 
-/* Returns the port ID used for 'slave_' in LACP communications. */
-uint16_t
-lacp_slave_get_port_id(const struct lacp *lacp, const void *slave_)
-{
-    struct slave *slave = slave_lookup(lacp, slave_);
-    return slave->port_id;
-}
-
 /* Returns true if partner information on 'slave_' is up to date.  'slave_'
  * not being current, generally indicates a connectivity problem, or a
  * misconfigured (or broken) partner. */
@@ -746,7 +741,9 @@ lacp_print_details(struct ds *ds, struct lacp *lacp)
     ds_put_format(ds, "\tsys_priority: %u\n", lacp->sys_priority);
     ds_put_cstr(ds, "\taggregation key: ");
     if (lacp->key_slave) {
-        ds_put_format(ds, "%u", lacp->key_slave->port_id);
+        ds_put_format(ds, "%u", lacp->key_slave->key
+                                ? lacp->key_slave->key
+                                : lacp->key_slave->port_id);
     } else {
         ds_put_cstr(ds, "none");
     }
@@ -788,6 +785,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));