]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Fix bug: infinite recursion in TCSM
authorVitalii Demianets <vitas@nppfactor.kiev.ua>
Tue, 27 Sep 2011 10:21:00 +0000 (10:21 +0000)
committerVitalii Demianets <vitas@nppfactor.kiev.ua>
Tue, 27 Sep 2011 10:21:00 +0000 (10:21 +0000)
git-svn-id: http://svn.code.sf.net/p/mstpd/code/trunk@8 fbe50366-0c72-4402-a84b-5d246361dba7

mstp.c
mstp.h

diff --git a/mstp.c b/mstp.c
index 22f81a91bc539a2c0ccb0b80ff1ebddf031fc127..6ffd40f77d719c9f2bdda9ed8eb253b03d0a7aa2 100644 (file)
--- 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 b5bf3a8c1cb4169734a8d13ae20ab67424467b26..0a5d36bd8ac9ca37645994fc8b6121e195193b96 100644 (file)
--- 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;