From 5323b89e368731807fa103e6eac6260b78b73f00 Mon Sep 17 00:00:00 2001 From: Vitalii Demianets Date: Tue, 27 Sep 2011 10:21:00 +0000 Subject: [PATCH] Fix bug: infinite recursion in TCSM git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@8 fbe50366-0c72-4402-a84b-5d246361dba7 --- mstp.c | 13 ++++++++++--- mstp.h | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mstp.c b/mstp.c index 22f81a9..6ffd40f 100644 --- a/mstp.c +++ b/mstp.c @@ -148,6 +148,8 @@ static per_tree_port_t * create_ptp(tree_t *tree, port_t *prt) assign(ptp->portPriority, tree->BridgePriority); assign(ptp->portTimes, tree->BridgeTimes); + ptp->calledFromFlushRoutine = false; + /* The following are initialized in BEGIN state: * - rcvdMsg: in Port Receive SM * - fdWhile, rrWhile, rbWhile, role, learn, forward, @@ -445,11 +447,14 @@ void MSTP_IN_one_second(bridge_t *br) void MSTP_IN_all_fids_flushed(per_tree_port_t *ptp) { bridge_t *br = ptp->port->bridge; + ptp->fdbFlush = false; if(!br->bridgeEnabled) return; - ptp->fdbFlush = false; - TCSM_run(ptp); - br_state_machines_run(br); + if(!ptp->calledFromFlushRoutine) + { + TCSM_run(ptp); + br_state_machines_run(br); + } } /* NOTE: bpdu pointer is unaligned, but it works because @@ -1841,7 +1846,9 @@ static void set_fdbFlush(per_tree_port_t *ptp) if(rstpVersion(br)) { ptp->fdbFlush = true; + ptp->calledFromFlushRoutine = true; MSTP_OUT_flush_all_fids(ptp); + ptp->calledFromFlushRoutine = false; } else { diff --git a/mstp.h b/mstp.h index b5bf3a8..0a5d36b 100644 --- a/mstp.h +++ b/mstp.h @@ -530,6 +530,9 @@ typedef struct PSTSM_states_t PSTSM_state; TCSM_states_t TCSM_state; + /* Auxiliary flag, helps preventing infinite recursion */ + bool calledFromFlushRoutine; + /* Pointer to the corresponding MSTI Configuration Message * in the port->rcvdBpduData */ msti_configuration_message_t *rcvdMstiConfig; -- 2.39.2