Merge pull request #9453 from LabNConsulting/chopps/fix-netns-vrfs

tests: uniq vrf names when using netns
This commit is contained in:
Donald Sharp 2021-08-21 12:24:42 -04:00 committed by GitHub
commit 3c9fb01d26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 126 additions and 131 deletions

View File

@ -4,7 +4,7 @@ debug bfd peer
debug bfd zebra debug bfd zebra
! !
bfd bfd
peer 192.168.0.2 vrf r1-cust1 peer 192.168.0.2 vrf r1-bfd-cust1
echo-mode echo-mode
no shutdown no shutdown
! !

View 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 ebgp-requires-policy
no bgp network import-check no bgp network import-check
neighbor 192.168.0.2 remote-as 102 neighbor 192.168.0.2 remote-as 102

View 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 ip address 192.168.0.1/24
! !

View File

@ -4,13 +4,13 @@ debug bfd peer
debug bfd zebra debug bfd zebra
! !
bfd bfd
peer 192.168.0.1 vrf r2-cust1 peer 192.168.0.1 vrf r2-bfd-cust1
receive-interval 1000 receive-interval 1000
transmit-interval 500 transmit-interval 500
echo-mode echo-mode
no shutdown no shutdown
! !
peer 192.168.1.1 vrf r2-cust1 peer 192.168.1.1 vrf r2-bfd-cust1
echo-mode echo-mode
no shutdown no shutdown
! !

View 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 ebgp-requires-policy
no bgp network import-check no bgp network import-check
neighbor 192.168.0.1 remote-as 101 neighbor 192.168.0.1 remote-as 101

View 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 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 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 ip address 192.168.2.2/24
! !

View File

@ -4,7 +4,7 @@ debug bfd peer
debug bfd zebra debug bfd zebra
! !
bfd bfd
peer 192.168.1.2 vrf r3-cust1 peer 192.168.1.2 vrf r3-bfd-cust1
echo-interval 100 echo-interval 100
echo-mode echo-mode
no shutdown no shutdown

View 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 ebgp-requires-policy
no bgp network import-check no bgp network import-check
neighbor 192.168.1.2 remote-as 102 neighbor 192.168.1.2 remote-as 102

View 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 ip address 192.168.1.1/24
! !

View File

@ -4,7 +4,7 @@ debug bfd peer
debug bfd zebra debug bfd zebra
! !
bfd bfd
peer 192.168.2.2 vrf r4-cust1 peer 192.168.2.2 vrf r4-bfd-cust1
transmit-interval 2000 transmit-interval 2000
receive-interval 2000 receive-interval 2000
no shutdown no shutdown

View 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 ebgp-requires-policy
no bgp network import-check no bgp network import-check
neighbor 192.168.2.2 remote-as 102 neighbor 192.168.2.2 remote-as 102

View 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 ip address 192.168.2.1/24
! !

View File

@ -95,20 +95,18 @@ def setup_module(mod):
logger.info("Testing with VRF Namespace support") logger.info("Testing with VRF Namespace support")
cmds = [ cmds = [
"if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi", "if [ -e /var/run/netns/{0}-bfd-cust1 ] ; then ip netns del {0}-bfd-cust1 ; fi",
"ip netns add {0}-cust1", "ip netns add {0}-bfd-cust1",
"ip link set dev {0}-eth0 netns {0}-cust1", "ip link set dev {0}-eth0 netns {0}-bfd-cust1 up",
"ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
] ]
cmds2 = [ cmds2 = [
"ip link set dev {0}-eth1 netns {0}-cust1", "ip link set dev {0}-eth1 netns {0}-bfd-cust1",
"ip netns exec {0}-cust1 ifconfig {0}-eth1 up", "ip netns exec {0}-bfd-cust1 ip link set {0}-eth1 up",
"ip link set dev {0}-eth2 netns {0}-cust1", "ip link set dev {0}-eth2 netns {0}-bfd-cust1 up",
"ip netns exec {0}-cust1 ifconfig {0}-eth2 up",
] ]
for rname, router in router_list.items(): 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: for cmd in cmds:
output = tgen.net[rname].cmd(cmd.format(rname)) output = tgen.net[rname].cmd(cmd.format(rname))
if rname == "r2": if rname == "r2":
@ -138,11 +136,11 @@ def teardown_module(_mod):
# move back rx-eth0 to default VRF # move back rx-eth0 to default VRF
# delete rx-vrf # delete rx-vrf
cmds = [ cmds = [
"ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1", "ip netns exec {0}-bfd-cust1 ip link set {0}-eth0 netns 1",
"ip netns delete {0}-cust1", "ip netns delete {0}-bfd-cust1",
] ]
cmds2 = [ 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", "ip netns exec {0}-cust2 ip link set {0}-eth1 netns 1",
] ]
@ -189,7 +187,7 @@ def test_bgp_convergence():
test_func = partial( test_func = partial(
topotest.router_json_cmp, topotest.router_json_cmp,
router, router,
"show ip bgp vrf {}-cust1 summary json".format(router.name), "show ip bgp vrf {}-bfd-cust1 summary json".format(router.name),
expected, expected,
) )
_, res = topotest.run_and_expect(test_func, None, count=125, wait=1.0) _, 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( test_func = partial(
topotest.router_json_cmp, topotest.router_json_cmp,
router, router,
"show ip bgp vrf {}-cust1 json".format(router.name), "show ip bgp vrf {}-bfd-cust1 json".format(router.name),
expected, expected,
) )
_, res = topotest.run_and_expect(test_func, None, count=40, wait=1) _, 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 # Disable r2-eth0 link
router2 = tgen.gears["r2"] router2 = tgen.gears["r2"]
topotest.interface_set_status( 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 # Wait the minimum time we can before checking that BGP/BFD
@ -286,7 +284,7 @@ def test_bgp_fast_reconvergence():
test_func = partial( test_func = partial(
topotest.router_json_cmp, topotest.router_json_cmp,
router, router,
"show ip bgp vrf {}-cust1 json".format(router.name), "show ip bgp vrf {}-bfd-cust1 json".format(router.name),
expected, expected,
) )
_, res = topotest.run_and_expect(test_func, None, count=16, wait=1) _, res = topotest.run_and_expect(test_func, None, count=16, wait=1)

View File

@ -178,14 +178,10 @@ NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
LOOPBACK_1 = { LOOPBACK_1 = {
"ipv4": "10.10.10.10/32", "ipv4": "10.10.10.10/32",
"ipv6": "10::10:10/128", "ipv6": "10::10:10/128",
"ipv4_mask": "255.255.255.255",
"ipv6_mask": None,
} }
LOOPBACK_2 = { LOOPBACK_2 = {
"ipv4": "20.20.20.20/32", "ipv4": "20.20.20.20/32",
"ipv6": "20::20:20/128", "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", "loopback1",
LOOPBACK_1[addr_type], LOOPBACK_1[addr_type],
"RED_A", "RED_A",
LOOPBACK_1["{}_mask".format(addr_type)],
) )
create_interface_in_kernel( create_interface_in_kernel(
tgen, tgen,
@ -1919,7 +1914,6 @@ def test_static_routes_for_inter_vrf_route_leaking_p0(request):
"loopback2", "loopback2",
LOOPBACK_2[addr_type], LOOPBACK_2[addr_type],
"RED_B", "RED_B",
LOOPBACK_2["{}_mask".format(addr_type)],
) )
step( step(
@ -2047,7 +2041,6 @@ def test_inter_vrf_and_intra_vrf_communication_iBGP_p0(request):
"loopback1", "loopback1",
LOOPBACK_1[addr_type], LOOPBACK_1[addr_type],
"RED_A", "RED_A",
LOOPBACK_1["{}_mask".format(addr_type)],
) )
create_interface_in_kernel( create_interface_in_kernel(
@ -2056,7 +2049,6 @@ def test_inter_vrf_and_intra_vrf_communication_iBGP_p0(request):
"loopback2", "loopback2",
LOOPBACK_2[addr_type], LOOPBACK_2[addr_type],
"BLUE_A", "BLUE_A",
LOOPBACK_2["{}_mask".format(addr_type)],
) )
step( step(
@ -2216,7 +2208,6 @@ def test_inter_vrf_and_intra_vrf_communication_eBGP_p0(request):
"loopback1", "loopback1",
LOOPBACK_1[addr_type], LOOPBACK_1[addr_type],
"RED_A", "RED_A",
LOOPBACK_1["{}_mask".format(addr_type)],
) )
create_interface_in_kernel( create_interface_in_kernel(
tgen, tgen,
@ -2224,7 +2215,6 @@ def test_inter_vrf_and_intra_vrf_communication_eBGP_p0(request):
"loopback2", "loopback2",
LOOPBACK_2[addr_type], LOOPBACK_2[addr_type],
"BLUE_A", "BLUE_A",
LOOPBACK_2["{}_mask".format(addr_type)],
) )
step( step(

View File

@ -131,8 +131,6 @@ NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
LOOPBACK_2 = { LOOPBACK_2 = {
"ipv4": "20.20.20.20/32", "ipv4": "20.20.20.20/32",
"ipv6": "20::20:20/128", "ipv6": "20::20:20/128",
"ipv4_mask": "255.255.255.255",
"ipv6_mask": None,
} }
MAX_PATHS = 2 MAX_PATHS = 2
@ -1928,7 +1926,6 @@ def test_vrf_route_leaking_next_hop_interface_flapping_p1(request):
"loopback2", "loopback2",
LOOPBACK_2[addr_type], LOOPBACK_2[addr_type],
"RED_B", "RED_B",
LOOPBACK_2["{}_mask".format(addr_type)],
) )
intf_red1_r11 = topo["routers"]["red1"]["links"]["r1-link2"]["interface"] intf_red1_r11 = topo["routers"]["red1"]["links"]["r1-link2"]["interface"]

View File

@ -1103,7 +1103,7 @@ def test_next_hop_with_recursive_lookup_p1(request):
tc_name, result 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"] intf_r3_r4 = topo["routers"]["r3"]["links"]["r4"]["interface"]
shutdown_bringup_interface(tgen, "r3", intf_r3_r4) shutdown_bringup_interface(tgen, "r3", intf_r3_r4)
@ -1161,7 +1161,7 @@ def test_next_hop_with_recursive_lookup_p1(request):
tc_name, result 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"] intf_r4_r3 = topo["routers"]["r4"]["links"]["r3"]["interface"]
shutdown_bringup_interface(tgen, "r4", intf_r4_r3) shutdown_bringup_interface(tgen, "r4", intf_r4_r3)

View File

@ -123,8 +123,6 @@ LOOPBACK_1 = {
LOOPBACK_2 = { LOOPBACK_2 = {
"ipv4": "10.0.0.16/24", "ipv4": "10.0.0.16/24",
"ipv6": "fd00:0:0:3::5/64", "ipv6": "fd00:0:0:3::5/64",
"ipv4_mask": "255.255.255.0",
"ipv6_mask": None,
} }
PREFERRED_NEXT_HOP = "global" PREFERRED_NEXT_HOP = "global"
@ -692,14 +690,13 @@ def test_dynamic_imported_routes_advertised_to_iBGP_peer_p0(request):
"loopback2", "loopback2",
LOOPBACK_2[addr_type], LOOPBACK_2[addr_type],
"ISR", "ISR",
LOOPBACK_2["{}_mask".format(addr_type)],
) )
for addr_type in ADDR_TYPES: for addr_type in ADDR_TYPES:
step( step(
"On router R1 Change the next-hop of static routes in vrf " "On router R1 Change the next-hop of static routes in vrf "
"ISR to LOOPBACK_1" "ISR to LOOPBACK_2"
) )
input_routes_r1 = { input_routes_r1 = {

View 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 router-id 10.0.1.1
bgp bestpath as-path multipath-relax bgp bestpath as-path multipath-relax
no bgp ebgp-requires-policy no bgp ebgp-requires-policy

View File

@ -2,7 +2,7 @@
"ipv4Unicast":{ "ipv4Unicast":{
"routerId":"10.0.1.1", "routerId":"10.0.1.1",
"as":100, "as":100,
"vrfName":"r1-cust1", "vrfName":"r1-bgp-cust1",
"peerCount":1, "peerCount":1,
"peers":{ "peers":{
"10.0.1.101":{ "10.0.1.101":{

View File

@ -1,7 +1,7 @@
{ {
"routerId":"10.0.1.1", "routerId":"10.0.1.1",
"as":100, "as":100,
"vrfName":"re1-cust1", "vrfName":"re1-bgp-cust1",
"peerCount":1, "peerCount":1,
"peers":{ "peers":{
"10.0.1.101":{ "10.0.1.101":{

View 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 ip address 10.0.1.1/24
! !
line vty line vty

View File

@ -106,13 +106,12 @@ def setup_module(module):
if CustomizeVrfWithNetns == True: if CustomizeVrfWithNetns == True:
logger.info("Testing with VRF Namespace support") logger.info("Testing with VRF Namespace support")
# create VRF r1-cust1 # create VRF r1-bgp-cust1
# move r1-eth0 to VRF r1-cust1 # move r1-eth0 to VRF r1-bgp-cust1
cmds = [ cmds = [
"if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi", "if [ -e /var/run/netns/{0}-bgp-cust1 ] ; then ip netns del {0}-bgp-cust1 ; fi",
"ip netns add {0}-cust1", "ip netns add {0}-bgp-cust1",
"ip link set dev {0}-eth0 netns {0}-cust1", "ip link set {0}-eth0 netns {0}-bgp-cust1 up",
"ip netns exec {0}-cust1 ifconfig {0}-eth0 up",
] ]
for cmd in cmds: for cmd in cmds:
cmd = cmd.format("r1") cmd = cmd.format("r1")
@ -154,10 +153,10 @@ def setup_module(module):
def teardown_module(module): def teardown_module(module):
tgen = get_topogen() tgen = get_topogen()
# move back r1-eth0 to default VRF # move back r1-eth0 to default VRF
# delete VRF r1-cust1 # delete VRF r1-bgp-cust1
cmds = [ cmds = [
"ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1", "ip netns exec {0}-bgp-cust1 ip link set {0}-eth0 netns 1",
"ip netns delete {0}-cust1", "ip netns delete {0}-bgp-cust1",
] ]
for cmd in cmds: for cmd in cmds:
tgen.net["r1"].cmd(cmd.format("r1")) tgen.net["r1"].cmd(cmd.format("r1"))
@ -203,7 +202,7 @@ def test_bgp_convergence():
expected = json.loads(open(reffile).read()) expected = json.loads(open(reffile).read())
test_func = functools.partial( 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) _, res = topotest.run_and_expect(test_func, None, count=90, wait=0.5)
assertmsg = "BGP router network did not converge" assertmsg = "BGP router network did not converge"
@ -231,11 +230,11 @@ def test_bgp_vrf_netns():
test_func = functools.partial( test_func = functools.partial(
topotest.router_json_cmp, topotest.router_json_cmp,
tgen.gears["r1"], tgen.gears["r1"],
"show ip bgp vrf r1-cust1 ipv4 json", "show ip bgp vrf r1-bgp-cust1 ipv4 json",
expect, expect,
) )
_, res = topotest.run_and_expect(test_func, None, count=12, wait=0.5) _, 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 assert res is None, assertmsg

View File

@ -971,22 +971,31 @@ def add_interfaces_to_vlan(tgen, input_dict):
for intf_dict in interfaces: for intf_dict in interfaces:
for interface, data in intf_dict.items(): for interface, data in intf_dict.items():
# Adding interface to VLAN # 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) logger.info("[DUT: %s]: Running command: %s", dut, cmd)
rnode.run(cmd) rnode.run(cmd)
vlan_intf = "{}.{}".format(interface, vlan)
ip = data["ip"]
subnet = data["subnet"]
# Bringing interface up # 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) logger.info("[DUT: %s]: Running command: %s", dut, cmd)
rnode.run(cmd) rnode.run(cmd)
# Assigning IP address # 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) logger.info("[DUT: %s]: Running command: %s", dut, cmd)
rnode.run(cmd) rnode.run(cmd)
@ -1391,15 +1400,20 @@ def create_interface_in_kernel(
rnode = tgen.routers()[dut] rnode = tgen.routers()[dut]
if create: 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) rnode.run(cmd)
addr_type = validate_ip_address(ip_addr) if not netmask:
if addr_type == "ipv4": ifaddr = ipaddress.ip_interface(frr_unicode(ip_addr))
cmd = "ifconfig {} {} netmask {}".format(name, ip_addr, netmask)
else: 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) rnode.run(cmd)
if vrf: if vrf:
@ -2933,7 +2947,7 @@ def configure_interface_mac(tgen, input_dict):
rnode = tgen.routers()[dut] rnode = tgen.routers()[dut]
for intf, mac in input_dict[dut].items(): 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) logger.info("[DUT: %s]: Running command: %s", dut, cmd)
try: try:

View 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 # 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") step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments")
fhr_node.run("ifconfig f1-i1-eth2 mtu 100") fhr_node.run("ip link set f1-i1-eth2 mtu 100")
inter_node.run("ifconfig i1-f1-eth0 mtu 100") inter_node.run("ip link set i1-f1-eth0 mtu 100")
# Use scapy to send pre-defined packet from senser to receiver # Use scapy to send pre-defined packet from senser to receiver
result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2")

View File

@ -1011,7 +1011,7 @@ def test_ospf_tc4_mtu_ignore_p0(request):
r0_r1_intf = topo["routers"]["r0"]["links"]["r1"]["interface"] r0_r1_intf = topo["routers"]["r0"]["links"]["r1"]["interface"]
r1_r0_intf = topo["routers"]["r1"]["links"]["r0"]["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") 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. " "Modify the MTU to non default Value on R0 to R1 interface. "
"Reset ospf neighbors on R0." "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") 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) result = config_ospf_interface(tgen, topo, r1_ospf_mtu)
assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) 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") 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.") 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") 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." "Configure ospf interface with jumbo MTU (9216)." "Reset ospf neighbors on R0."
) )
rtr0.run("ifconfig {} mtu 9216".format(r0_r1_intf)) rtr0.run("ip link set {} mtu 9216".format(r0_r1_intf))
rtr1.run("ifconfig {} mtu 9216".format(r1_r0_intf)) rtr1.run("ip link set {} mtu 9216".format(r1_r0_intf))
clear_ospf(tgen, "r0") clear_ospf(tgen, "r0")
clear_ospf(tgen, "r1") clear_ospf(tgen, "r1")

View File

@ -3,7 +3,7 @@ hostname r1
password zebra password zebra
log file /tmp/r1-ospfd.log log file /tmp/r1-ospfd.log
! !
router ospf vrf r1-cust1 router ospf vrf r1-ospf-cust1
ospf router-id 10.0.255.1 ospf router-id 10.0.255.1
redistribute kernel redistribute kernel
redistribute connected redistribute connected

View File

@ -1,4 +1,4 @@
VRF Name: r1-cust1 VRF Name: r1-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.1.0/24 [10] area: 0.0.0.0 N 10.0.1.0/24 [10] area: 0.0.0.0
directly attached to r1-eth0 directly attached to r1-eth0

View File

@ -1,4 +1,4 @@
VRF Name: r1-cust1 VRF Name: r1-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.1.0/24 [10] area: 0.0.0.0 N 10.0.1.0/24 [10] area: 0.0.0.0
directly attached to r1-eth0 directly attached to r1-eth0

View File

@ -7,10 +7,10 @@ hostname r1
password zebra password zebra
log file /tmp/r1-zebra.log 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 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 address 10.0.3.2/24
! !
ip forwarding ip forwarding

View 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 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 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 O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, weight 1, XX:XX:XX

View 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 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 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 O>* 10.0.2.0/24 [110/20] via 10.0.3.3, r1-eth1, weight 1, XX:XX:XX

View File

@ -4,7 +4,7 @@ password zebra
log file /tmp/r2-ospfd.log log file /tmp/r2-ospfd.log
! !
! !
router ospf vrf r2-cust1 router ospf vrf r2-ospf-cust1
ospf router-id 10.0.255.2 ospf router-id 10.0.255.2
redistribute kernel redistribute kernel
redistribute connected redistribute connected

View File

@ -1,4 +1,4 @@
VRF Name: r2-cust1 VRF Name: r2-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.1.0/24 [20] area: 0.0.0.0 N 10.0.1.0/24 [20] area: 0.0.0.0
via 10.0.3.2, r2-eth1 via 10.0.3.2, r2-eth1

View File

@ -1,4 +1,4 @@
VRF Name: r2-cust1 VRF Name: r2-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.1.0/24 [20] area: 0.0.0.0 N 10.0.1.0/24 [20] area: 0.0.0.0
via 10.0.3.2, r2-eth1 via 10.0.3.2, r2-eth1

View File

@ -3,10 +3,10 @@ hostname r2
password zebra password zebra
log file /tmp/r2-zebra.log 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 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 address 10.0.3.3/24
! !
ip forwarding ip forwarding

View 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.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 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 C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX

View 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.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 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 C>* 10.0.2.0/24 is directly connected, r2-eth0, XX:XX:XX

View File

@ -4,7 +4,7 @@ password zebra
log file /tmp/r3-ospfd.log log file /tmp/r3-ospfd.log
! !
! !
router ospf vrf r3-cust1 router ospf vrf r3-ospf-cust1
ospf router-id 10.0.255.3 ospf router-id 10.0.255.3
redistribute kernel redistribute kernel
redistribute connected redistribute connected

View File

@ -1,4 +1,4 @@
VRF Name: r3-cust1 VRF Name: r3-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.1.0/24 [20] area: 0.0.0.0 N 10.0.1.0/24 [20] area: 0.0.0.0
via 10.0.3.2, r3-eth0 via 10.0.3.2, r3-eth0

View File

@ -1,4 +1,4 @@
VRF Name: r3-cust1 VRF Name: r3-ospf-cust1
============ OSPF network routing table ============ ============ OSPF network routing table ============
N 10.0.10.0/24 [10] area: 0.0.0.0 N 10.0.10.0/24 [10] area: 0.0.0.0
directly attached to r3-eth1 directly attached to r3-eth1

View File

@ -3,10 +3,10 @@ hostname r3
password zebra password zebra
log file /tmp/r3-zebra.log 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 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 address 10.0.10.1/24
! !
ip forwarding ip forwarding

View 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.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.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 O 10.0.3.0/24 [110/10] is directly connected, r3-eth0, weight 1, XX:XX:XX

View 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 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 C>* 10.0.10.0/24 is directly connected, r3-eth1, XX:XX:XX

View File

@ -100,17 +100,17 @@ def setup_module(mod):
logger.info("Testing with VRF Namespace support") logger.info("Testing with VRF Namespace support")
cmds = [ cmds = [
"if [ -e /var/run/netns/{0}-cust1 ] ; then ip netns del {0}-cust1 ; fi", "if [ -e /var/run/netns/{0}-ospf-cust1 ] ; then ip netns del {0}-ospf-cust1 ; fi",
"ip netns add {0}-cust1", "ip netns add {0}-ospf-cust1",
"ip link set dev {0}-eth0 netns {0}-cust1", "ip link set dev {0}-eth0 netns {0}-ospf-cust1",
"ip netns exec {0}-cust1 ifconfig {0}-eth0 up", "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 up",
"ip link set dev {0}-eth1 netns {0}-cust1", "ip link set dev {0}-eth1 netns {0}-ospf-cust1",
"ip netns exec {0}-cust1 ifconfig {0}-eth1 up", "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 up",
] ]
for rname, router in router_list.items(): 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: for cmd in cmds:
output = tgen.net[rname].cmd(cmd.format(rname)) output = tgen.net[rname].cmd(cmd.format(rname))
@ -137,9 +137,9 @@ def teardown_module(mod):
# move back rx-eth0 to default VRF # move back rx-eth0 to default VRF
# delete rx-vrf # delete rx-vrf
cmds = [ cmds = [
"ip netns exec {0}-cust1 ip link set {0}-eth0 netns 1", "ip netns exec {0}-ospf-cust1 ip link set {0}-eth0 netns 1",
"ip netns exec {0}-cust1 ip link set {0}-eth1 netns 1", "ip netns exec {0}-ospf-cust1 ip link set {0}-eth1 netns 1",
"ip netns delete {0}-cust1", "ip netns delete {0}-ospf-cust1",
] ]
router_list = tgen.routers() router_list = tgen.routers()
@ -152,11 +152,11 @@ def teardown_module(mod):
# Shared test function to validate expected output. # Shared test function to validate expected output.
def compare_show_ip_route_vrf(rname, expected): 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. result with the expected output.
""" """
tgen = get_topogen() 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) current = topotest.ip4_route_zebra(tgen.gears[rname], vrf_name)
ret = topotest.difflines( ret = topotest.difflines(
current, expected, title1="Current output", title2="Expected output" current, expected, title1="Current output", title2="Expected output"
@ -182,7 +182,7 @@ def test_ospf_convergence():
test_func = partial( test_func = partial(
topotest.router_output_cmp, topotest.router_output_cmp,
router, router,
"show ip ospf vrf {0}-cust1 route".format(rname), "show ip ospf vrf {0}-ospf-cust1 route".format(rname),
expected, expected,
) )
result, diff = topotest.run_and_expect(test_func, "", count=160, wait=0.5) 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(): for rname, router in tgen.routers().items():
logger.info( 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,
router.name, router.name,
) )
expected = { expected = {
"{}-cust1".format(router.name): { "{}-ospf-cust1".format(router.name): {
"vrfName": "{}-cust1".format(router.name), "vrfName": "{}-ospf-cust1".format(router.name),
"routerId": "10.0.255.{}".format(rname[1:]), "routerId": "10.0.255.{}".format(rname[1:]),
"tosRoutesOnly": True, "tosRoutesOnly": True,
"rfc2328Conform": True, "rfc2328Conform": True,
@ -244,7 +244,7 @@ def test_ospf_json():
} }
# Area specific additional checks # Area specific additional checks
if router.name == "r1" or router.name == "r2" or router.name == "r3": 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, "areaIfActiveCounter": 2,
"areaIfTotalCounter": 2, "areaIfTotalCounter": 2,
"authentication": "authenticationNone", "authentication": "authenticationNone",
@ -263,7 +263,7 @@ def test_ospf_json():
test_func = partial( test_func = partial(
topotest.router_json_cmp, topotest.router_json_cmp,
router, router,
"show ip ospf vrf {0}-cust1 json".format(rname), "show ip ospf vrf {0}-ospf-cust1 json".format(rname),
expected, expected,
) )
_, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5) _, 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. # Simulate a network down event on router3 switch3 interface.
router3 = tgen.gears["r3"] router3 = tgen.gears["r3"]
topotest.interface_set_status( 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 # Expect convergence on all routers
@ -295,7 +295,7 @@ def test_ospf_link_down():
test_func = partial( test_func = partial(
topotest.router_output_cmp, topotest.router_output_cmp,
router, router,
"show ip ospf vrf {0}-cust1 route".format(rname), "show ip ospf vrf {0}-ospf-cust1 route".format(rname),
expected, expected,
) )
result, diff = topotest.run_and_expect(test_func, "", count=140, wait=0.5) 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 '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)) reffile = os.path.join(CWD, "{}/zebraroutedown.txt".format(router.name))
expected = open(reffile).read() expected = open(reffile).read()
# Run test function until we get an result. Wait at most 60 seconds. # Run test function until we get an result. Wait at most 60 seconds.