From 161572bdf969ace6ae63f4383b3bfdc5db7413bf Mon Sep 17 00:00:00 2001 From: Ashish Pant Date: Thu, 12 Sep 2019 09:54:44 +0530 Subject: [PATCH 1/4] tests: Fix topojson link local ipv6 address Signed-off-by: Ashish Pant Removed code that disabled link local ipv6 address on the interface --- tests/topotests/lib/common_config.py | 70 +--------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index ba8a4cb0f4..e2f9ebda18 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -35,11 +35,7 @@ import ConfigParser import traceback import socket import ipaddr -import re -from lib import topotest - -from functools import partial from lib.topolog import logger, logger_config from lib.topogen import TopoRouter from lib.topotest import interface_set_status @@ -736,62 +732,6 @@ def retry(attempts=3, wait=2, return_is_str=True, initial_wait=0): return _retry -def disable_v6_link_local(tgen, router, intf_name=None): - """ - Disables ipv6 link local addresses for a particular interface or - all interfaces - - * `tgen`: tgen onject - * `router` : router for which hightest interface should be - calculated - * `intf_name` : Interface name for which v6 link local needs to - be disabled - """ - - router_list = tgen.routers() - for rname, rnode in router_list.iteritems(): - if rname != router: - continue - - linklocal = [] - - ifaces = router_list[router].run('ip -6 address') - - # Fix newlines (make them all the same) - ifaces = ('\n'.join(ifaces.splitlines()) + '\n').splitlines() - - interface = None - ll_per_if_count = 0 - for line in ifaces: - # Interface name - m = re.search('[0-9]+: ([^:]+)[@if0-9:]+ <', line) - if m: - interface = m.group(1).split("@")[0] - ll_per_if_count = 0 - - # Interface ip - m = re.search('inet6 (fe80::[0-9a-f]+:[0-9a-f]+:[0-9a-f]+' - ':[0-9a-f]+[/0-9]*) scope link', line) - if m: - local = m.group(1) - ll_per_if_count += 1 - if ll_per_if_count > 1: - linklocal += [["%s-%s" % (interface, ll_per_if_count), local]] - else: - linklocal += [[interface, local]] - - if len(linklocal[0]) > 1: - link_local_dict = {item[0]: item[1] for item in linklocal} - - for lname, laddr in link_local_dict.items(): - - if intf_name is not None and lname != intf_name: - continue - - cmd = "ip addr del {} dev {}".format(laddr, lname) - router_list[router].run(cmd) - - ############################################# # These APIs, will used by testcase ############################################# @@ -821,8 +761,6 @@ def create_interfaces_cfg(tgen, topo, build=False): interface_name = destRouterLink else: interface_name = data["interface"] - if "ipv6" in data: - disable_v6_link_local(tgen, c_router, interface_name) interface_data.append("interface {}".format( str(interface_name) )) @@ -1569,19 +1507,13 @@ def shutdown_bringup_interface(tgen, dut, intf_name, ifaceaction=False): errormsg(str) or True """ - from topotest import interface_set_status router_list = tgen.routers() if ifaceaction: logger.info("Bringing up interface : {}".format(intf_name)) else: logger.info("Shutting down interface : {}".format(intf_name)) - interface_set_status(router_list[dut], intf_name, - ifaceaction) - - if ifaceaction: - # Disabling v6 link local once interfac comes up back - disable_v6_link_local(tgen, dut, intf_name=intf_name) + interface_set_status(router_list[dut], intf_name, ifaceaction) ############################################# From 915bed88d83fa960c85e8f9ff8468438bc7c00d5 Mon Sep 17 00:00:00 2001 From: Ashish Pant Date: Thu, 12 Sep 2019 10:00:00 +0530 Subject: [PATCH 2/4] tests: Add topojson route-map for nexthop Signed-off-by: Ashish Pant Add route-map option for ipv6 nexthop Fix typo in bgp configuration --- tests/topotests/lib/bgp.py | 4 ++-- tests/topotests/lib/common_config.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index bfc34c25e4..41d6a326cf 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -445,10 +445,10 @@ def __create_bgp_unicast_address_family(topo, input_dict, router, addr_type, bgp_data = input_dict[router]["bgp"]["address_family"] neigh_data = bgp_data[addr_type]["unicast"]["neighbor"] - for name, peer_dict in deepcopy(neigh_data).iteritems(): + for peer_name, peer_dict in deepcopy(neigh_data).iteritems(): for dest_link, peer in peer_dict["dest_link"].iteritems(): deactivate = None - nh_details = topo[name] + nh_details = topo[peer_name] # Loopback interface if "source_link" in peer and peer["source_link"] == "lo": for destRouterLink, data in sorted(nh_details["links"]. diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index e2f9ebda18..c413bf45c7 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -1240,13 +1240,15 @@ def create_route_maps(tgen, input_dict, build=False): # Weight if weight: - rmap_data.append("set weight {} \n".format( + rmap_data.append("set weight {}".format( weight)) if ipv6_data: - nexthop = ipv6_data.setdefault("nexthop",None) + nexthop = ipv6_data.setdefault("nexthop", None) if nexthop: - rmap_data.append("set ipv6 next-hop \ - {}".format(nexthop)) + rmap_data.append("set ipv6 next-hop {}".format( + nexthop + )) + # Adding MATCH and SET sequence to RMAP if defined if "match" in rmap_dict: match_data = rmap_dict["match"] From 6ade2c18fb18655869f0ab13dac0557fee61da35 Mon Sep 17 00:00:00 2001 From: Ashish Pant Date: Thu, 12 Sep 2019 10:11:59 +0530 Subject: [PATCH 3/4] tests: Modify json for bgp-ecmp-topo2 Signed-off-by: Ashish Pant Modified json files to configure route-map which prefer global address --- .../bgp-ecmp-topo2/ebgp_ecmp_topo2.json | 234 +++++++++++++++--- .../bgp-ecmp-topo2/ibgp_ecmp_topo2.json | 234 +++++++++++++++--- 2 files changed, 404 insertions(+), 64 deletions(-) diff --git a/tests/topotests/bgp-ecmp-topo2/ebgp_ecmp_topo2.json b/tests/topotests/bgp-ecmp-topo2/ebgp_ecmp_topo2.json index 50797f130a..34f11c0a29 100755 --- a/tests/topotests/bgp-ecmp-topo2/ebgp_ecmp_topo2.json +++ b/tests/topotests/bgp-ecmp-topo2/ebgp_ecmp_topo2.json @@ -564,6 +564,16 @@ "ipv6": "auto" } }, + "route_maps": { + "rmap_global": [{ + "action": "permit", + "set": { + "ipv6": { + "nexthop": "prefer-global" + } + } + }] + }, "bgp": { "local_as": "300", "address_family": { @@ -620,38 +630,198 @@ "neighbor": { "r2": { "dest_link": { - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {}, - "r3-link8": {}, - "r3-link9": {}, - "r3-link10": {}, - "r3-link11": {}, - "r3-link12": {}, - "r3-link13": {}, - "r3-link14": {}, - "r3-link15": {}, - "r3-link16": {}, - "r3-link17": {}, - "r3-link18": {}, - "r3-link19": {}, - "r3-link20": {}, - "r3-link21": {}, - "r3-link22": {}, - "r3-link23": {}, - "r3-link24": {}, - "r3-link25": {}, - "r3-link26": {}, - "r3-link27": {}, - "r3-link28": {}, - "r3-link29": {}, - "r3-link30": {}, - "r3-link31": {}, - "r3-link32": {} + "r3-link1": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link2": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link3": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link4": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link5": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link6": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link7": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link8": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link9": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link10": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link11": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link12": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link13": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link14": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link15": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link16": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link17": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link18": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link19": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link20": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link21": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link22": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link23": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link24": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link25": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link26": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link27": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link28": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link29": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link30": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link31": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link32": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + } } } } diff --git a/tests/topotests/bgp-ecmp-topo2/ibgp_ecmp_topo2.json b/tests/topotests/bgp-ecmp-topo2/ibgp_ecmp_topo2.json index 9010b8c273..9eea9073c7 100755 --- a/tests/topotests/bgp-ecmp-topo2/ibgp_ecmp_topo2.json +++ b/tests/topotests/bgp-ecmp-topo2/ibgp_ecmp_topo2.json @@ -574,6 +574,16 @@ "ipv6": "auto" } }, + "route_maps": { + "rmap_global": [{ + "action": "permit", + "set": { + "ipv6": { + "nexthop": "prefer-global" + } + } + }] + }, "bgp": { "local_as": "100", "address_family": { @@ -630,38 +640,198 @@ "neighbor": { "r2": { "dest_link": { - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {}, - "r3-link8": {}, - "r3-link9": {}, - "r3-link10": {}, - "r3-link11": {}, - "r3-link12": {}, - "r3-link13": {}, - "r3-link14": {}, - "r3-link15": {}, - "r3-link16": {}, - "r3-link17": {}, - "r3-link18": {}, - "r3-link19": {}, - "r3-link20": {}, - "r3-link21": {}, - "r3-link22": {}, - "r3-link23": {}, - "r3-link24": {}, - "r3-link25": {}, - "r3-link26": {}, - "r3-link27": {}, - "r3-link28": {}, - "r3-link29": {}, - "r3-link30": {}, - "r3-link31": {}, - "r3-link32": {} + "r3-link1": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link2": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link3": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link4": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link5": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link6": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link7": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link8": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link9": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link10": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link11": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link12": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link13": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link14": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link15": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link16": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link17": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link18": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link19": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link20": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link21": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link22": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link23": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link24": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link25": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link26": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link27": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link28": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link29": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link30": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link31": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + }, + "r3-link32": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + } } } } From 819f9825900511e5db6ed4163e0a07cbe80aff37 Mon Sep 17 00:00:00 2001 From: Ashish Pant Date: Tue, 24 Sep 2019 10:20:08 +0530 Subject: [PATCH 4/4] tests: Enabling bgp-ecmp-topo2 test cases Signed-off-by: Ashish Pant --- tests/topotests/pytest.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/topotests/pytest.ini b/tests/topotests/pytest.ini index b65f93856f..ade5bfd501 100644 --- a/tests/topotests/pytest.ini +++ b/tests/topotests/pytest.ini @@ -1,6 +1,6 @@ # Skip pytests example directory [pytest] -norecursedirs = .git example-test example-topojson-test lib docker bgp-ecmp-topo2 +norecursedirs = .git example-test example-topojson-test lib docker [topogen] # Default configuration values