]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: uniq vrf names when using netns
authorChristian Hopps <chopps@labn.net>
Sat, 21 Aug 2021 07:04:42 +0000 (03:04 -0400)
committerChristian Hopps <chopps@labn.net>
Sat, 21 Aug 2021 10:13:52 +0000 (06:13 -0400)
- In order to run tests in parallel the netns-based vrfs need to
have unique names primarily bc they are all tracked/looked-up in
`/run/netns` which is not network namespace nesting friendly

- use ip(8) exclusively rather than a mix of `ip` and `ifconfig`
and `vconfig`, reducing required pkg count by a couple.

Signed-off-by: Christian Hopps <chopps@labn.net>
44 files changed:
tests/topotests/bfd_vrf_topo1/r1/bfdd.conf
tests/topotests/bfd_vrf_topo1/r1/bgpd.conf
tests/topotests/bfd_vrf_topo1/r1/zebra.conf
tests/topotests/bfd_vrf_topo1/r2/bfdd.conf
tests/topotests/bfd_vrf_topo1/r2/bgpd.conf
tests/topotests/bfd_vrf_topo1/r2/zebra.conf
tests/topotests/bfd_vrf_topo1/r3/bfdd.conf
tests/topotests/bfd_vrf_topo1/r3/bgpd.conf
tests/topotests/bfd_vrf_topo1/r3/zebra.conf
tests/topotests/bfd_vrf_topo1/r4/bfdd.conf
tests/topotests/bfd_vrf_topo1/r4/bgpd.conf
tests/topotests/bfd_vrf_topo1/r4/zebra.conf
tests/topotests/bfd_vrf_topo1/test_bfd_vrf_topo1.py
tests/topotests/bgp_multi_vrf_topo1/test_bgp_multi_vrf_topo1.py
tests/topotests/bgp_multi_vrf_topo2/test_bgp_multi_vrf_topo2.py
tests/topotests/bgp_recursive_route_ebgp_multi_hop/test_bgp_recursive_route_ebgp_multi_hop.py
tests/topotests/bgp_vrf_dynamic_route_leak/test_bgp_vrf_dynamic_route_leak_topo1.py
tests/topotests/bgp_vrf_netns/r1/bgpd.conf
tests/topotests/bgp_vrf_netns/r1/summary.txt
tests/topotests/bgp_vrf_netns/r1/summary20.txt
tests/topotests/bgp_vrf_netns/r1/zebra.conf
tests/topotests/bgp_vrf_netns/test_bgp_vrf_netns_topo.py
tests/topotests/lib/common_config.py
tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py
tests/topotests/ospf_basic_functionality/test_ospf_single_area.py
tests/topotests/ospf_topo1_vrf/r1/ospfd.conf
tests/topotests/ospf_topo1_vrf/r1/ospfroute.txt
tests/topotests/ospf_topo1_vrf/r1/ospfroute_down.txt
tests/topotests/ospf_topo1_vrf/r1/zebra.conf
tests/topotests/ospf_topo1_vrf/r1/zebraroute.txt
tests/topotests/ospf_topo1_vrf/r1/zebraroutedown.txt
tests/topotests/ospf_topo1_vrf/r2/ospfd.conf
tests/topotests/ospf_topo1_vrf/r2/ospfroute.txt
tests/topotests/ospf_topo1_vrf/r2/ospfroute_down.txt
tests/topotests/ospf_topo1_vrf/r2/zebra.conf
tests/topotests/ospf_topo1_vrf/r2/zebraroute.txt
tests/topotests/ospf_topo1_vrf/r2/zebraroutedown.txt
tests/topotests/ospf_topo1_vrf/r3/ospfd.conf
tests/topotests/ospf_topo1_vrf/r3/ospfroute.txt
tests/topotests/ospf_topo1_vrf/r3/ospfroute_down.txt
tests/topotests/ospf_topo1_vrf/r3/zebra.conf
tests/topotests/ospf_topo1_vrf/r3/zebraroute.txt
tests/topotests/ospf_topo1_vrf/r3/zebraroutedown.txt
tests/topotests/ospf_topo1_vrf/test_ospf_topo1_vrf.py

index 5e736a7fcc26244391e81c07be2b87627b076d8a..fd57b2c4d53a6cc9b12693f59386e7cd57e51a91 100644 (file)
@@ -4,7 +4,7 @@ debug bfd peer
 debug bfd zebra
 !
 bfd
- peer 192.168.0.2 vrf r1-cust1
+ peer 192.168.0.2 vrf r1-bfd-cust1
   echo-mode
   no shutdown
  !
index 5bb45b9863cb749d9689c46de362fe60a8ad8ae3..cf72f30d661fa639183772ca5246a9296debdde1 100644 (file)
@@ -1,4 +1,4 @@
-router bgp 101 vrf r1-cust1
+router bgp 101 vrf r1-bfd-cust1
  no bgp ebgp-requires-policy
  no bgp network import-check
  neighbor 192.168.0.2 remote-as 102
index fcd1e7db17762a02cb24f67bd8dbe4377be2a9b6..62ed36fdb8b5549f78ebdd4f17d10e5137c5240b 100644 (file)
@@ -1,3 +1,3 @@
-interface r1-eth0 vrf r1-cust1
+interface r1-eth0 vrf r1-bfd-cust1
  ip address 192.168.0.1/24
 !
index 94f502c7d9ddb61f5dc9851d910ad2ffbed14d19..e5539f14e5c7e2fa6b6e7c723d2f9e6f7c50e66e 100644 (file)
@@ -4,13 +4,13 @@ debug bfd peer
 debug bfd zebra
 !
 bfd
- peer 192.168.0.1 vrf r2-cust1
+ peer 192.168.0.1 vrf r2-bfd-cust1
   receive-interval 1000
   transmit-interval 500
   echo-mode
   no shutdown
  !
- peer 192.168.1.1 vrf r2-cust1
+ peer 192.168.1.1 vrf r2-bfd-cust1
   echo-mode
   no shutdown
  !
index b2aac74685d4612407cc333ac2c52a78788c27e1..132011cf869ab6214ed00ec4262007bf45c04b05 100644 (file)
@@ -1,4 +1,4 @@
-router bgp 102 vrf r2-cust1
+router bgp 102 vrf r2-bfd-cust1
  no bgp ebgp-requires-policy
  no bgp network import-check
  neighbor 192.168.0.1 remote-as 101
index daffd1912e82cc757c7c1ad0bb3ab9a37662d449..1e817b19f6c8b70c972b7fa54e88e7180189dc4c 100644 (file)
@@ -1,9 +1,9 @@
-interface r2-eth0 vrf r2-cust1
+interface r2-eth0 vrf r2-bfd-cust1
  ip address 192.168.0.2/24
 !
-interface r2-eth1 vrf r2-cust1
+interface r2-eth1 vrf r2-bfd-cust1
  ip address 192.168.1.2/24
 !
-interface r2-eth2 vrf r2-cust1
+interface r2-eth2 vrf r2-bfd-cust1
  ip address 192.168.2.2/24
 !
index 76910ac927782a53d6954302b80d7f78637919df..e1f53e1abc66bd64532879c0c83725b56004a3da 100644 (file)
@@ -4,7 +4,7 @@ debug bfd peer
 debug bfd zebra
 !
 bfd
- peer 192.168.1.2 vrf r3-cust1
+ peer 192.168.1.2 vrf r3-bfd-cust1
   echo-interval 100
   echo-mode
   no shutdown
index 1d7c7303952a4a5aca356efd48e7d76814d51873..f7646479205bebaf679c2a0fcd430e1852ee2cf5 100644 (file)
@@ -1,4 +1,4 @@
-router bgp 103 vrf r3-cust1
+router bgp 103 vrf r3-bfd-cust1
  no bgp ebgp-requires-policy
  no bgp network import-check
  neighbor 192.168.1.2 remote-as 102
index f727c2d633c11b57e11e60a0e4ece6ea3bc15966..e67345948eeb465aaee818a3ab248475a1dd377d 100644 (file)
@@ -1,3 +1,3 @@
-interface r3-eth0 vrf r3-cust1
+interface r3-eth0 vrf r3-bfd-cust1
  ip address 192.168.1.1/24
 !
index 63d0da7805fdeb664d2db0a323aa087b2e71ac09..9ef2023b21e79154614f4f92bfc4c8af29af9256 100644 (file)
@@ -4,7 +4,7 @@ debug bfd peer
 debug bfd zebra
 !
 bfd
- peer 192.168.2.2 vrf r4-cust1
+ peer 192.168.2.2 vrf r4-bfd-cust1
   transmit-interval 2000
   receive-interval 2000
   no shutdown
index f34035d460fa13348692add6203e879f27b38744..03353e45e31bdd558dd1f1519be93fbf312911e0 100644 (file)
@@ -1,4 +1,4 @@
-router bgp 104 vrf r4-cust1
+router bgp 104 vrf r4-bfd-cust1
  no bgp ebgp-requires-policy
  no bgp network import-check
  neighbor 192.168.2.2 remote-as 102
index 69770dd2bf79f5c9237473d0066fe9ab3f9077a5..15d3ec1d9064c20165cbae07bdc558253f29aba9 100644 (file)
@@ -1,3 +1,3 @@
-interface r4-eth0 vrf r4-cust1
+interface r4-eth0 vrf r4-bfd-cust1
  ip address 192.168.2.1/24
 !
index 8a1ffe085d9cd5038c635866ba45d98e946e2be3..a342997912b9bfb3dd9312b548aebb190f46c950 100644 (file)
@@ -95,20 +95,18 @@ def setup_module(mod):
     logger.info("Testing with VRF Namespace support")
 
     cmds = [
-        "if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi",
-        "ip netns add {0}-cust1",
-        "ip link set dev {0}-eth0 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
+        "if [ -e /var/run/netns/{0}-bfd-cust1 ] ; then ip netns del {0}-bfd-cust1 ; fi",
+        "ip netns add {0}-bfd-cust1",
+        "ip link set dev {0}-eth0 netns {0}-bfd-cust1 up",
     ]
     cmds2 = [
-        "ip link set dev {0}-eth1 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth1 up",
-        "ip link set dev {0}-eth2 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth2 up",
+        "ip link set dev {0}-eth1 netns {0}-bfd-cust1",
+        "ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 up",
+        "ip link set dev {0}-eth2 netns {0}-bfd-cust1 up",
     ]
 
     for rname, router in router_list.items():
-        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
+        # create VRF rx-bfd-cust1 and link rx-eth0 to rx-bfd-cust1
         for cmd in cmds:
             output = tgen.net[rname].cmd(cmd.format(rname))
         if rname == "r2":
@@ -138,11 +136,11 @@ def teardown_module(_mod):
     # move back rx-eth0 to default VRF
     # delete rx-vrf
     cmds = [
-        "ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1",
-        "ip netns delete {0}-cust1",
+        "ip netns exec {0}-bfd-cust1 ip link set {0}-eth0 netns 1",
+        "ip netns delete {0}-bfd-cust1",
     ]
     cmds2 = [
-        "ip netns exec {0}-cust1 ip link set {0}-eth1 netns 1",
+        "ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 netns 1",
         "ip netns exec {0}-cust2 ip link set {0}-eth1 netns 1",
     ]
 
@@ -189,7 +187,7 @@ def test_bgp_convergence():
         test_func = partial(
             topotest.router_json_cmp,
             router,
-            "show ip bgp vrf {}-cust1 summary json".format(router.name),
+            "show ip bgp vrf {}-bfd-cust1 summary json".format(router.name),
             expected,
         )
         _, res = topotest.run_and_expect(test_func, None, count=125, wait=1.0)
@@ -211,7 +209,7 @@ def test_bgp_fast_convergence():
         test_func = partial(
             topotest.router_json_cmp,
             router,
-            "show ip bgp vrf {}-cust1 json".format(router.name),
+            "show ip bgp vrf {}-bfd-cust1 json".format(router.name),
             expected,
         )
         _, res = topotest.run_and_expect(test_func, None, count=40, wait=1)
@@ -231,7 +229,7 @@ def test_bfd_fast_convergence():
     # Disable r2-eth0 link
     router2 = tgen.gears["r2"]
     topotest.interface_set_status(
-        router2, "r2-eth0", ifaceaction=False, vrf_name="r2-cust1"
+        router2, "r2-eth0", ifaceaction=False, vrf_name="r2-bfd-cust1"
     )
 
     # Wait the minimum time we can before checking that BGP/BFD
@@ -286,7 +284,7 @@ def test_bgp_fast_reconvergence():
         test_func = partial(
             topotest.router_json_cmp,
             router,
-            "show ip bgp vrf {}-cust1 json".format(router.name),
+            "show ip bgp vrf {}-bfd-cust1 json".format(router.name),
             expected,
         )
         _, res = topotest.run_and_expect(test_func, None, count=16, wait=1)
index c9a93bd75f34ea20286c6b307f563f51eeb4ddbf..84e10af5b3845e7ff65b1076613afd2bb85a23f7 100644 (file)
@@ -178,14 +178,10 @@ NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
 LOOPBACK_1 = {
     "ipv4": "10.10.10.10/32",
     "ipv6": "10::10:10/128",
-    "ipv4_mask": "255.255.255.255",
-    "ipv6_mask": None,
 }
 LOOPBACK_2 = {
     "ipv4": "20.20.20.20/32",
     "ipv6": "20::20:20/128",
-    "ipv4_mask": "255.255.255.255",
-    "ipv6_mask": None,
 }
 
 
@@ -1911,7 +1907,6 @@ def test_static_routes_for_inter_vrf_route_leaking_p0(request):
             "loopback1",
             LOOPBACK_1[addr_type],
             "RED_A",
-            LOOPBACK_1["{}_mask".format(addr_type)],
         )
         create_interface_in_kernel(
             tgen,
@@ -1919,7 +1914,6 @@ def test_static_routes_for_inter_vrf_route_leaking_p0(request):
             "loopback2",
             LOOPBACK_2[addr_type],
             "RED_B",
-            LOOPBACK_2["{}_mask".format(addr_type)],
         )
 
     step(
@@ -2047,7 +2041,6 @@ def test_inter_vrf_and_intra_vrf_communication_iBGP_p0(request):
             "loopback1",
             LOOPBACK_1[addr_type],
             "RED_A",
-            LOOPBACK_1["{}_mask".format(addr_type)],
         )
 
         create_interface_in_kernel(
@@ -2056,7 +2049,6 @@ def test_inter_vrf_and_intra_vrf_communication_iBGP_p0(request):
             "loopback2",
             LOOPBACK_2[addr_type],
             "BLUE_A",
-            LOOPBACK_2["{}_mask".format(addr_type)],
         )
 
     step(
@@ -2216,7 +2208,6 @@ def test_inter_vrf_and_intra_vrf_communication_eBGP_p0(request):
             "loopback1",
             LOOPBACK_1[addr_type],
             "RED_A",
-            LOOPBACK_1["{}_mask".format(addr_type)],
         )
         create_interface_in_kernel(
             tgen,
@@ -2224,7 +2215,6 @@ def test_inter_vrf_and_intra_vrf_communication_eBGP_p0(request):
             "loopback2",
             LOOPBACK_2[addr_type],
             "BLUE_A",
-            LOOPBACK_2["{}_mask".format(addr_type)],
         )
 
     step(
index 37da53fc31fddf247e2d5f206ddf0792214e2f53..31569e69b4b507bb1f75ca4a578f7473c038f73b 100644 (file)
@@ -131,8 +131,6 @@ NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
 LOOPBACK_2 = {
     "ipv4": "20.20.20.20/32",
     "ipv6": "20::20:20/128",
-    "ipv4_mask": "255.255.255.255",
-    "ipv6_mask": None,
 }
 
 MAX_PATHS = 2
@@ -1928,7 +1926,6 @@ def test_vrf_route_leaking_next_hop_interface_flapping_p1(request):
             "loopback2",
             LOOPBACK_2[addr_type],
             "RED_B",
-            LOOPBACK_2["{}_mask".format(addr_type)],
         )
 
     intf_red1_r11 = topo["routers"]["red1"]["links"]["r1-link2"]["interface"]
index e7d70f6d8ea4e2a618ce6a744e86100d5ad4fc89..2fe80c77f0a9f59d2e1d5790ec2d1d0c248528bc 100644 (file)
@@ -1103,7 +1103,7 @@ def test_next_hop_with_recursive_lookup_p1(request):
             tc_name, result
         )
 
-    step("Toggle the interface on R3(ifconfig 192.34).")
+    step("Toggle the interface on R3.")
 
     intf_r3_r4 = topo["routers"]["r3"]["links"]["r4"]["interface"]
     shutdown_bringup_interface(tgen, "r3", intf_r3_r4)
@@ -1161,7 +1161,7 @@ def test_next_hop_with_recursive_lookup_p1(request):
             tc_name, result
         )
 
-    step("Toggle the interface on R4(ifconfig 192.34).")
+    step("Toggle the interface on R4.")
 
     intf_r4_r3 = topo["routers"]["r4"]["links"]["r3"]["interface"]
     shutdown_bringup_interface(tgen, "r4", intf_r4_r3)
index d6f1058a982bbda3f06dd222b45302f4348d70eb..ea1b1a42d79724db93ef4603b6a16344e74a4cb5 100644 (file)
@@ -123,8 +123,6 @@ LOOPBACK_1 = {
 LOOPBACK_2 = {
     "ipv4": "10.0.0.16/24",
     "ipv6": "fd00:0:0:3::5/64",
-    "ipv4_mask": "255.255.255.0",
-    "ipv6_mask": None,
 }
 PREFERRED_NEXT_HOP = "global"
 
@@ -692,14 +690,13 @@ def test_dynamic_imported_routes_advertised_to_iBGP_peer_p0(request):
             "loopback2",
             LOOPBACK_2[addr_type],
             "ISR",
-            LOOPBACK_2["{}_mask".format(addr_type)],
         )
 
     for addr_type in ADDR_TYPES:
 
         step(
             "On router R1 Change the next-hop of static routes in vrf "
-            "ISR to LOOPBACK_1"
+            "ISR to LOOPBACK_2"
         )
 
         input_routes_r1 = {
index cfe3f2e2b5de0fc992e53af0f0506103e1c1817c..572dce74557455a7056fe427025f193ab479af47 100644 (file)
@@ -1,5 +1,5 @@
 !
-router bgp 100 vrf r1-cust1
+router bgp 100 vrf r1-bgp-cust1
  bgp router-id 10.0.1.1
  bgp bestpath as-path multipath-relax
  no bgp ebgp-requires-policy
index 1a079ff130807044161d9b4fe85cd968b905c483..819f26133fb77474af7fefd74d2333703984f662 100644 (file)
@@ -2,7 +2,7 @@
 "ipv4Unicast":{
   "routerId":"10.0.1.1",
   "as":100,
-  "vrfName":"r1-cust1",
+  "vrfName":"r1-bgp-cust1",
   "peerCount":1,
   "peers":{
     "10.0.1.101":{
index 2b5787e6dadf0e5d33c670d4aae3405bf85102f6..ea04a56d85ec5fa0a675ec158315c8e1e8472871 100644 (file)
@@ -1,7 +1,7 @@
 {
   "routerId":"10.0.1.1",
   "as":100,
-  "vrfName":"re1-cust1",
+  "vrfName":"re1-bgp-cust1",
   "peerCount":1,
   "peers":{
     "10.0.1.101":{
index 817d9544d3caa2d9d169961a5729e2df79026a21..fd0e18f5fda0baafa8a5e2085686d5ae79186bf1 100644 (file)
@@ -1,5 +1,5 @@
 !
-interface r1-eth0 vrf r1-cust1
+interface r1-eth0 vrf r1-bgp-cust1
  ip address 10.0.1.1/24
 !
 line vty
index 9889e1cdd5a501284c8cb04b9cda91f0524a1302..60511aebde75742c9842b3fb5ffabce55d936ce0 100644 (file)
@@ -106,13 +106,12 @@ def setup_module(module):
     if CustomizeVrfWithNetns == True:
         logger.info("Testing with VRF Namespace support")
 
-    # create VRF r1-cust1
-    # move r1-eth0 to VRF r1-cust1
+    # create VRF r1-bgp-cust1
+    # move r1-eth0 to VRF r1-bgp-cust1
     cmds = [
-        "if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi",
-        "ip netns add {0}-cust1",
-        "ip link set dev {0}-eth0 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
+        "if [ -e /var/run/netns/{0}-bgp-cust1 ] ; then ip netns del {0}-bgp-cust1 ; fi",
+        "ip netns add {0}-bgp-cust1",
+        "ip link set {0}-eth0 netns {0}-bgp-cust1 up",
     ]
     for cmd in cmds:
         cmd = cmd.format("r1")
@@ -154,10 +153,10 @@ def setup_module(module):
 def teardown_module(module):
     tgen = get_topogen()
     # move back r1-eth0 to default VRF
-    # delete VRF r1-cust1
+    # delete VRF r1-bgp-cust1
     cmds = [
-        "ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1",
-        "ip netns delete {0}-cust1",
+        "ip netns exec {0}-bgp-cust1 ip link set {0}-eth0 netns 1",
+        "ip netns delete {0}-bgp-cust1",
     ]
     for cmd in cmds:
         tgen.net["r1"].cmd(cmd.format("r1"))
@@ -203,7 +202,7 @@ def test_bgp_convergence():
     expected = json.loads(open(reffile).read())
 
     test_func = functools.partial(
-        topotest.router_json_cmp, router, "show bgp vrf r1-cust1 summary json", expected
+        topotest.router_json_cmp, router, "show bgp vrf r1-bgp-cust1 summary json", expected
     )
     _, res = topotest.run_and_expect(test_func, None, count=90, wait=0.5)
     assertmsg = "BGP router network did not converge"
@@ -231,11 +230,11 @@ def test_bgp_vrf_netns():
     test_func = functools.partial(
         topotest.router_json_cmp,
         tgen.gears["r1"],
-        "show ip bgp vrf r1-cust1 ipv4 json",
+        "show ip bgp vrf r1-bgp-cust1 ipv4 json",
         expect,
     )
     _, res = topotest.run_and_expect(test_func, None, count=12, wait=0.5)
-    assertmsg = 'expected routes in "show ip bgp vrf r1-cust1 ipv4" output'
+    assertmsg = 'expected routes in "show ip bgp vrf r1-bgp-cust1 ipv4" output'
     assert res is None, assertmsg
 
 
index 22a678862a30b938bc25d04e6467fcb2772602e3..3754ad999e7337d8ff59c5b939b69e9b4899218e 100644 (file)
@@ -971,22 +971,31 @@ def add_interfaces_to_vlan(tgen, input_dict):
                 for intf_dict in interfaces:
                     for interface, data in intf_dict.items():
                         # Adding interface to VLAN
-                        cmd = "vconfig add {} {}".format(interface, vlan)
+                        vlan_intf = "{}.{}".format(interface, vlan)
+                        cmd = "ip link add link {} name {} type vlan id {}".format(
+                            interface,
+                            vlan_intf,
+                            vlan
+                        )
                         logger.info("[DUT: %s]: Running command: %s", dut, cmd)
                         rnode.run(cmd)
 
-                        vlan_intf = "{}.{}".format(interface, vlan)
-
-                        ip = data["ip"]
-                        subnet = data["subnet"]
-
                         # Bringing interface up
-                        cmd = "ip link set up {}".format(vlan_intf)
+                        cmd = "ip link set {} up".format(vlan_intf)
                         logger.info("[DUT: %s]: Running command: %s", dut, cmd)
                         rnode.run(cmd)
 
                         # Assigning IP address
-                        cmd = "ifconfig {} {} netmask {}".format(vlan_intf, ip, subnet)
+                        ifaddr = ipaddress.ip_interface(
+                            u"{}/{}".format(
+                                frr_unicode(data["ip"]),
+                                frr_unicode(data["subnet"])
+                            )
+                        )
+
+                        cmd = "ip -{0} a flush {1} scope global && ip a add {2} dev {1} && ip l set {1} up".format(
+                            ifaddr.version, vlan_intf, ifaddr
+                        )
                         logger.info("[DUT: %s]: Running command: %s", dut, cmd)
                         rnode.run(cmd)
 
@@ -1391,15 +1400,20 @@ def create_interface_in_kernel(
     rnode = tgen.routers()[dut]
 
     if create:
-        cmd = "sudo ip link add name {} type dummy".format(name)
+        cmd = "ip link show {0} >/dev/null || ip link add {0} type dummy".format(name)
         rnode.run(cmd)
 
-    addr_type = validate_ip_address(ip_addr)
-    if addr_type == "ipv4":
-        cmd = "ifconfig {} {} netmask {}".format(name, ip_addr, netmask)
+    if not netmask:
+        ifaddr = ipaddress.ip_interface(frr_unicode(ip_addr))
     else:
-        cmd = "ifconfig {} inet6 add {}/{}".format(name, ip_addr, netmask)
-
+        ifaddr = ipaddress.ip_interface(u"{}/{}".format(
+            frr_unicode(ip_addr),
+            frr_unicode(netmask)
+        ))
+    cmd = "ip -{0} a flush {1} scope global && ip a add {2} dev {1} && ip l set {1} up".format(
+        ifaddr.version, name, ifaddr
+    )
+    logger.info("[DUT: %s]: Running command: %s", dut, cmd)
     rnode.run(cmd)
 
     if vrf:
@@ -2933,7 +2947,7 @@ def configure_interface_mac(tgen, input_dict):
         rnode = tgen.routers()[dut]
 
         for intf, mac in input_dict[dut].items():
-            cmd = "ifconfig {} hw ether {}".format(intf, mac)
+            cmd = "ip link set {} address {}".format(intf, mac)
             logger.info("[DUT: %s]: Running command: %s", dut, cmd)
 
             try:
index 98af4433aba945eeaa3cc435a1b24316a94de49f..894326f19f5b3462eac62db7d6bbdf88f7d7f99a 100644 (file)
@@ -1008,8 +1008,8 @@ def test_BSM_fragmentation_p1(request):
 
     # set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments
     step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments")
-    fhr_node.run("ifconfig f1-i1-eth2 mtu 100")
-    inter_node.run("ifconfig i1-f1-eth0 mtu 100")
+    fhr_node.run("ip link set f1-i1-eth2 mtu 100")
+    inter_node.run("ip link set i1-f1-eth0 mtu 100")
 
     # Use scapy to send pre-defined packet from senser to receiver
     result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2")
index a595bc049114a013e939a83b381bcc801661231a..374d68509c7fe3d02796bfb15e7c55c95bf74263 100644 (file)
@@ -1011,7 +1011,7 @@ def test_ospf_tc4_mtu_ignore_p0(request):
     r0_r1_intf = topo["routers"]["r0"]["links"]["r1"]["interface"]
     r1_r0_intf = topo["routers"]["r1"]["links"]["r0"]["interface"]
 
-    rtr0.run("ifconfig {} mtu 1200".format(r0_r1_intf))
+    rtr0.run("ip link set {} mtu 1200".format(r0_r1_intf))
 
     clear_ospf(tgen, "r0")
 
@@ -1037,7 +1037,7 @@ def test_ospf_tc4_mtu_ignore_p0(request):
         "Modify the MTU to non default Value on R0 to R1 interface. "
         "Reset ospf neighbors on R0."
     )
-    rtr0.run("ifconfig {} mtu 1500".format(r0_r1_intf))
+    rtr0.run("ip link set {} mtu 1500".format(r0_r1_intf))
 
     clear_ospf(tgen, "r0")
 
@@ -1062,7 +1062,7 @@ def test_ospf_tc4_mtu_ignore_p0(request):
     result = config_ospf_interface(tgen, topo, r1_ospf_mtu)
     assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
 
-    rtr0.run("ifconfig {} mtu 1200".format(r0_r1_intf))
+    rtr0.run("ip link set {} mtu 1200".format(r0_r1_intf))
 
     clear_ospf(tgen, "r0")
 
@@ -1094,7 +1094,7 @@ def test_ospf_tc4_mtu_ignore_p0(request):
 
     step("Modify the MTU to again default valaue on R0 to R1 interface.")
 
-    rtr0.run("ifconfig {} mtu 1500".format(r0_r1_intf))
+    rtr0.run("ip link set {} mtu 1500".format(r0_r1_intf))
 
     clear_ospf(tgen, "r0")
 
@@ -1106,8 +1106,8 @@ def test_ospf_tc4_mtu_ignore_p0(request):
         "Configure ospf interface with jumbo MTU (9216)." "Reset ospf neighbors on R0."
     )
 
-    rtr0.run("ifconfig {} mtu 9216".format(r0_r1_intf))
-    rtr1.run("ifconfig {} mtu 9216".format(r1_r0_intf))
+    rtr0.run("ip link set {} mtu 9216".format(r0_r1_intf))
+    rtr1.run("ip link set {} mtu 9216".format(r1_r0_intf))
 
     clear_ospf(tgen, "r0")
     clear_ospf(tgen, "r1")
index 9a686355680a05d87ed40e519973f352376cb1e8..e1e2bfb99a777e93fe35d885d7ebee8aa24c6eb9 100644 (file)
@@ -3,7 +3,7 @@ hostname r1
 password zebra
 log file /tmp/r1-ospfd.log
 !
-router ospf vrf r1-cust1
+router ospf vrf r1-ospf-cust1
   ospf router-id 10.0.255.1
   redistribute kernel
   redistribute connected
index 134a10a454966356c656a2054cd84a6ed65d46d6..d617ab36d91c75284e35e784587c1565f099d2c2 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r1-cust1
+VRF Name: r1-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.1.0/24           [10] area: 0.0.0.0
                            directly attached to r1-eth0
index 083d77126cbc760d9a600390edf0947fdc9275a4..4f7fd699cf6506985459f66a30a727760e7893f7 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r1-cust1
+VRF Name: r1-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.1.0/24           [10] area: 0.0.0.0
                            directly attached to r1-eth0
index e826793657641c1f3116e2dc15e04294f5775500..e100d3b121d348d8a4ad04f9b84f88db8dc71fcf 100644 (file)
@@ -7,10 +7,10 @@ hostname r1
 password zebra
 log file /tmp/r1-zebra.log
 !
-interface r1-eth0 vrf r1-cust1
+interface r1-eth0 vrf r1-ospf-cust1
  ip address 10.0.1.1/24
 !
-interface r1-eth1 vrf r1-cust1
+interface r1-eth1 vrf r1-ospf-cust1
  ip address 10.0.3.2/24
 !
 ip forwarding
index d72aa3b8e5695b1d7f469dd0aa12dbee86e1cb2c..979af20c59e234f1f05ab33ac9b9d7a1da9d1e23 100644 (file)
@@ -1,4 +1,4 @@
-VRF r1-cust1:
+VRF r1-ospf-cust1:
 O   10.0.1.0/24 [110/10] is directly connected, r1-eth0, weight 1, XX:XX:XX
 C>* 10.0.1.0/24 is directly connected, r1-eth0, XX:XX:XX
 O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, weight 1, XX:XX:XX
index 5ea6bdc04d1101fc6f8aceeae6d7727f959d1445..ec99fad762ded6d506463e578e87710126978fc8 100644 (file)
@@ -1,4 +1,4 @@
-VRF r1-cust1:
+VRF r1-ospf-cust1:
 O   10.0.1.0/24 [110/10] is directly connected, r1-eth0, weight 1, XX:XX:XX
 C>* 10.0.1.0/24 is directly connected, r1-eth0, XX:XX:XX
 O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, weight 1, XX:XX:XX
index ad481a996d7e47aa2510638dca9e663a16e435e0..c1984276f407f26caad81a10173095a2d5802e45 100644 (file)
@@ -4,7 +4,7 @@ password zebra
 log file /tmp/r2-ospfd.log
 !
 !
-router ospf vrf r2-cust1
+router ospf vrf r2-ospf-cust1
   ospf router-id 10.0.255.2
   redistribute kernel
   redistribute connected
index a49cb7724933b428c490f6657f56d64241e6f17a..89763ff7332692861431b27f26655c90ed34319e 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r2-cust1
+VRF Name: r2-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.1.0/24           [20] area: 0.0.0.0
                            via 10.0.3.2, r2-eth1
index 2227bedf07680abfff6df740b0fd0060842ee285..d946f02dfde98cb56d551b02b3e2b8d87b2f85d5 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r2-cust1
+VRF Name: r2-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.1.0/24           [20] area: 0.0.0.0
                            via 10.0.3.2, r2-eth1
index 8dcb713da6fbd49c24722d0076d5772d301b0908..6ff72d1267f6c2d466dd61c402471a289dc9a565 100644 (file)
@@ -3,10 +3,10 @@ hostname r2
 password zebra
 log file /tmp/r2-zebra.log
 !
-interface r2-eth0 vrf r2-cust1
+interface r2-eth0 vrf r2-ospf-cust1
  ip address 10.0.2.1/24
 !
-interface r2-eth1 vrf r2-cust1
+interface r2-eth1 vrf r2-ospf-cust1
  ip address 10.0.3.3/24
 !
 ip forwarding
index ce5e5f3bab57227c321e29bab24f3508af5b2c15..df66e92abc88133d46ba37925f19417daa84dd35 100644 (file)
@@ -1,4 +1,4 @@
-VRF r2-cust1:
+VRF r2-ospf-cust1:
 O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r2-eth1, weight 1, XX:XX:XX
 O   10.0.2.0/24 [110/10] is directly connected, r2-eth0, weight 1, XX:XX:XX
 C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX
index 157811ec77d046b02b8ecdf2f62e955895bd2159..4afc354ca7ec2ac82cf9de6a3851c0f7b5fec551 100644 (file)
@@ -1,4 +1,4 @@
-VRF r2-cust1:
+VRF r2-ospf-cust1:
 O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r2-eth1, weight 1, XX:XX:XX
 O   10.0.2.0/24 [110/10] is directly connected, r2-eth0, weight 1, XX:XX:XX
 C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX
index d5214f734e7df4f07bee6b300fa25029ec0ea8bf..b73d547e3e138f8cc3cdf7964963f82ccb88bca3 100644 (file)
@@ -4,7 +4,7 @@ password zebra
 log file /tmp/r3-ospfd.log
 !
 !
-router ospf vrf r3-cust1
+router ospf vrf r3-ospf-cust1
   ospf router-id 10.0.255.3
   redistribute kernel
   redistribute connected
index 3b16bfbd55449b893293c40509fa6d91e02f891e..917702b14c84375172853d9fae553097b13050f9 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r3-cust1
+VRF Name: r3-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.1.0/24           [20] area: 0.0.0.0
                            via 10.0.3.2, r3-eth0
index 39beac7a732ba8c09489108858b964e82e5e7404..966185e49567ee79ae5b712eefe1b50368ee1bde 100644 (file)
@@ -1,4 +1,4 @@
-VRF Name: r3-cust1
+VRF Name: r3-ospf-cust1
 ============ OSPF network routing table ============
 N    10.0.10.0/24          [10] area: 0.0.0.0
                            directly attached to r3-eth1
index b5486943303b8e240465adc8a89d6a49e2aa9881..15341500480ad6cf9c14be81fee878e90230256c 100644 (file)
@@ -3,10 +3,10 @@ hostname r3
 password zebra
 log file /tmp/r3-zebra.log
 !
-interface r3-eth0 vrf r3-cust1
+interface r3-eth0 vrf r3-ospf-cust1
  ip address 10.0.3.1/24
 !
-interface r3-eth1 vrf r3-cust1
+interface r3-eth1 vrf r3-ospf-cust1
  ip address 10.0.10.1/24
 !
 ip forwarding
index f40b7b09af1bd5a979f1415ff0b313b62363d532..b435c2ebe5444b551e16cb5caa7ec53246e32139 100644 (file)
@@ -1,4 +1,4 @@
-VRF r3-cust1:
+VRF r3-ospf-cust1:
 O>* 10.0.1.0/24 [110/20] via 10.0.3.2, r3-eth0, weight 1, XX:XX:XX
 O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r3-eth0, weight 1, XX:XX:XX
 O   10.0.3.0/24 [110/10] is directly connected, r3-eth0, weight 1, XX:XX:XX
index 89cd6f56c4cb14f3ac202c4ff1539261c680a5a8..f30a4be6c684b1bdea0e61d58eaa5c9c8155a0b8 100644 (file)
@@ -1,4 +1,4 @@
-VRF r3-cust1:
+VRF r3-ospf-cust1:
 O   10.0.10.0/24 [110/10] is directly connected, r3-eth1, weight 1, XX:XX:XX
 C>* 10.0.10.0/24 is directly connected, r3-eth1, XX:XX:XX
 
index e2cb7bff038075802eba5e61a4546f3f36636e3a..713a65a812f2ab38337fc9bafb0bce58e3720b28 100644 (file)
@@ -100,17 +100,17 @@ def setup_module(mod):
     logger.info("Testing with VRF Namespace support")
 
     cmds = [
-        "if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi",
-        "ip netns add {0}-cust1",
-        "ip link set dev {0}-eth0 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
-        "ip link set dev {0}-eth1 netns {0}-cust1",
-        "ip netns exec {0}-cust1 ifconfig {0}-eth1 up",
+        "if [ -e /var/run/netns/{0}-ospf-cust1 ] ; then ip netns del {0}-ospf-cust1 ; fi",
+        "ip netns add {0}-ospf-cust1",
+        "ip link set dev {0}-eth0 netns {0}-ospf-cust1",
+        "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 up",
+        "ip link set dev {0}-eth1 netns {0}-ospf-cust1",
+        "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 up",
     ]
 
     for rname, router in router_list.items():
 
-        # create VRF rx-cust1 and link rx-eth0 to rx-cust1
+        # create VRF rx-ospf-cust1 and link rx-eth0 to rx-ospf-cust1
         for cmd in cmds:
             output = tgen.net[rname].cmd(cmd.format(rname))
 
@@ -137,9 +137,9 @@ def teardown_module(mod):
     # move back rx-eth0 to default VRF
     # delete rx-vrf
     cmds = [
-        "ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1",
-        "ip netns exec {0}-cust1 ip link set {0}-eth1 netns 1",
-        "ip netns delete {0}-cust1",
+        "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 netns 1",
+        "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 netns 1",
+        "ip netns delete {0}-ospf-cust1",
     ]
 
     router_list = tgen.routers()
@@ -152,11 +152,11 @@ def teardown_module(mod):
 # Shared test function to validate expected output.
 def compare_show_ip_route_vrf(rname, expected):
     """
-    Calls 'show ip ospf vrf [rname]-cust1 route' for router `rname` and compare the obtained
+    Calls 'show ip ospf vrf [rname]-ospf-cust1 route' for router `rname` and compare the obtained
     result with the expected output.
     """
     tgen = get_topogen()
-    vrf_name = "{0}-cust1".format(rname)
+    vrf_name = "{0}-ospf-cust1".format(rname)
     current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
     ret = topotest.difflines(
         current, expected, title1="Current output", title2="Expected output"
@@ -182,7 +182,7 @@ def test_ospf_convergence():
         test_func = partial(
             topotest.router_output_cmp,
             router,
-            "show ip ospf vrf {0}-cust1 route".format(rname),
+            "show ip ospf vrf {0}-ospf-cust1 route".format(rname),
             expected,
         )
         result, diff = topotest.run_and_expect(test_func, "", count=160, wait=0.5)
@@ -220,13 +220,13 @@ def test_ospf_json():
 
     for rname, router in tgen.routers().items():
         logger.info(
-            'Comparing router "%s" "show ip ospf vrf %s-cust1 json" output',
+            'Comparing router "%s" "show ip ospf vrf %s-ospf-cust1 json" output',
             router.name,
             router.name,
         )
         expected = {
-            "{}-cust1".format(router.name): {
-                "vrfName": "{}-cust1".format(router.name),
+            "{}-ospf-cust1".format(router.name): {
+                "vrfName": "{}-ospf-cust1".format(router.name),
                 "routerId": "10.0.255.{}".format(rname[1:]),
                 "tosRoutesOnly": True,
                 "rfc2328Conform": True,
@@ -244,7 +244,7 @@ def test_ospf_json():
         }
         # Area specific additional checks
         if router.name == "r1" or router.name == "r2" or router.name == "r3":
-            expected["{}-cust1".format(router.name)]["areas"]["0.0.0.0"] = {
+            expected["{}-ospf-cust1".format(router.name)]["areas"]["0.0.0.0"] = {
                 "areaIfActiveCounter": 2,
                 "areaIfTotalCounter": 2,
                 "authentication": "authenticationNone",
@@ -263,7 +263,7 @@ def test_ospf_json():
         test_func = partial(
             topotest.router_json_cmp,
             router,
-            "show ip ospf vrf {0}-cust1 json".format(rname),
+            "show ip ospf vrf {0}-ospf-cust1 json".format(rname),
             expected,
         )
         _, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
@@ -281,7 +281,7 @@ def test_ospf_link_down():
     # Simulate a network down event on router3 switch3 interface.
     router3 = tgen.gears["r3"]
     topotest.interface_set_status(
-        router3, "r3-eth0", ifaceaction=False, vrf_name="r3-cust1"
+        router3, "r3-eth0", ifaceaction=False, vrf_name="r3-ospf-cust1"
     )
 
     # Expect convergence on all routers
@@ -295,7 +295,7 @@ def test_ospf_link_down():
         test_func = partial(
             topotest.router_output_cmp,
             router,
-            "show ip ospf vrf {0}-cust1 route".format(rname),
+            "show ip ospf vrf {0}-ospf-cust1 route".format(rname),
             expected,
         )
         result, diff = topotest.run_and_expect(test_func, "", count=140, wait=0.5)
@@ -316,7 +316,7 @@ def test_ospf_link_down_kernel_route():
             'Checking OSPF IPv4 kernel routes in "%s" after link down', router.name
         )
 
-        str = "{0}-cust1".format(router.name)
+        str = "{0}-ospf-cust1".format(router.name)
         reffile = os.path.join(CWD, "{}/zebraroutedown.txt".format(router.name))
         expected = open(reffile).read()
         # Run test function until we get an result. Wait at most 60 seconds.