From 16c05ce2c5a400cec7c0782f6f4b1e28128a771f Mon Sep 17 00:00:00 2001 From: Levente Meszaros Date: Fri, 22 Mar 2024 15:14:46 +0100 Subject: [PATCH] Ipv4NetworkConfigurator: Extended static multicast routes with an additional route for the leaf nodes with no output interfaces. This prevents packets being reported as dropped because no route is found even though the packets are delivered locally. --- .../ipv4/Ipv4NetworkConfigurator.cc | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.cc b/src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.cc index 533679a8bd6..d36b8079ec9 100644 --- a/src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.cc +++ b/src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.cc @@ -1933,13 +1933,11 @@ void Ipv4NetworkConfigurator::addStaticMulticastRoutes(Topology& topology, Node InterfaceInfo *inInterfaceInfo = nullptr; InterfaceInfo *outInterfaceInfo = nullptr; Node *node = receiverNode; - while (node != sourceNode && node->getNumPaths() > 0) { + while (true) { auto link = (Link *)node->getPath(0); - outInterfaceInfo = static_cast(link->destinationInterfaceInfo); - node = (Node *)link->getLinkOutRemoteNode(); - inInterfaceInfo = node == sourceNode ? nullptr : static_cast(((Link *)node->getPath(0))->sourceInterfaceInfo); + inInterfaceInfo = node == sourceNode ? nullptr : static_cast(link->sourceInterfaceInfo); ASSERT(inInterfaceInfo == nullptr || inInterfaceInfo->node == node); - ASSERT(outInterfaceInfo->node == node); + ASSERT(outInterfaceInfo == nullptr || outInterfaceInfo->node == node); Ipv4Address origin = Ipv4Address::UNSPECIFIED_ADDRESS; Ipv4Address originNetmask = Ipv4Address::UNSPECIFIED_ADDRESS; @@ -1973,15 +1971,25 @@ void Ipv4NetworkConfigurator::addStaticMulticastRoutes(Topology& topology, Node node->staticMulticastRoutes.push_back(route); } - bool foundOutInterface = false; - for (unsigned int i = 0; i < route->getNumOutInterfaces(); i++) - if (route->getOutInterface(i)->getInterface() == outInterfaceInfo->networkInterface) { - foundOutInterface = true; - break; + if (outInterfaceInfo != nullptr) { + bool foundOutInterface = false; + for (unsigned int i = 0; i < route->getNumOutInterfaces(); i++) { + if (route->getOutInterface(i)->getInterface() == outInterfaceInfo->networkInterface) { + foundOutInterface = true; + break; + } + } + if (!foundOutInterface) { + route->addOutInterface(new Ipv4MulticastRoute::OutInterface(outInterfaceInfo->networkInterface, false /*TODOisLeaf*/)); + EV_INFO << "Extending static multicast route " << *route << " in " << node->module->getFullPath() << endl; } - if (!foundOutInterface) { - route->addOutInterface(new Ipv4MulticastRoute::OutInterface(outInterfaceInfo->networkInterface, false /*TODOisLeaf*/)); - EV_INFO << "Extending static multicast route " << *route << " in " << node->module->getFullPath() << endl; + } + + if (node == sourceNode || node->getNumPaths() == 0) + break; + else { + outInterfaceInfo = static_cast(link->destinationInterfaceInfo); + node = (Node *)link->getLinkOutRemoteNode(); } } }