From: dv1tas Date: Thu, 27 Jun 2013 09:20:45 +0000 (+0000) Subject: Check bpdu->flags only when this field is valid, i.e. not STP-TCN BPDU X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9400c229f29f63006887bcfbcab00b1c6e0c2040;p=people%2Fms%2Fmstpd.git Check bpdu->flags only when this field is valid, i.e. not STP-TCN BPDU git-svn-id: svn://svn.code.sf.net/p/mstpd/code/trunk@52 fbe50366-0c72-4402-a84b-5d246361dba7 --- diff --git a/bridge_track.c b/bridge_track.c index ed90194..2a521b3 100644 --- a/bridge_track.c +++ b/bridge_track.c @@ -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 9d76287..5338e99 100644 --- 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;