Skip to content

Commit acd32bd

Browse files
committed
configurator: add addRemoteRoutes and addManualRoutes parameters
Give the IPv4 and IPv6 network configurators finer-grained control over which routes they install, so a routing protocol can be tested with each router knowing only its directly-connected subnets and learning every remote subnet from the protocol (otherwise the configurator's precomputed shortest-path routes mask the protocol; for BGP they make decisionProcess discard the learned route because a route to the destination already exists). - addRemoteRoutes (default true): when false, do not add the multi-hop shortest-path routes (those that have a gateway / next hop). This is the mirror image of the existing addDirectRoutes filter, which drops the on-link (gateway-less) routes. Used only when addStaticRoutes is true. - addManualRoutes (default true): when false, skip the manual <route> entries in the XML configuration. Independent of addStaticRoutes: manual routes are still applied regardless of the master switch, as before. All new parameters default to true, so existing behavior is unchanged.
1 parent 6666190 commit acd32bd

6 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ void Ipv4NetworkConfigurator::initialize(int stage)
6464
addSubnetRoutesParameter = par("addSubnetRoutes");
6565
addDefaultRoutesParameter = par("addDefaultRoutes");
6666
addDirectRoutesParameter = par("addDirectRoutes");
67+
addRemoteRoutesParameter = par("addRemoteRoutes");
6768
optimizeRoutesParameter = par("optimizeRoutes");
69+
addManualRoutesParameter = par("addManualRoutes");
6870
updateRoutesParameter = par("updateRoutes");
6971
}
7072
else if (stage == INITSTAGE_NETWORK_CONFIGURATION) {
@@ -91,7 +93,9 @@ void Ipv4NetworkConfigurator::computeConfiguration()
9193
// read and configure multicast groups from the XML configuration
9294
TIME(readMulticastGroupConfiguration(topology));
9395
// read and configure manual routes from the XML configuration
94-
readManualRouteConfiguration(topology);
96+
// (independent of addStaticRoutes)
97+
if (addManualRoutesParameter)
98+
readManualRouteConfiguration(topology);
9599
// read and configure manual multicast routes from the XML configuration
96100
readManualMulticastRouteConfiguration(topology);
97101
// calculate shortest paths, and add corresponding static routes
@@ -1583,6 +1587,8 @@ void Ipv4NetworkConfigurator::addStaticRoutes(Topology& topology, cXMLElement *a
15831587
delete route;
15841588
else if (!addDirectRoutesParameter && route->getGateway().isUnspecified())
15851589
delete route;
1590+
else if (!addRemoteRoutesParameter && !route->getGateway().isUnspecified())
1591+
delete route;
15861592
else {
15871593
sourceNode->staticRoutes.push_back(route);
15881594
sourceNode->routingTableNetworkInterfaces.push_back(route->getInterface());

src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class INET_API Ipv4NetworkConfigurator : public L3NetworkConfiguratorBase, publi
121121
bool addSubnetRoutesParameter = false;
122122
bool addDefaultRoutesParameter = false;
123123
bool addDirectRoutesParameter = false;
124+
bool addRemoteRoutesParameter = false;
124125
bool optimizeRoutesParameter = false;
126+
bool addManualRoutesParameter = false;
125127
bool updateRoutesParameter = false;
126128

127129
// internal state

src/inet/networklayer/configurator/ipv4/Ipv4NetworkConfigurator.ned

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ simple Ipv4NetworkConfigurator extends L3NetworkConfiguratorBase
413413
bool addDefaultRoutes = default(true); // Add default routes if all routes from a source node go through the same gateway (used only if addStaticRoutes is true)
414414
bool addSubnetRoutes = default(true); // Add subnet routes instead of destination interface routes (only where applicable; used only if addStaticRoutes is true)
415415
bool addDirectRoutes = default(true); // Add direct routes towards local network members (i.e. directly connected interfaces) to the routing table (used only if addStaticRoutes is true)
416+
bool addRemoteRoutes = default(true); // Add routes towards remote (non-directly-connected) destinations via a gateway (used only if addStaticRoutes is true)
416417
bool optimizeRoutes = default(true); // Optimize routing tables by merging routes, the resulting routing table might route more packets than the original (used only if addStaticRoutes is true)
418+
bool addManualRoutes = default(true); // Add manual routes from the XML configuration; independent of addStaticRoutes
417419
bool updateRoutes = default(false); // Recalculate static routes if an interface goes down/up or a carrier is lost/back
418420
bool dumpTopology = default(false); // Print extracted network topology to the module output
419421
bool dumpLinks = default(false); // Print recognized network links to the module output

src/inet/networklayer/configurator/ipv6/Ipv6NetworkConfigurator.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ void Ipv6NetworkConfigurator::initialize(int stage)
3636
addStaticRoutesParameter = par("addStaticRoutes");
3737
addDefaultRoutesParameter = par("addDefaultRoutes");
3838
addDirectRoutesParameter = par("addDirectRoutes");
39+
addRemoteRoutesParameter = par("addRemoteRoutes");
40+
addManualRoutesParameter = par("addManualRoutes");
3941
}
4042
else if (stage == INITSTAGE_NETWORK_CONFIGURATION) {
4143
ensureConfigurationComputed(topology);
@@ -57,7 +59,9 @@ void Ipv6NetworkConfigurator::computeConfiguration()
5759
if (assignAddressesParameter)
5860
TIME(assignAddresses(topology));
5961
// read and configure manual routes from the XML configuration
60-
readManualRouteConfiguration(topology);
62+
// (independent of addStaticRoutes)
63+
if (addManualRoutesParameter)
64+
readManualRouteConfiguration(topology);
6165
// read and configure manual multicast routes from the XML configuration
6266
readManualMulticastRouteConfiguration(topology);
6367
// calculate shortest paths, and add corresponding static routes
@@ -1037,6 +1041,9 @@ void Ipv6NetworkConfigurator::addStaticRoutes(Topology& topology, cXMLElement *a
10371041
// Skip direct (on-link) routes when direct routes are disabled
10381042
if (!addDirectRoutesParameter && nextHop.isUnspecified())
10391043
continue;
1044+
// Skip remote routes (via a next hop) when remote routes are disabled
1045+
if (!addRemoteRoutesParameter && !nextHop.isUnspecified())
1046+
continue;
10401047

10411048
// Check for duplicate routes
10421049
bool duplicate = false;

src/inet/networklayer/configurator/ipv6/Ipv6NetworkConfigurator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class INET_API Ipv6NetworkConfigurator : public L3NetworkConfiguratorBase, publi
8686
bool addStaticRoutesParameter = false;
8787
bool addDefaultRoutesParameter = false;
8888
bool addDirectRoutesParameter = false;
89+
bool addRemoteRoutesParameter = false;
90+
bool addManualRoutesParameter = false;
8991

9092
// internal state
9193
Topology topology;

src/inet/networklayer/configurator/ipv6/Ipv6NetworkConfigurator.ned

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ simple Ipv6NetworkConfigurator extends L3NetworkConfiguratorBase
106106
bool assignAddressesToHosts = default(true); // If true, statically assign global addresses to host (non-router) interfaces too. If false, configure only router interfaces and their advertised prefixes, leaving hosts to obtain addresses through DYNAMIC configuration; which dynamic method is used is selected by the usual mechanisms (router AdvAutonomousFlag for SLAAC; the Managed/Other-config RA flags plus a DHCPv6 server for DHCPv6), not by this parameter. Set to false for mobile nodes (MIPv6), whose home/care-of addresses must be autoconfigured. Routers always get static addresses regardless of this setting.
107107
bool addStaticRoutes = default(true); // Add static routes to all routing tables
108108
bool addDefaultRoutes = default(true); // Add default routes if all routes from a source go through the same gateway
109-
bool addDirectRoutes = default(true); // Add direct routes (on-link prefix routes) for local network members
109+
bool addDirectRoutes = default(true); // Add direct routes (on-link prefix routes) for local network members (used only if addStaticRoutes is true)
110+
bool addRemoteRoutes = default(true); // Add routes towards remote (non-on-link) destinations via a next hop (used only if addStaticRoutes is true)
111+
bool addManualRoutes = default(true); // Add manual routes from the XML configuration; independent of addStaticRoutes
110112
bool dumpTopology = default(false); // Print extracted network topology
111113
bool dumpLinks = default(false); // Print recognized network links
112114
bool dumpAddresses = default(false); // Print assigned IPv6 addresses for all interfaces

0 commit comments

Comments
 (0)