]> git.ipfire.org Git - people/ms/mstpd.git/commitdiff
Check bpdu->flags only when this field is valid, i.e. not STP-TCN BPDU
authordv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Thu, 27 Jun 2013 09:20:45 +0000 (09:20 +0000)
committerdv1tas <dv1tas@fbe50366-0c72-4402-a84b-5d246361dba7>
Thu, 27 Jun 2013 09:20:45 +0000 (09:20 +0000)
git-svn-id: svn://svn.code.sf.net/p/mstpd/code/trunk@52 fbe50366-0c72-4402-a84b-5d246361dba7

bridge_track.c
mstp.c

index ed9019410fcaf0b135b16f8d43767351d787de81..2a521b3faeb50d2894d332a0f75c410d9825891f 100644 (file)
@@ -537,7 +537,7 @@ void MSTP_OUT_set_ageing_time(port_t *prt, unsigned int ageingTime)
 
 void MSTP_OUT_tx_bpdu(port_t * ifc, bpdu_t * bpdu, int size)
 {
-    char *bpdu_type;
+    char *bpdu_type, *tcflag;
     bridge_t *br = ifc->bridge;
 
     switch(bpdu->protocolVersion)
@@ -550,7 +550,6 @@ void MSTP_OUT_tx_bpdu(port_t * ifc, bpdu_t * bpdu, int size)
                     break;
                 case bpduTypeTCN:
                     bpdu_type = "STP-TCN";
-                    ++(ifc->num_tx_tcn);
                     break;
                 default:
                     bpdu_type = "STP-UnknownType";
@@ -566,8 +565,22 @@ void MSTP_OUT_tx_bpdu(port_t * ifc, bpdu_t * bpdu, int size)
             bpdu_type = "UnknownProto";
     }
 
-    LOG_PRTNAME(br, ifc, "sending %s BPDU%s", bpdu_type,
-        (bpdu->flags & (1 << offsetTc)) ? ", tcFlag" : "");
+    ++(ifc->num_tx_bpdu);
+    if((protoSTP == bpdu->protocolVersion) && (bpduTypeTCN == bpdu->bpduType))
+    {
+        ++(ifc->num_tx_tcn);
+        LOG_PRTNAME(br, ifc, "sending %s BPDU", bpdu_type);
+    }
+    else
+    {
+        tcflag = "";
+        if(bpdu->flags & (1 << offsetTc))
+        {
+            ++(ifc->num_tx_tcn);
+            tcflag = ", tcFlag";
+        }
+        LOG_PRTNAME(br, ifc, "sending %s BPDU%s", bpdu_type, tcflag);
+    }
 
     struct llc_header h;
     memcpy(h.dest_addr, bridge_group_address, ETH_ALEN);
@@ -581,9 +594,7 @@ void MSTP_OUT_tx_bpdu(port_t * ifc, bpdu_t * bpdu, int size)
         { .iov_base = &h, .iov_len = sizeof(h) },
         { .iov_base = bpdu, .iov_len = size }
     };
-    ++(ifc->num_tx_bpdu);
-    if(bpdu->flags & (1 << offsetTc))
-        ++(ifc->num_tx_tcn);
+
     packet_send(ifc->sysdeps.if_index, iov, 2, sizeof(h) + size);
 }
 
diff --git a/mstp.c b/mstp.c
index 9d76287a7f9806355a142e0bf25fe89da0d2c82e..5338e99d126b9014091be7d393491f343d3c2580 100644 (file)
--- a/mstp.c
+++ b/mstp.c
@@ -564,10 +564,6 @@ void MSTP_IN_rx_bpdu(port_t *prt, bpdu_t *bpdu, int size)
     bridge_t *br = prt->bridge;
 
     ++(prt->num_rx_bpdu);
-    if(bpdu->flags & (1 << offsetTc))
-        ++(prt->num_rx_tcn);
-    if(bpdu->bpduType == bpduTypeTCN)
-        ++(prt->num_rx_tcn);
 
     if(prt->BpduGuardPort)
     {
@@ -664,6 +660,16 @@ bpdu_validation_failed:
             goto bpdu_validation_failed;
     }
 
+    if((protoSTP == bpdu->protocolVersion) && (bpduTypeTCN == bpdu->bpduType))
+    {
+        ++(prt->num_rx_tcn);
+    }
+    else
+    {
+        if(bpdu->flags & (1 << offsetTc))
+            ++(prt->num_rx_tcn);
+    }
+
     assign(prt->rcvdBpduData, *bpdu);
     prt->rcvdBpdu = true;