From 11e33e00754fef2555109f70f0a9ea24adb1f268 Mon Sep 17 00:00:00 2001 From: Wesley Coakley Date: Mon, 8 Jun 2020 13:39:04 -0400 Subject: [PATCH] tests: pbr topotest verifying vrf functionality Creates a VRF in the kernel and tests areas of pbrd not covered before Signed-off-by: Wesley Coakley --- tests/topotests/pbr-topo1/r1/pbr-map.json | 8 ++++++++ .../topotests/pbr-topo1/r1/pbr-nexthop-groups.json | 3 +++ tests/topotests/pbr-topo1/r1/pbrd.conf | 13 ++++++++++--- tests/topotests/pbr-topo1/r1/zebra.conf | 2 +- tests/topotests/pbr-topo1/test_pbr_topo1.py | 11 ++++++++--- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/tests/topotests/pbr-topo1/r1/pbr-map.json b/tests/topotests/pbr-topo1/r1/pbr-map.json index c0a40afc7c..f0738dc540 100644 --- a/tests/topotests/pbr-topo1/r1/pbr-map.json +++ b/tests/topotests/pbr-topo1/r1/pbr-map.json @@ -81,6 +81,14 @@ }, "matchSrc":"1.2.0.0\/16", "matchDst":"3.4.5.0\/24" + }, + { + "sequenceNumber":10, + "vrfUnchanged":true, + "installed":false, + "installedReason":"Valid", + "matchSrc":"1.2.0.0\/16", + "matchDst":"3.4.5.0\/24" } ] }, diff --git a/tests/topotests/pbr-topo1/r1/pbr-nexthop-groups.json b/tests/topotests/pbr-topo1/r1/pbr-nexthop-groups.json index 2402293865..540ea28158 100644 --- a/tests/topotests/pbr-topo1/r1/pbr-nexthop-groups.json +++ b/tests/topotests/pbr-topo1/r1/pbr-nexthop-groups.json @@ -55,14 +55,17 @@ "nexthops":[ { "nexthop":"192.168.4.3", + "targetVrf":"vrf-chiyoda", "valid":true }, { "nexthop":"192.168.4.2", + "targetVrf":"vrf-chiyoda", "valid":true }, { "nexthop":"192.168.4.1", + "targetVrf":"vrf-chiyoda", "valid":true } ] diff --git a/tests/topotests/pbr-topo1/r1/pbrd.conf b/tests/topotests/pbr-topo1/r1/pbrd.conf index b73d678e8e..4a126151b0 100644 --- a/tests/topotests/pbr-topo1/r1/pbrd.conf +++ b/tests/topotests/pbr-topo1/r1/pbrd.conf @@ -18,9 +18,9 @@ nexthop-group B nexthop 192.168.50.1 ! nexthop-group C - nexthop 192.168.4.1 - nexthop 192.168.4.2 - nexthop 192.168.4.3 + nexthop 192.168.4.1 nexthop-vrf vrf-chiyoda + nexthop 192.168.4.2 nexthop-vrf vrf-chiyoda + nexthop 192.168.4.3 nexthop-vrf vrf-chiyoda ! nexthop-group D nexthop c0ff:ee::1 @@ -40,7 +40,13 @@ pbr-map DONNA seq 5 match src-ip 1.2.0.0/16 set nexthop-group B ! +pbr-map DONNA seq 10 + match dst-ip 3.4.5.0/24 + match src-ip 1.2.0.0/16 + set vrf unchanged +! pbr-map AKIHABARA seq 5 + no set vrf unchanged match dst-ip 192.168.4.0/24 set nexthop-group C ! @@ -50,6 +56,7 @@ pbr-map AKIHABARA seq 10 set nexthop-group C ! pbr-map AKIHABARA seq 15 + set vrf noexist-vrf match dst-ip 192.168.4.0/24 set nexthop-group C no set nexthop-group C diff --git a/tests/topotests/pbr-topo1/r1/zebra.conf b/tests/topotests/pbr-topo1/r1/zebra.conf index b9c6dc1bb2..2ec947c275 100644 --- a/tests/topotests/pbr-topo1/r1/zebra.conf +++ b/tests/topotests/pbr-topo1/r1/zebra.conf @@ -7,7 +7,7 @@ int r1-eth1 int r1-eth2 ip address 192.168.3.1/24 -interface r1-eth3 +int r1-eth3 vrf vrf-chiyoda ip address 192.168.4.1/24 int r1-eth4 diff --git a/tests/topotests/pbr-topo1/test_pbr_topo1.py b/tests/topotests/pbr-topo1/test_pbr_topo1.py index d0c3d3d8f4..aedc9ca3fc 100755 --- a/tests/topotests/pbr-topo1/test_pbr_topo1.py +++ b/tests/topotests/pbr-topo1/test_pbr_topo1.py @@ -86,6 +86,11 @@ def setup_module(module): router_list = tgen.routers() for rname, router in router_list.iteritems(): + # Install vrf into the kernel and slave eth3 + router.run("ip link add vrf-chiyoda type vrf table 1000") + router.run("ip link set dev {}-eth3 master vrf-chiyoda".format(rname)) + router.run("ip link set vrf-chiyoda up") + router.load_config( TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) ) @@ -179,13 +184,13 @@ def test_pbr_flap(): for router in router_list: # Flap interface to see if route-map properties are intact # Shutdown interface - dut = "r1" + for i in range(5): intf = "r1-eth{}".format(i) # Down and back again - shutdown_bringup_interface(tgen, dut, intf, False) - shutdown_bringup_interface(tgen, dut, intf, True) + shutdown_bringup_interface(tgen, router.name, intf, False) + shutdown_bringup_interface(tgen, router.name, intf, True) intf_file = "{}/{}/pbr-interface.json".format(CWD, router.name) logger.info(intf_file) -- 2.39.5