Skip to content

Commit 34bdd1b

Browse files
committed
stp: fix misplaced break in Ieee8021dBpduSerializer causing serialization failure
The break statement in the BPDU_CFG case of the serialize() method was placed immediately after the dynamic cast, before any of the BPDU fields were written to the stream. This caused the serializer to only write the 4-byte BPDU header (protocolIdentifier, protocolVersionIdentifier, bpduType = 32 bits) while the BpduCfg chunk declares chunkLength = B(35) (280 bits). When fcsMode was set to 'computed', the EthernetFcsInserter would serialize the packet to compute the FCS and detect the mismatch: 'serialized length is incorrect: serialized=32 bit, chunk=280 bit' The fix moves the break to after all BpduCfg fields are serialized.
1 parent b7f0549 commit 34bdd1b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/inet/linklayer/ieee8021d/common/Ieee8021dBpduSerializer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ void Ieee8021dBpduSerializer::serialize(MemoryOutputStream& stream, const Ptr<co
2525
switch (bpduBase->getBpduType()) {
2626
case BPDU_CFG: {
2727
const auto& bpdu = CHK(dynamicPtrCast<const BpduCfg>(chunk));
28-
break;
2928
stream.writeBit(bpdu->getTcaFlag());
3029
stream.writeNBitsOfUint64Be(bpdu->getReserved(), 6);
3130
stream.writeBit(bpdu->getTcFlag());
@@ -40,6 +39,7 @@ void Ieee8021dBpduSerializer::serialize(MemoryOutputStream& stream, const Ptr<co
4039
stream.writeUint16Be(bpdu->getMaxAge().dbl() * 256);
4140
stream.writeUint16Be(bpdu->getHelloTime().dbl() * 256);
4241
stream.writeUint16Be(bpdu->getForwardDelay().dbl() * 256);
42+
break;
4343
}
4444
case BPDU_TCN: {
4545
const auto& bpdu = CHK(dynamicPtrCast<const BpduTcn>(chunk));

0 commit comments

Comments
 (0)