Wed, Sep 02, 2015 at 12:54:54AM CEST, sridhar.samudrala(a)intel.com wrote:
Watch for team admin state changes and update the member ports state
to enable/disable sending LACP frames.
Signed-off-by: Sridhar Samudrala <sridhar.samudrala(a)intel.com>
---
libteam/ifinfo.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
teamd/teamd.h | 3 +++
teamd/teamd_events.c | 17 +++++++++++++++++
teamd/teamd_ifinfo_watch.c | 14 ++++++++++----
teamd/teamd_runner_lacp.c | 27 +++++++++++++++++++++++++++
5 files changed, 101 insertions(+), 5 deletions(-)
<snip>
Patch looks good to me. I think that lacp part should be a separate
patch.
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 59d505d..8d88e87 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -1016,6 +1016,11 @@ static int lacpdu_send(struct lacp_port *lacp_port)
struct sockaddr_ll ll_my;
struct sockaddr_ll ll_slow;
int err;
+ bool admin_state;
+
+ admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo);
+ if (!admin_state)
+ return 0;
err = teamd_getsockname_hwaddr(lacp_port->sock, &ll_my, 0);
if (err)
@@ -1302,6 +1307,27 @@ static int lacp_event_watch_hwaddr_changed(struct teamd_context
*ctx,
return 0;
}
+static int lacp_event_watch_admin_state_changed(struct teamd_context *ctx,
+ void *priv)
+{
+ struct lacp *lacp = priv;
+ struct teamd_port *tdport;
+ bool admin_state;
+ int err;
+
+ teamd_for_each_tdport(tdport, ctx) {
+ struct lacp_port *lacp_port = lacp_port_get(lacp, tdport);
+
+ admin_state = team_get_ifinfo_admin_state(ctx->ifinfo);
+ err = lacp_port_set_state(lacp_port,
+ admin_state?PORT_STATE_CURRENT:PORT_STATE_DISABLED);
+ if (err)
+ return err;
+ }
+ return 0;
+}
+
+
static int lacp_event_watch_port_added(struct teamd_context *ctx,
struct teamd_port *tdport, void *priv)
{
@@ -1336,6 +1362,7 @@ static const struct teamd_event_watch_ops lacp_port_watch_ops = {
I think that this struct should be renamed to lacp_event_watch_ops, sice
this this no longer about port events only.
Thanks for taking care of this!
.port_added = lacp_event_watch_port_added,
.port_removed = lacp_event_watch_port_removed,
.port_changed = lacp_event_watch_port_changed,
+ .admin_state_changed = lacp_event_watch_admin_state_changed,
};
static int lacp_carrier_init(struct teamd_context *ctx, struct lacp *lacp)
--
2.1.0