Skip to content

Commit b0dce55

Browse files
avargaadamgeorge309
authored andcommitted
L2NodeConfigurator: conditionally add protocol data based on hasStp/hasMrp parameters
Add hasStp and hasMrp boolean parameters to L2NodeConfigurator. Only add Ieee8021dInterfaceData when hasStp is true, and only add MrpInterfaceData when hasMrp is true. Previously, both were added unconditionally, causing MrpInterfaceData to appear on interfaces even when MRP was not active. EthernetSwitch passes its hasStp/hasMrp parameters through to L2NodeConfigurator. L2NetworkConfigurator::configureInterface() now gracefully handles the case when Ieee8021dInterfaceData is absent.
1 parent 635e7d1 commit b0dce55

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/inet/linklayer/configurator/common/L2NetworkConfigurator.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ void L2NetworkConfigurator::configureInterface(NetworkInterface *networkInterfac
256256
void L2NetworkConfigurator::configureInterface(InterfaceInfo *interfaceInfo)
257257
{
258258
NetworkInterface *networkInterface = interfaceInfo->networkInterface;
259-
auto interfaceData = networkInterface->getProtocolDataForUpdate<Ieee8021dInterfaceData>();
259+
auto interfaceData = networkInterface->findProtocolDataForUpdate<Ieee8021dInterfaceData>();
260+
if (!interfaceData)
261+
return;
260262

261263
interfaceData->setLinkCost(interfaceInfo->portData.linkCost);
262264
interfaceData->setPriority(interfaceInfo->portData.priority);

src/inet/linklayer/configurator/common/L2NodeConfigurator.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ void L2NodeConfigurator::prepareNode()
6060

6161
void L2NodeConfigurator::prepareInterface(NetworkInterface *networkInterface)
6262
{
63-
// ASSERT(!networkInterface->getProtocolData<Ieee8021dInterfaceData>());
64-
networkInterface->addProtocolData<Ieee8021dInterfaceData>();
63+
if (par("hasStp"))
64+
networkInterface->addProtocolData<Ieee8021dInterfaceData>();
6565
#ifdef INET_WITH_MRP
66-
networkInterface->addProtocolData<MrpInterfaceData>();
66+
if (par("hasMrp"))
67+
networkInterface->addProtocolData<MrpInterfaceData>();
6768
#endif
6869
}
6970

src/inet/linklayer/configurator/common/L2NodeConfigurator.ned

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ simple L2NodeConfigurator extends SimpleModule like IL2NodeConfigurator
3131
parameters:
3232
@class(L2NodeConfigurator);
3333
@display("i=block/cogwheel");
34+
bool hasStp = default(false);
35+
bool hasMrp = default(false);
3436
string interfaceTableModule;
3537
string l2ConfiguratorModule = default("l2NetworkConfigurator"); // The absolute path to the ~L2NetworkConfigurator; use "" if there is no configurator
3638
}

src/inet/node/ethernet/EthernetSwitch.ned

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ module EthernetSwitch like IEthernetNetworkNode
8787
}
8888
l2NodeConfigurator: <default("L2NodeConfigurator")> like IL2NodeConfigurator if hasStp || hasMrp {
8989
@display("p=100,300;is=s");
90+
hasStp = parent.hasStp;
91+
hasMrp = parent.hasMrp;
9092
}
9193
status: NodeStatus if hasStatus {
9294
@display("p=100,400;is=s");

0 commit comments

Comments
 (0)