From 3eecdf1cf75ceebe968578e754cba6e6183bd232 Mon Sep 17 00:00:00 2001 From: mikajuvonen67 <81306121+mikajuvonen67@users.noreply.github.com> Date: Fri, 18 Mar 2022 08:23:40 +0100 Subject: [PATCH] Always update statefile for neighbor elected mac when storing winner mac * Always update statefile for neighbor elected mac when storing winner mac Co-authored-by: Mika Juvonen Co-authored-by: Andy Koszela --- configure.ac | 2 +- teamd/teamd_runner_ttdp.c | 37 +++++++++++-------------------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index b8006c0..3c41928 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([libteam], [1.31-wmo3], [jiri@resnulli.us]) +AC_INIT([libteam], [1.31-wmo4], [mika.juvonen@westermo.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) diff --git a/teamd/teamd_runner_ttdp.c b/teamd/teamd_runner_ttdp.c index 2c4ef6b..a90918b 100644 --- a/teamd/teamd_runner_ttdp.c +++ b/teamd/teamd_runner_ttdp.c @@ -1007,6 +1007,14 @@ static int elect_neighbor(struct teamd_context *ctx, struct ab *ab, uint8_t *nex /* store winner mac */ memcpy(ab->elected_neighbor.neighbor_mac, ab->neighbors[candidate_suggestion].neighbor_mac, sizeof(ab->elected_neighbor.neighbor_mac)); + /* Update neighbor mac statefile */ + /* Notify the rest of the stack that something has changed */ + lag_state_write_elected_neighbor_mac(ctx, ab); + if (ab->is_s4r) { + lag_state_write_elected_neighbor_uuid(ctx, ab); + lag_state_write_elected_neighbor_primary_state(ctx, ab); + } + teamd_ttdp_log_infox(ctx->team_devname, "Writing elected neighbor to state file."); /* store winner uuid */ memcpy(ab->elected_neighbor.neighbor_uuid, ab->neighbors[candidate_suggestion].neighbor_uuid, sizeof(ab->elected_neighbor.neighbor_uuid)); @@ -1069,22 +1077,8 @@ static int ab_link_watch_handler_internal(struct teamd_context *ctx, struct ab * * add links that have come up to the aggregate, but we do elect neighbors. */ if (ab->aggregate_status == TTDP_AGG_STATE_FIXED_END) { teamd_ttdp_log_infox(ctx->team_devname, "Linkwatch handler update in FIXED END mode..."); - /* Neighbor data is automatically set by my ports. Perform election - * and notify tcnd if it's changed. */ - if (elect_neighbor(ctx, ab, ab->neighbor_agreement) != 0) { - /* Notify tcnd that something has changed */ - - //if (ab->silent == TTDP_NOT_SILENT) { - lag_state_write_elected_neighbor_mac(ctx, ab); - if (ab->is_s4r) { - lag_state_write_elected_neighbor_uuid(ctx, ab); - lag_state_write_elected_neighbor_primary_state(ctx, ab); - } - //} - /* FIXME */ - teamd_ttdp_log_infox(ctx->team_devname, "Wrote elected neighbor state file."); - } - + /* Neighbor data is automatically set by my ports. Perform election. */ + elect_neighbor(ctx, ab, ab->neighbor_agreement); update_aggregate_state(ctx, ab); return 0; } @@ -1119,19 +1113,10 @@ static int ab_link_watch_handler_internal(struct teamd_context *ctx, struct ab * } } - /* Neighbor data is automatically set by my ports. Perform election - * and notify tcnd if it's changed. */ + /* Neighbor data is automatically set by my ports. Perform election. */ if (elect_neighbor(ctx, ab, ab->neighbor_agreement) != 0) { if (allow_update_aggregate_state) update_aggregate_state(ctx, ab); - - /* Notify tcnd that something has changed */ - teamd_ttdp_log_infox(ctx->team_devname, "Writing elected neighbor to state file."); - lag_state_write_elected_neighbor_mac(ctx, ab); - if (ab->is_s4r) { - lag_state_write_elected_neighbor_uuid(ctx, ab); - lag_state_write_elected_neighbor_primary_state(ctx, ab); - } } teamd_ttdp_log_dbgx(ctx->team_devname, "AGREE mode %d count %d %d", ab->neighbor_agreement_mode,