Skip to content

Commit dacf233

Browse files
committed
Fix crash when combining multicast traffic with VLANs
When IPv4 creates a multicast loopback copy via packet->dup(), the EncapsulationProtocolReq tag (e.g. ieee8021qctag from PacketTagger) is inherited. This causes MessageDispatchers to route the loopback copy through the VLAN/Ethernet path instead of the loopback interface, leading to a 'MacAddressReq tag is absent' error in EthernetEncapsulation. Fix: clear EncapsulationProtocolReq for loopback interfaces in sendPacketToNIC(), since loopback does not perform link-layer encapsulation. Reasoning: IP_MULTICAST_LOOP delivers a local copy as a network-layer datagram, not as an Ethernet frame. The looped-back copy should go directly to local IP input and UDP delivery, bypassing link-layer processing (MAC, VLAN tagging, FCS, etc.) entirely. Only the outward copy sent via the selected interface should be encapsulated into an Ethernet frame with a multicast destination MAC.
1 parent 670f7cc commit dacf233

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/inet/networklayer/ipv4/Ipv4.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,9 @@ void Ipv4::sendPacketToNIC(Packet *packet)
12221222
EV_INFO << "Sending " << packet << " to output interface = " << networkInterface->getInterfaceName() << ".\n";
12231223
packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::ipv4);
12241224
packet->addTagIfAbsent<DispatchProtocolInd>()->setProtocol(&Protocol::ipv4);
1225-
if (auto networkInterfaceProtocol = networkInterface->getProtocol())
1225+
if (networkInterface->isLoopback())
1226+
packet->removeTagIfPresent<EncapsulationProtocolReq>();
1227+
else if (auto networkInterfaceProtocol = networkInterface->getProtocol())
12261228
ensureEncapsulationProtocolReq(packet, networkInterfaceProtocol, true, false);
12271229
setDispatchProtocol(packet);
12281230
send(packet, "queueOut");

0 commit comments

Comments
 (0)