Skip to content

Commit 845b234

Browse files
committed
tests: add early interface config for topojson and fix test
- A more general fix for the bgp listener test which requires interfaces be configured in the kernel when the bgpd daemons are launched. Signed-off-by: Christian Hopps <chopps@labn.net>
1 parent 0090895 commit 845b234

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/topotests/bgp_listen_on_multiple_addresses/test_bgp_listen_on_multiple_addresses.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
from lib.topogen import Topogen, get_topogen
5252
from lib.topojson import build_topo_from_json, build_config_from_json
53+
from lib.topojson import linux_intf_config_from_json
5354
from lib.common_config import start_topology
5455
from lib.topotest import router_json_cmp, run_and_expect
5556
from mininet.topo import Topo
@@ -96,6 +97,9 @@ def setup_module(mod):
9697
)
9798

9899
start_topology(tgen)
100+
101+
linux_intf_config_from_json(tgen, topo)
102+
99103
build_config_from_json(tgen, topo)
100104

101105

tests/topotests/lib/topojson.py

+18
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,24 @@ def build_topo_from_json(tgen, topo):
293293
)
294294

295295

296+
def linux_intf_config_from_json(tgen, topo):
297+
"""Configure interfaces from linux based on topo."""
298+
routers = topo["routers"]
299+
for rname in routers:
300+
router = tgen.gears[rname]
301+
links = routers[rname]["links"]
302+
for rrname in links:
303+
link = links[rrname]
304+
if rrname == "lo":
305+
lname = "lo"
306+
else:
307+
lname = link["interface"]
308+
if "ipv4" in link:
309+
router.run("ip addr add {} dev {}".format(link["ipv4"], lname))
310+
if "ipv6" in link:
311+
router.run("ip -6 addr add {} dev {}".format(link["ipv6"], lname))
312+
313+
296314
def build_config_from_json(tgen, topo, save_bkup=True):
297315
"""
298316
Reads initial configuraiton from JSON for each router, builds

0 commit comments

Comments
 (0)