From 71cda229ffe16d68801af26eb55e85cf5bd41f1b Mon Sep 17 00:00:00 2001 From: Claudio-Daniel Freire <claudio-daniel.freire@inria.fr> Date: Mon, 23 May 2011 17:40:07 +0200 Subject: [PATCH] Routing fixes in ns3: consider point-to-point patterns when figuring out nexthop/interface associations: 192.168.2.2/32 -> iface 10 192.168.3.0/24 -> 192.168.2.2 --- src/nepi/testbeds/ns3/execute.py | 2 ++ .../ns3/factories_metadata_v3_9_RC3.py | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/nepi/testbeds/ns3/execute.py b/src/nepi/testbeds/ns3/execute.py index 8b1d6b3c..ab34f25e 100644 --- a/src/nepi/testbeds/ns3/execute.py +++ b/src/nepi/testbeds/ns3/execute.py @@ -124,6 +124,8 @@ class TestbedController(testbed_impl.TestbedController): # graceful shutdown of locally-implemented objects element.Cleanup() element = None + sys.stdout.flush() + sys.stderr.flush() def _simulator_run(self, condition): # Run simulation diff --git a/src/nepi/testbeds/ns3/factories_metadata_v3_9_RC3.py b/src/nepi/testbeds/ns3/factories_metadata_v3_9_RC3.py index 0980ea0b..febb5c45 100644 --- a/src/nepi/testbeds/ns3/factories_metadata_v3_9_RC3.py +++ b/src/nepi/testbeds/ns3/factories_metadata_v3_9_RC3.py @@ -475,20 +475,40 @@ def configure_node(testbed_instance, guid): ifindex = -1 # TODO: HACKISH way of getting the ifindex... improve this nifaces = ipv4.GetNInterfaces() - for ifidx in range(nifaces): + for ifidx in xrange(nifaces): iface = ipv4.GetInterface(ifidx) naddress = iface.GetNAddresses() - for addridx in range(naddress): + for addridx in xrange(naddress): ifaddr = iface.GetAddress(addridx) ifmask = ifaddr.GetMask() ifindex = ipv4.GetInterfaceForPrefix(nexthop_address, ifmask) if ifindex == ifidx: break + if ifindex < 0: + # Check previous ptp routes + for chaindest, chainprefix, chainhop in routes: + if chaindest == nexthop and chainprefix == 32: + chainhop_address = ns3.Ipv4Address(chainhop) + for ifidx in xrange(nifaces): + iface = ipv4.GetInterface(ifidx) + naddress = iface.GetNAddresses() + for addridx in xrange(naddress): + ifaddr = iface.GetAddress(addridx) + ifmask = ifaddr.GetMask() + ifindex = ipv4.GetInterfaceForPrefix(chainhop_address, ifmask) + if ifindex == ifidx: + break + if ifindex < 0: + raise RuntimeError, "Cannot associate interface for routing entry:" \ + "%s/%s -> %s. At node %s" % (destination, netprefix, nexthop, guid) _add_static_route(ns3, static_routing, address, netprefix, nexthop_address, ifindex) else: mask = ns3.Ipv4Mask("/%d" % netprefix) ifindex = ipv4.GetInterfaceForPrefix(address, mask) + if ifindex < 0: + raise RuntimeError, "Cannot associate interface for routing entry:" \ + "%s/%s -> %s. At node %s" % (destination, netprefix, nexthop, guid) _add_static_route_if(ns3, static_routing, address, netprefix, nexthop_address, ifindex) -- 2.47.0