summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_l3vpn_to_bgp_vrf
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/bgp_l3vpn_to_bgp_vrf')
-rwxr-xr-xtests/topotests/bgp_l3vpn_to_bgp_vrf/__init__.py0
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf55
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/sharpd.conf0
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/zebra.conf17
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf55
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/sharpd.conf0
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/zebra.conf17
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf45
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/zebra.conf17
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf45
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/zebra.conf17
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py229
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/bgpd.conf55
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ldpd.conf24
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ospfd.conf12
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/zebra.conf25
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/bgpd.conf35
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ldpd.conf26
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ospfd.conf19
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/zebra.conf28
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/bgpd.conf48
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ldpd.conf24
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ospfd.conf17
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/zebra.conf29
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf72
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ldpd.conf24
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ospfd.conf12
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/zebra.conf28
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/add_routes.py59
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/adjacencies.py64
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_mpls.py83
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py74
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py888
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/cleanup_all.py120
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/del_bgp_instances.py30
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py22
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py87
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py234
-rwxr-xr-xtests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py128
39 files changed, 2764 insertions, 0 deletions
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/__init__.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/__init__.py
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf
new file mode 100644
index 0000000..ae57431
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf
@@ -0,0 +1,55 @@
+frr defaults traditional
+!
+hostname ce1
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log
+
+router bgp 5227
+ no bgp network import-check
+ bgp router-id 99.0.0.1
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.1 remote-as 5227
+ neighbor 192.168.1.1 update-source 192.168.1.2
+ neighbor 192.168.1.1 timers 3 10
+ address-family ipv4 unicast
+ network 99.0.0.1/32
+ network 5.1.0.0/24 route-map rm-nh
+ network 5.1.1.0/24 route-map rm-nh
+ redistribute sharp route-map sharp-nh
+ network 6.0.1.0/24 route-map rm-nh
+ network 6.0.2.0/24 route-map rm-nh-same
+ neighbor 192.168.1.1 activate
+ exit-address-family
+!
+access-list al-any permit any
+!
+route-map rm-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.1
+ set local-preference 123
+ set metric 98
+ set large-community 12:34:56
+ set extcommunity rt 89:123
+ set community 0:67
+!
+route-map sharp-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.1
+ set local-preference 200
+ set metric 200
+ set large-community 90:12:34
+ set extcommunity rt 80:987
+ set community 0:65
+!
+route-map rm-nh-same permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.1
+ set local-preference 100
+ set metric 100
+ set large-community 12:34:11
+ set extcommunity rt 89:123
+ set community 0:67
+!
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/sharpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/sharpd.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/sharpd.conf
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/zebra.conf
new file mode 100644
index 0000000..46831bb
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/zebra.conf
@@ -0,0 +1,17 @@
+log file zebra.log
+!
+hostname ce1
+!
+interface lo
+ ip address 99.0.0.1/32
+!
+interface ce1-eth0
+ description to r1
+ ip address 192.168.1.2/24
+ no link-detect
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf
new file mode 100644
index 0000000..599e2dd
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf
@@ -0,0 +1,55 @@
+frr defaults traditional
+!
+hostname ce2
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log
+
+router bgp 5227
+ no bgp network import-check
+ bgp router-id 99.0.0.2
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.1 remote-as 5227
+ neighbor 192.168.1.1 update-source 192.168.1.2
+ neighbor 192.168.1.1 timers 3 10
+ address-family ipv4 unicast
+ network 99.0.0.2/32
+ network 5.1.0.0/24 route-map rm-nh
+ network 5.1.1.0/24 route-map rm-nh
+ redistribute sharp route-map sharp-nh
+ network 6.0.1.0/24 route-map rm-nh
+ network 6.0.2.0/24 route-map rm-nh-same
+ neighbor 192.168.1.1 activate
+ exit-address-family
+!
+access-list al-any permit any
+!
+route-map rm-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.2
+ set local-preference 100
+ set metric 100
+ set large-community 12:34:56
+ set extcommunity rt 89:123
+ set community 0:67
+!
+route-map sharp-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.2
+ set local-preference 200
+ set metric 200
+ set large-community 78:90:12
+ set extcommunity rt 70:456
+ set community 0:66
+!
+route-map rm-nh-same permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.2
+ set local-preference 100
+ set metric 100
+ set large-community 12:34:12
+ set extcommunity rt 89:123
+ set community 0:67
+!
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/sharpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/sharpd.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/sharpd.conf
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/zebra.conf
new file mode 100644
index 0000000..fb4d8cc
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/zebra.conf
@@ -0,0 +1,17 @@
+log file zebra.log
+!
+hostname ce2
+!
+interface lo
+ ip address 99.0.0.2/32
+!
+interface ce2-eth0
+ description to r3
+ ip address 192.168.1.2/24
+ no link-detect
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf
new file mode 100644
index 0000000..e316de5
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf
@@ -0,0 +1,45 @@
+frr defaults traditional
+!
+hostname ce3
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log
+
+router bgp 5227
+ no bgp network import-check
+ bgp router-id 99.0.0.3
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.1 remote-as 5227
+ neighbor 192.168.1.1 update-source 192.168.1.2
+ neighbor 192.168.1.1 timers 3 10
+ address-family ipv4 unicast
+ network 99.0.0.3/32
+ network 5.1.2.0/24 route-map rm-nh
+ network 5.1.3.0/24 route-map rm-nh
+ network 6.0.1.0/24 route-map rm-nh
+ network 6.0.2.0/24 route-map rm-nh-same
+ neighbor 192.168.1.1 activate
+ exit-address-family
+!
+access-list al-any permit any
+!
+route-map rm-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.3
+ set local-preference 50
+ set metric 200
+ set large-community 12:34:56
+ set extcommunity rt 89:123
+ set community 0:67
+!
+route-map rm-nh-same permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.3
+ set local-preference 100
+ set metric 100
+ set large-community 12:34:13
+ set extcommunity rt 89:123
+ set community 0:67
+!
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/zebra.conf
new file mode 100644
index 0000000..77a1163
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/zebra.conf
@@ -0,0 +1,17 @@
+log file zebra.log
+!
+hostname ce3
+!
+interface lo
+ ip address 99.0.0.3/32
+!
+interface ce3-eth0
+ description to r4
+ ip address 192.168.1.2/24
+ no link-detect
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf
new file mode 100644
index 0000000..60d9e93
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf
@@ -0,0 +1,45 @@
+frr defaults traditional
+!
+hostname ce4
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log
+
+router bgp 5228 vrf ce4-cust2
+ no bgp network import-check
+ bgp router-id 99.0.0.4
+ no bgp ebgp-requires-policy
+ neighbor 192.168.2.1 remote-as 5228
+ neighbor 192.168.2.1 update-source 192.168.2.2
+ neighbor 192.168.2.1 timers 3 10
+ address-family ipv4 unicast
+ network 99.0.0.4/32
+ network 5.4.2.0/24 route-map rm-nh
+ network 5.4.3.0/24 route-map rm-nh
+ network 6.0.1.0/24 route-map rm-nh
+ network 6.0.2.0/24 route-map rm-nh-same
+ neighbor 192.168.2.1 activate
+ exit-address-family
+!
+access-list al-any permit any
+!
+route-map rm-nh permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.4
+ set local-preference 50
+ set metric 200
+ set large-community 12:34:56
+ set extcommunity rt 89:123
+ set community 0:67
+!
+route-map rm-nh-same permit 10
+ match ip address al-any
+ set ip next-hop 99.0.0.4
+ set local-preference 100
+ set metric 100
+ set large-community 12:34:14
+ set extcommunity rt 89:123
+ set community 0:67
+!
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/zebra.conf
new file mode 100644
index 0000000..e55c9e7
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/zebra.conf
@@ -0,0 +1,17 @@
+log file zebra.log
+!
+hostname ce4
+!
+interface ce4-cust2
+ ip address 99.0.0.4/32
+!
+interface ce4-eth0
+ description to r4
+ ip address 192.168.2.2/24
+ no link-detect
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
new file mode 100644
index 0000000..5161d84
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py
@@ -0,0 +1,229 @@
+#!/usr/bin/env python
+
+#
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2017 by
+# Network Device Education Foundation, Inc. ("NetDEF")
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+r"""
+customize.py: Simple FRR MPLS L3VPN test topology
+
+ |
+ +----+----+
+ | ce1 |
+ | 99.0.0.1| CE Router
+ +----+----+
+ 192.168.1. | .2 ce1-eth0
+ | .1 r1-eth4
+ +---------+
+ | r1 |
+ | 1.1.1.1 | PE Router
+ +----+----+
+ | .1 r1-eth0
+ |
+ ~~~~~~~~~~~~~
+ ~~ sw0 ~~
+ ~~ 10.0.1.0/24 ~~
+ ~~~~~~~~~~~~~
+ |10.0.1.0/24
+ |
+ | .2 r2-eth0
+ +----+----+
+ | r2 |
+ | 2.2.2.2 | P router
+ +--+---+--+
+ r2-eth2 .2 | | .2 r2-eth1
+ ______/ \______
+ / \
+ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
+~~ sw2 ~~ ~~ sw1 ~~
+~~ 10.0.3.0/24 ~~ ~~ 10.0.2.0/24 ~~
+ ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
+ | / |
+ \ _________/ |
+ \ / \
+r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0
+ +----+--+---+ +----+----+
+ | r3 | | r4 | r4-eth5
+ | 3.3.3.3 | | 4.4.4.4 |-------+ PE Routers
+ +-----------+ +---------+ |
+192.168.1.1 |r3.eth4 192.168.1.1 | r4-eth4 |192.168.2.1
+ .2 | ceX-eth0 .2 | | .2
+ +-----+-----+ +----+-----+ +----+-----+
+ | ce2 | | ce3 | | ce4 |
+ | 99.0.0.2 | | 99.0.0.3 | | 99.0.0.4 | CE Routers
+ +-----+-----+ +----+-----+ +----+-----+
+ | | |
+
+"""
+
+import os
+import platform
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib import topotest
+from lib.topogen import get_topogen
+from lib.topolog import logger
+from lib.ltemplate import ltemplateRtrCmd
+
+# Required to instantiate the topology builder class.
+
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+# test name based on directory
+TEST = os.path.basename(CWD)
+
+
+def build_topo(tgen):
+ "Build function"
+
+ # This function only purpose is to define allocation and relationship
+ # between routers, switches and hosts.
+ #
+ # Create P/PE routers
+ # check for mpls
+ tgen.add_router("r1")
+ if tgen.hasmpls != True:
+ logger.info("MPLS not available, tests will be skipped")
+ return
+ mach = platform.machine()
+ krel = platform.release()
+ if mach[:1] == "a" and topotest.version_cmp(krel, "4.11") < 0:
+ logger.info("Need Kernel version 4.11 to run on arm processor")
+ return
+ for routern in range(2, 5):
+ tgen.add_router("r{}".format(routern))
+ # Create CE routers
+ for routern in range(1, 5):
+ tgen.add_router("ce{}".format(routern))
+
+ # CE/PE links
+ tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
+ tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
+ tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
+ tgen.add_link(tgen.gears["ce4"], tgen.gears["r4"], "ce4-eth0", "r4-eth5")
+
+ # Create a switch with just one router connected to it to simulate a
+ # empty network.
+ switch = {}
+ switch[0] = tgen.add_switch("sw0")
+ switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
+ switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
+
+ switch[1] = tgen.add_switch("sw1")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
+ switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
+
+ switch[1] = tgen.add_switch("sw2")
+ switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
+ switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
+
+
+def ltemplatePreRouterStartHook():
+ cc = ltemplateRtrCmd()
+ krel = platform.release()
+ tgen = get_topogen()
+ logger.info("pre router-start hook, kernel=" + krel)
+
+ # check for mpls
+ if tgen.hasmpls != True:
+ logger.info("MPLS not available, skipping setup")
+ return False
+ # trace errors/unexpected output
+ cc.resetCounts()
+ # configure r2 mpls interfaces
+ intfs = ["lo", "r2-eth0", "r2-eth1", "r2-eth2"]
+ for intf in intfs:
+ cc.doCmd(tgen, "r2", "echo 1 > /proc/sys/net/mpls/conf/{}/input".format(intf))
+
+ # configure cust1 VRFs & MPLS
+ rtrs = ["r1", "r3", "r4"]
+ cmds = [
+ "ip link add {0}-cust1 type vrf table 10",
+ "ip ru add oif {0}-cust1 table 10",
+ "ip ru add iif {0}-cust1 table 10",
+ "ip link set dev {0}-cust1 up",
+ ]
+ for rtr in rtrs:
+ for cmd in cmds:
+ cc.doCmd(tgen, rtr, cmd.format(rtr))
+ cc.doCmd(tgen, rtr, "ip link set dev {0}-eth4 master {0}-cust1".format(rtr))
+ intfs = [rtr + "-cust1", "lo", rtr + "-eth0", rtr + "-eth4"]
+ for intf in intfs:
+ cc.doCmd(
+ tgen, rtr, "echo 1 > /proc/sys/net/mpls/conf/{}/input".format(intf)
+ )
+ logger.info(
+ "setup {0} vrf {0}-cust1, {0}-eth4. enabled mpls input.".format(rtr)
+ )
+ # configure cust2 VRFs & MPLS
+ rtrs = ["r4"]
+ cmds = [
+ "ip link add {0}-cust2 type vrf table 20",
+ "ip ru add oif {0}-cust2 table 20",
+ "ip ru add iif {0}-cust2 table 20",
+ "ip link set dev {0}-cust2 up",
+ ]
+ for rtr in rtrs:
+ for cmd in cmds:
+ cc.doCmd(tgen, rtr, cmd.format(rtr))
+ cc.doCmd(tgen, rtr, "ip link set dev {0}-eth5 master {0}-cust2".format(rtr))
+ intfs = [rtr + "-cust2", rtr + "-eth5"]
+ for intf in intfs:
+ cc.doCmd(
+ tgen, rtr, "echo 1 > /proc/sys/net/mpls/conf/{}/input".format(intf)
+ )
+ logger.info(
+ "setup {0} vrf {0}-cust2, {0}-eth5. enabled mpls input.".format(rtr)
+ )
+ # put ce4-eth0 into a VRF (no default instance!)
+ rtrs = ["ce4"]
+ cmds = [
+ "ip link add {0}-cust2 type vrf table 20",
+ "ip ru add oif {0}-cust2 table 20",
+ "ip ru add iif {0}-cust2 table 20",
+ "ip link set dev {0}-cust2 up",
+ ]
+ for rtr in rtrs:
+ for cmd in cmds:
+ cc.doCmd(tgen, rtr, cmd.format(rtr))
+ cc.doCmd(tgen, rtr, "ip link set dev {0}-eth0 master {0}-cust2".format(rtr))
+ if cc.getOutput() != 0:
+ InitSuccess = False
+ logger.info(
+ "Unexpected output seen ({} times, tests will be skipped".format(
+ cc.getOutput()
+ )
+ )
+ else:
+ rtrs = ["r1", "r3", "r4", "ce4"]
+ for rtr in rtrs:
+ logger.info("{} configured".format(rtr))
+ cc.doCmd(tgen, rtr, "ip -d link show type vrf")
+ cc.doCmd(tgen, rtr, "ip link show")
+ InitSuccess = True
+ logger.info("VRF config successful!")
+ return InitSuccess
+
+
+def ltemplatePostRouterStartHook():
+ logger.info("post router-start hook")
+ return True
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/bgpd.conf
new file mode 100644
index 0000000..8d42cfc
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/bgpd.conf
@@ -0,0 +1,55 @@
+frr defaults traditional
+
+hostname r1
+password zebra
+log stdout notifications
+log commands
+
+log file bgpd.log debugging
+
+#debug bgp vpn leak-to-vrf
+#debug bgp vpn leak-from-vrf
+#debug bgp vpn label
+#debug bgp updates out
+
+router bgp 5226
+ bgp router-id 1.1.1.1
+ bgp cluster-id 1.1.1.1
+ no bgp ebgp-requires-policy
+ neighbor 2.2.2.2 remote-as 5226
+ neighbor 2.2.2.2 update-source 1.1.1.1
+ neighbor 2.2.2.2 timers 3 10
+
+ address-family ipv4 unicast
+ no neighbor 2.2.2.2 activate
+ exit-address-family
+
+ address-family ipv4 vpn
+ neighbor 2.2.2.2 activate
+ exit-address-family
+
+
+router bgp 5227 vrf r1-cust1
+
+ bgp router-id 192.168.1.1
+ no bgp ebgp-requires-policy
+
+ neighbor 192.168.1.2 remote-as 5227
+ neighbor 192.168.1.2 update-source 192.168.1.1
+ neighbor 192.168.1.2 timers 3 10
+
+ address-family ipv4 unicast
+ neighbor 192.168.1.2 activate
+ neighbor 192.168.1.2 next-hop-self
+
+ label vpn export 101
+ rd vpn export 10:1
+ rt vpn both 52:100
+
+ import vpn
+ export vpn
+ exit-address-family
+
+
+!
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ldpd.conf
new file mode 100644
index 0000000..168b2d4
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ldpd.conf
@@ -0,0 +1,24 @@
+hostname r1
+log file ldpd.log
+password zebra
+!
+! debug mpls ldp zebra
+! debug mpls ldp event
+! debug mpls ldp errors
+! debug mpls ldp messages recv
+! debug mpls ldp messages sent
+! debug mpls ldp discovery hello recv
+! debug mpls ldp discovery hello sent
+!
+mpls ldp
+ router-id 1.1.1.1
+ !
+ address-family ipv4
+ discovery transport-address 1.1.1.1
+ !
+ interface r1-eth0
+ !
+ !
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ospfd.conf
new file mode 100644
index 0000000..460a8fb
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/ospfd.conf
@@ -0,0 +1,12 @@
+hostname r1
+log file ospfd.log
+!
+router ospf
+ router-id 1.1.1.1
+ network 0.0.0.0/4 area 0
+ redistribute static
+!
+int r1-eth0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/zebra.conf
new file mode 100644
index 0000000..221bc7a
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r1/zebra.conf
@@ -0,0 +1,25 @@
+log file zebra.log
+
+hostname r1
+password zebra
+
+#debug zebra packet
+
+interface lo
+ ip address 1.1.1.1/32
+
+interface r1-eth0
+ description to sw0
+ ip address 10.0.1.1/24
+ no link-detect
+
+interface r1-eth4
+ description to ce1
+ ip address 192.168.1.1/24
+ no link-detect
+
+ip forwarding
+
+
+line vty
+
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/bgpd.conf
new file mode 100644
index 0000000..7b42b77
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/bgpd.conf
@@ -0,0 +1,35 @@
+frr defaults traditional
+
+hostname r2
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log debugging
+
+router bgp 5226
+ bgp router-id 2.2.2.2
+ bgp cluster-id 2.2.2.2
+ no bgp ebgp-requires-policy
+ neighbor 1.1.1.1 remote-as 5226
+ neighbor 1.1.1.1 update-source 2.2.2.2
+ neighbor 1.1.1.1 timers 3 10
+ neighbor 3.3.3.3 remote-as 5226
+ neighbor 3.3.3.3 update-source 2.2.2.2
+ neighbor 3.3.3.3 timers 3 10
+ neighbor 4.4.4.4 remote-as 5226
+ neighbor 4.4.4.4 update-source 2.2.2.2
+ neighbor 4.4.4.4 timers 3 10
+ address-family ipv4 unicast
+ no neighbor 1.1.1.1 activate
+ no neighbor 3.3.3.3 activate
+ no neighbor 4.4.4.4 activate
+ exit-address-family
+ address-family ipv4 vpn
+ neighbor 1.1.1.1 activate
+ neighbor 1.1.1.1 route-reflector-client
+ neighbor 3.3.3.3 activate
+ neighbor 3.3.3.3 route-reflector-client
+ neighbor 4.4.4.4 activate
+ neighbor 4.4.4.4 route-reflector-client
+ exit-address-family
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ldpd.conf
new file mode 100644
index 0000000..847be20
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ldpd.conf
@@ -0,0 +1,26 @@
+hostname r2
+log file ldpd.log
+password zebra
+!
+! debug mpls ldp zebra
+! debug mpls ldp event
+! debug mpls ldp errors
+! debug mpls ldp messages recv
+! debug mpls ldp messages sent
+! debug mpls ldp discovery hello recv
+! debug mpls ldp discovery hello sent
+!
+mpls ldp
+ router-id 2.2.2.2
+ !
+ address-family ipv4
+ discovery transport-address 2.2.2.2
+ !
+ interface r2-eth0
+ !
+ interface r2-eth1
+ !
+ !
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ospfd.conf
new file mode 100644
index 0000000..dbed618
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/ospfd.conf
@@ -0,0 +1,19 @@
+hostname r2
+log file ospfd.log
+!
+router ospf
+ router-id 2.2.2.2
+ network 0.0.0.0/0 area 0
+!
+int r2-eth0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
+int r2-eth1
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
+int r2-eth2
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/zebra.conf
new file mode 100644
index 0000000..dc4ef7e
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r2/zebra.conf
@@ -0,0 +1,28 @@
+log file zebra.log
+
+hostname r2
+password zebra
+!
+interface lo
+ ip address 2.2.2.2/32
+!
+interface r2-eth0
+ description to sw0
+ ip address 10.0.1.2/24
+ no link-detect
+!
+interface r2-eth1
+ description to sw1
+ ip address 10.0.2.2/24
+ no link-detect
+!
+interface r2-eth2
+ description to sw2
+ ip address 10.0.3.2/24
+ no link-detect
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/bgpd.conf
new file mode 100644
index 0000000..6c9640e
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/bgpd.conf
@@ -0,0 +1,48 @@
+frr defaults traditional
+
+hostname r3
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log
+
+#debug bgp vpn label
+router bgp 5226
+ bgp router-id 3.3.3.3
+ bgp cluster-id 3.3.3.3
+ no bgp ebgp-requires-policy
+ neighbor 2.2.2.2 remote-as 5226
+ neighbor 2.2.2.2 update-source 3.3.3.3
+ neighbor 2.2.2.2 timers 3 10
+
+ address-family ipv4 unicast
+ no neighbor 2.2.2.2 activate
+ exit-address-family
+
+ address-family ipv4 vpn
+ neighbor 2.2.2.2 activate
+ exit-address-family
+
+router bgp 5227 vrf r3-cust1
+
+ bgp router-id 192.168.1.1
+ no bgp ebgp-requires-policy
+
+ neighbor 192.168.1.2 remote-as 5227
+ neighbor 192.168.1.2 update-source 192.168.1.1
+ neighbor 192.168.1.2 timers 3 10
+
+ address-family ipv4 unicast
+ neighbor 192.168.1.2 activate
+ neighbor 192.168.1.2 next-hop-self
+
+ label vpn export 103
+ rd vpn export 10:3
+ rt vpn both 52:100
+
+ import vpn
+ export vpn
+ exit-address-family
+
+
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ldpd.conf
new file mode 100644
index 0000000..a620739
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ldpd.conf
@@ -0,0 +1,24 @@
+hostname r3
+password zebra
+log file ldpd.log
+!
+! debug mpls ldp zebra
+! debug mpls ldp event
+! debug mpls ldp errors
+! debug mpls ldp messages recv
+! debug mpls ldp messages sent
+! debug mpls ldp discovery hello recv
+! debug mpls ldp discovery hello sent
+!
+mpls ldp
+ router-id 3.3.3.3
+ !
+ address-family ipv4
+ discovery transport-address 3.3.3.3
+ !
+ interface r3-eth0
+ !
+ !
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ospfd.conf
new file mode 100644
index 0000000..0e64ed6
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/ospfd.conf
@@ -0,0 +1,17 @@
+hostname r3
+password 1
+log file ospfd.log
+!
+router ospf
+ router-id 3.3.3.3
+ network 0.0.0.0/4 area 0
+ redistribute static
+!
+int r3-eth0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
+int r3-eth1
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/zebra.conf
new file mode 100644
index 0000000..9ffc84f
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r3/zebra.conf
@@ -0,0 +1,29 @@
+log file zebra.log
+
+hostname r3
+password zebra
+!
+interface lo
+ ip address 3.3.3.3/32
+!
+interface r3-eth0
+ description to sw1
+ ip address 10.0.2.3/24
+ no link-detect
+!
+interface r3-eth1
+ description to sw2
+ ip address 10.0.3.3/24
+ no link-detect
+!
+interface r3-eth4
+ description to ce2
+ ip address 192.168.1.1/24
+ no link-detect
+!
+!
+ip forwarding
+!
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf
new file mode 100644
index 0000000..ca9e627
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf
@@ -0,0 +1,72 @@
+frr defaults traditional
+
+hostname r4
+password zebra
+log stdout notifications
+log commands
+log file bgpd.log debug
+
+#debug bgp vpn label
+#debug bgp nht
+#debug bgp zebra
+
+router bgp 5226
+ bgp router-id 4.4.4.4
+ bgp cluster-id 4.4.4.4
+ no bgp ebgp-requires-policy
+ neighbor 2.2.2.2 remote-as 5226
+ neighbor 2.2.2.2 update-source 4.4.4.4
+ neighbor 2.2.2.2 timers 3 10
+
+ address-family ipv4 unicast
+ no neighbor 2.2.2.2 activate
+ exit-address-family
+
+ address-family ipv4 vpn
+ neighbor 2.2.2.2 activate
+ exit-address-family
+
+router bgp 5227 vrf r4-cust1
+
+ bgp router-id 192.168.1.1
+ no bgp ebgp-requires-policy
+
+ neighbor 192.168.1.2 remote-as 5227
+ neighbor 192.168.1.2 update-source 192.168.1.1
+ neighbor 192.168.1.2 timers 3 10
+
+ address-family ipv4 unicast
+ neighbor 192.168.1.2 activate
+ neighbor 192.168.1.2 next-hop-self
+
+ label vpn export 1041
+ rd vpn export 10:41
+ rt vpn both 52:100
+
+ import vpn
+ export vpn
+ exit-address-family
+
+router bgp 5228 vrf r4-cust2
+
+ bgp router-id 192.168.2.1
+ no bgp ebgp-requires-policy
+
+ neighbor 192.168.2.2 remote-as 5228
+ neighbor 192.168.2.2 update-source 192.168.2.1
+ neighbor 192.168.2.2 timers 3 10
+
+ address-family ipv4 unicast
+ neighbor 192.168.2.2 activate
+ neighbor 192.168.2.2 next-hop-self
+
+ label vpn export 1042
+ rd vpn export 10:42
+ # note RT same as r4-cust1 for inter-vrf route leaking
+ rt vpn both 52:100
+
+ import vpn
+ export vpn
+ exit-address-family
+
+end
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ldpd.conf
new file mode 100644
index 0000000..617d3a7
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ldpd.conf
@@ -0,0 +1,24 @@
+hostname r4
+password zebra
+log file ldpd.log
+!
+! debug mpls ldp zebra
+! debug mpls ldp event
+! debug mpls ldp errors
+! debug mpls ldp messages recv
+! debug mpls ldp messages sent
+! debug mpls ldp discovery hello recv
+! debug mpls ldp discovery hello sent
+!
+mpls ldp
+ router-id 4.4.4.4
+ !
+ address-family ipv4
+ discovery transport-address 4.4.4.4
+ !
+ interface r4-eth0
+ !
+ !
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ospfd.conf
new file mode 100644
index 0000000..89e37df
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/ospfd.conf
@@ -0,0 +1,12 @@
+hostname r4
+log file ospfd.log
+!
+router ospf
+ router-id 4.4.4.4
+ network 0.0.0.0/4 area 0
+ redistribute static
+!
+int r4-eth0
+ ip ospf hello-interval 2
+ ip ospf dead-interval 10
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/zebra.conf
new file mode 100644
index 0000000..4f01a27
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/zebra.conf
@@ -0,0 +1,28 @@
+log file zebra.log
+
+hostname r4
+password zebra
+!
+interface lo
+ ip address 4.4.4.4/32
+!
+interface r4-eth0
+ description to sw1
+ ip address 10.0.2.4/24
+ no link-detect
+!
+interface r4-eth4
+ description to ce3
+ ip address 192.168.1.1/24
+ no link-detect
+!
+interface r4-eth5
+ description to ce4
+ ip address 192.168.2.1/24
+ no link-detect
+!
+!
+ip forwarding
+!
+line vty
+!
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/add_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/add_routes.py
new file mode 100644
index 0000000..375bca8
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/add_routes.py
@@ -0,0 +1,59 @@
+from lib.lutil import luCommand
+
+luCommand(
+ "r1", 'vtysh -c "add vrf r1-cust1 prefix 99.0.0.1/32"', ".", "none", "IP Address"
+)
+luCommand(
+ "r3", 'vtysh -c "add vrf r3-cust1 prefix 99.0.0.2/32"', ".", "none", "IP Address"
+)
+luCommand(
+ "r4", 'vtysh -c "add vrf r4-cust1 prefix 99.0.0.3/32"', ".", "none", "IP Address"
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.1",
+ "pass",
+ "Local Registration",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.2",
+ "pass",
+ "Local Registration",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.3",
+ "pass",
+ "Local Registration",
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show vnc registrations remote"',
+ "4 out of 4",
+ "wait",
+ "Remote Registration",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show vnc registrations remote"',
+ "6 out of 6",
+ "wait",
+ "Remote Registration",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show vnc registrations remote"',
+ "4 out of 4",
+ "wait",
+ "Remote Registration",
+ 10,
+)
+luCommand("r1", 'vtysh -c "show vnc registrations"', ".", "none")
+luCommand("r3", 'vtysh -c "show vnc registrations"', ".", "none")
+luCommand("r4", 'vtysh -c "show vnc registrations"', ".", "none")
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/adjacencies.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/adjacencies.py
new file mode 100644
index 0000000..f514575
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/adjacencies.py
@@ -0,0 +1,64 @@
+from lib.lutil import luCommand
+
+luCommand("ce1", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Adjacencies up", 180)
+luCommand("ce2", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Adjacencies up", 180)
+luCommand("ce3", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Adjacencies up", 180)
+luCommand(
+ "ce4", 'vtysh -c "show bgp vrf all summary"', " 00:0", "wait", "Adjacencies up", 180
+)
+luCommand(
+ "r1", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60
+)
+luCommand(
+ "r3", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60
+)
+luCommand(
+ "r4", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60
+)
+luCommand(
+ "r2",
+ 'vtysh -c "show bgp summary"',
+ " 00:0.* 00:0.* 00:0",
+ "wait",
+ "Core adjacencies up",
+ 180,
+)
+luCommand(
+ "r1", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Core adjacencies up", 180
+)
+luCommand(
+ "r3", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Core adjacencies up", 180
+)
+luCommand(
+ "r4", 'vtysh -c "show bgp summary"', " 00:0", "wait", "Core adjacencies up", 180
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf all summary"',
+ " 00:0.* 00:0",
+ "pass",
+ "All adjacencies up",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf all summary"',
+ " 00:0.* 00:0",
+ "pass",
+ "All adjacencies up",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf all summary"',
+ " 00:0.* 00:0.* 00:0",
+ "pass",
+ "All adjacencies up",
+)
+luCommand(
+ "r1", "ping 3.3.3.3 -c 1", " 0. packet loss", "wait", "PE->PE3 (loopback) ping"
+)
+luCommand(
+ "r1", "ping 4.4.4.4 -c 1", " 0. packet loss", "wait", "PE->PE4 (loopback) ping"
+)
+luCommand(
+ "r4", "ping 3.3.3.3 -c 1", " 0. packet loss", "wait", "PE->PE3 (loopback) ping"
+)
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_mpls.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_mpls.py
new file mode 100644
index 0000000..91a7adf
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_mpls.py
@@ -0,0 +1,83 @@
+from lib.lutil import luCommand, luLast
+from lib import topotest
+
+ret = luCommand(
+ "r2",
+ "ip -M route show",
+ r"\d*(?= via inet 10.0.2.4 dev r2-eth1)",
+ "wait",
+ "See mpls route to r4",
+)
+found = luLast()
+
+if ret != False and found != None:
+ label4r4 = found.group(0)
+ luCommand("r2", "ip -M route show", ".", "pass", "See %s as label to r4" % label4r4)
+ ret = luCommand(
+ "r2",
+ "ip -M route show",
+ r"\d*(?= via inet 10.0.1.1 dev r2-eth0)",
+ "wait",
+ "See mpls route to r1",
+ )
+ found = luLast()
+
+if ret != False and found != None:
+ label4r1 = found.group(0)
+ luCommand("r2", "ip -M route show", ".", "pass", "See %s as label to r1" % label4r1)
+
+ luCommand(
+ "r1",
+ "ip route show vrf r1-cust1",
+ "99.0.0.4",
+ "pass",
+ "VRF->MPLS PHP route installed",
+ )
+ luCommand(
+ "r4",
+ "ip route show vrf r4-cust2",
+ "99.0.0.1",
+ "pass",
+ "VRF->MPLS PHP route installed",
+ )
+
+ luCommand("r1", "ip -M route show", "101", "pass", "MPLS->VRF route installed")
+ luCommand("r4", "ip -M route show", "1041", "pass", "MPLS->VRF1 route installed")
+ luCommand("r4", "ip -M route show", "1042", "pass", "MPLS->VRF2 route installed")
+
+ luCommand(
+ "ce1",
+ "ping 99.0.0.4 -I 99.0.0.1 -c 1",
+ " 0. packet loss",
+ "wait",
+ "CE->CE (loopback) ping - l3vpn+zebra case",
+ )
+ # skip due to VRF weirdness
+ # luCommand('ce4', 'ping 99.0.0.1 -I 99.0.0.4 -c 1',
+ # ' 0. packet loss','wait','CE->CE (loopback) ping - l3vpn+zebra case')
+
+ luCommand(
+ "ce1",
+ "ping 99.0.0.4 -I 99.0.0.1 -c 1",
+ " 0. packet loss",
+ "wait",
+ "CE->CE (loopback) ping",
+ )
+ # luCommand('ce4', 'ping 99.0.0.1 -I 99.0.0.4 -c 1',
+ # ' 0. packet loss','wait','CE->CE (loopback) ping')
+
+ luCommand("r3", "ip -M route show", "103", "pass", "MPLS->VRF route installed")
+ luCommand(
+ "ce2",
+ "ping 99.0.0.3 -I 99.0.0.2 -c 1",
+ " 0. packet loss",
+ "wait",
+ "CE2->CE3 (loopback) ping",
+ )
+ luCommand(
+ "ce3",
+ "ping 99.0.0.4 -I 99.0.0.3 -c 1",
+ " 0. packet loss",
+ "wait",
+ "CE3->CE4 (loopback) ping",
+ )
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py
new file mode 100644
index 0000000..75158b1
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py
@@ -0,0 +1,74 @@
+from lib.lutil import luCommand
+
+rtrs = ["r1", "r3", "r4"]
+for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip link show type vrf {}-cust1".format(rtr),
+ "cust1: .*UP",
+ "pass",
+ "VRF cust1 intf up",
+ )
+ luCommand(
+ rtr,
+ "ip add show vrf {}-cust1".format(rtr),
+ "r..eth4.*UP",
+ "pass",
+ "VRF cust1 IP intf up",
+ )
+ luCommand(
+ rtr,
+ "ip add show vrf {}-cust1".format(rtr),
+ "192.168",
+ "pass",
+ "VRF cust1 IP config",
+ )
+ luCommand(
+ rtr,
+ "ip route show vrf {}-cust1".format(rtr),
+ "192.168...0/24 dev r.-eth",
+ "pass",
+ "VRF cust1 interface route",
+ )
+luCommand("r4", "ip link show type vrf r4-cust2", "cust2: .*UP", "pass", "VRF cust2 up")
+luCommand(
+ "r4",
+ "ip add show vrf r4-cust2",
+ "r..eth5.*UP.* 192.168",
+ "pass",
+ "VRF cust1 IP config",
+)
+luCommand(
+ "r4",
+ "ip route show vrf r4-cust2",
+ "192.168...0/24 dev r.-eth",
+ "pass",
+ "VRF cust2 interface route",
+)
+rtrs = ["ce1", "ce2", "ce3"]
+for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip route show",
+ "192.168...0/24 dev ce.-eth0",
+ "pass",
+ "CE interface route",
+ )
+ luCommand(rtr, "ping 192.168.1.1 -c 1", " 0. packet loss", "wait", "CE->PE ping")
+luCommand(
+ "ce4", "ip link show type vrf ce4-cust2", "cust2: .*UP", "pass", "VRF cust2 up"
+)
+luCommand(
+ "ce4",
+ "ip route show vrf ce4-cust2",
+ "192.168...0/24 dev ce.-eth0",
+ "pass",
+ "CE interface route",
+)
+luCommand(
+ "ce4",
+ "ping 192.168.2.1 -c 1 -I ce4-cust2",
+ " 0. packet loss",
+ "wait",
+ "CE4->PE4 ping",
+)
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py
new file mode 100644
index 0000000..550ff93
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py
@@ -0,0 +1,888 @@
+from lib.lutil import luCommand
+from lib.bgprib import bgpribRequireVpnRoutes, bgpribRequireUnicastRoutes
+
+########################################################################
+# CE routers: contain routes they originate
+########################################################################
+#
+# mininet CLI commands
+# ce1 vtysh -c "show bgp ipv4 uni"
+# ce2 vtysh -c "show bgp ipv4 uni"
+# ce3 vtysh -c "show bgp ipv4 uni"
+# ce4 vtysh -c "show bgp ipv4 uni"
+
+want = [
+ {"p": "5.1.0.0/24", "n": "99.0.0.1"},
+ {"p": "5.1.1.0/24", "n": "99.0.0.1"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.1"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.1"},
+ {"p": "99.0.0.1/32", "n": "0.0.0.0"},
+]
+bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes in ce1", want)
+
+want = [
+ {"p": "5.1.0.0/24", "n": "99.0.0.2"},
+ {"p": "5.1.1.0/24", "n": "99.0.0.2"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.2"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.2"},
+ {"p": "99.0.0.2/32", "n": "0.0.0.0"},
+]
+bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 2 routes in ce1", want)
+
+want = [
+ {"p": "5.1.2.0/24", "n": "99.0.0.3"},
+ {"p": "5.1.3.0/24", "n": "99.0.0.3"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.3"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.3"},
+ {"p": "99.0.0.3/32", "n": "0.0.0.0"},
+]
+bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 3 routes in ce1", want)
+
+want = [
+ {"p": "5.4.2.0/24", "n": "99.0.0.4"},
+ {"p": "5.4.3.0/24", "n": "99.0.0.4"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.4"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.4"},
+ {"p": "99.0.0.4/32", "n": "0.0.0.0"},
+]
+bgpribRequireUnicastRoutes("ce4", "ipv4", "ce4-cust2", "Cust 4 routes in ce1", want)
+
+
+########################################################################
+# PE routers: VRFs contain routes from locally-attached customer nets
+########################################################################
+#
+# r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
+#
+want_r1_cust1_routes = [
+ {"p": "5.1.0.0/24", "n": "99.0.0.1"},
+ {"p": "5.1.1.0/24", "n": "99.0.0.1"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.1"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.1"},
+ {"p": "99.0.0.1/32", "n": "192.168.1.2"},
+]
+bgpribRequireUnicastRoutes(
+ "r1", "ipv4", "r1-cust1", "Customer 1 routes in r1 vrf", want_r1_cust1_routes
+)
+
+want_r3_cust1_routes = [
+ {"p": "5.1.0.0/24", "n": "99.0.0.2"},
+ {"p": "5.1.1.0/24", "n": "99.0.0.2"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.2"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.2"},
+ {"p": "99.0.0.2/32", "n": "192.168.1.2"},
+]
+bgpribRequireUnicastRoutes(
+ "r3", "ipv4", "r3-cust1", "Customer 1 routes in r3 vrf", want_r3_cust1_routes
+)
+
+want_r4_cust1_routes = [
+ {"p": "5.1.2.0/24", "n": "99.0.0.3"},
+ {"p": "5.1.3.0/24", "n": "99.0.0.3"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.3"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.3"},
+ {"p": "99.0.0.3/32", "n": "192.168.1.2"},
+]
+bgpribRequireUnicastRoutes(
+ "r4", "ipv4", "r4-cust1", "Customer 1 routes in r4 vrf", want_r4_cust1_routes
+)
+
+want_r4_cust2_routes = [
+ {"p": "5.4.2.0/24", "n": "99.0.0.4"},
+ {"p": "5.4.3.0/24", "n": "99.0.0.4"},
+ {"p": "6.0.1.0/24", "n": "99.0.0.4"},
+ {"p": "6.0.2.0/24", "n": "99.0.0.4"},
+ {"p": "99.0.0.4/32", "n": "192.168.2.2"},
+]
+bgpribRequireUnicastRoutes(
+ "r4", "ipv4", "r4-cust2", "Customer 2 routes in r4 vrf", want_r4_cust2_routes
+)
+
+########################################################################
+# PE routers: core unicast routes are empty
+########################################################################
+
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "No BGP prefixes displayed",
+ "pass",
+ "Core Unicast SAFI clean",
+)
+luCommand(
+ "r2",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "No BGP prefixes displayed",
+ "pass",
+ "Core Unicast SAFI clean",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "No BGP prefixes displayed",
+ "pass",
+ "Core Unicast SAFI clean",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "No BGP prefixes displayed",
+ "pass",
+ "Core Unicast SAFI clean",
+)
+
+########################################################################
+# PE routers: local ce-originated routes are leaked to vpn
+########################################################################
+
+# nhzero is for the new code that sets nh of locally-leaked routes to 0
+# nhzero = 1
+nhzero = 0
+
+if nhzero:
+ luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 vpn"',
+ "Distinguisher: *10:1.*5.1.0.0/24 *0.0.0.0 .*5.1.1.0/24 *0.0.0.0 .*99.0.0.1/32 *0.0.0.0 ",
+ "pass",
+ "vrf->vpn routes",
+ )
+ luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 vpn"',
+ "Distinguisher: *10:3.*5.1.0.0/24 *0.0.0.0 .*5.1.1.0/24 *0.0.0.0 .*99.0.0.2/32 *0.0.0.0 ",
+ "pass",
+ "vrf->vpn routes",
+ )
+ want = [
+ {"rd": "10:41", "p": "5.1.2.0/24", "n": "0.0.0.0"},
+ {"rd": "10:41", "p": "5.1.3.0/24", "n": "0.0.0.0"},
+ {"rd": "10:41", "p": "99.0.0.3/32", "n": "0.0.0.0"},
+ {"rd": "10:42", "p": "5.4.2.0/24", "n": "0.0.0.0"},
+ {"rd": "10:42", "p": "5.4.3.0/24", "n": "0.0.0.0"},
+ {"rd": "10:42", "p": "99.0.0.4/32", "n": "0.0.0.0"},
+ ]
+ bgpribRequireVpnRoutes("r4", "vrf->vpn routes", want)
+
+else:
+ luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 vpn"',
+ r"Distinguisher: *10:1.*5.1.0.0/24 *99.0.0.1\b.*5.1.1.0/24 *99.0.0.1\b.*6.0.1.0/24 *99.0.0.1\b.*6.0.2.0/24 *99.0.0.1\b.*99.0.0.1/32 *192.168.1.2\b",
+ "pass",
+ "vrf->vpn routes",
+ )
+ luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 vpn"',
+ r"Distinguisher: *10:3.*5.1.0.0/24 *99.0.0.2\b.*5.1.1.0/24 *99.0.0.2\b.*6.0.1.0/24 *99.0.0.2\b.*6.0.2.0/24 *99.0.0.2\b.*99.0.0.2/32 *192.168.1.2\b",
+ "pass",
+ "vrf->vpn routes",
+ )
+ want = [
+ {"rd": "10:41", "p": "5.1.2.0/24", "n": "99.0.0.3"},
+ {"rd": "10:41", "p": "5.1.3.0/24", "n": "99.0.0.3"},
+ {"rd": "10:41", "p": "6.0.1.0/24", "n": "99.0.0.3"},
+ {"rd": "10:41", "p": "6.0.2.0/24", "n": "99.0.0.3"},
+ {"rd": "10:41", "p": "99.0.0.3/32", "n": "192.168.1.2"},
+ {"rd": "10:42", "p": "5.4.2.0/24", "n": "99.0.0.4"},
+ {"rd": "10:42", "p": "5.4.3.0/24", "n": "99.0.0.4"},
+ {"rd": "10:42", "p": "6.0.1.0/24", "n": "99.0.0.4"},
+ {"rd": "10:42", "p": "6.0.2.0/24", "n": "99.0.0.4"},
+ {"rd": "10:42", "p": "99.0.0.4/32", "n": "192.168.2.2"},
+ ]
+ bgpribRequireVpnRoutes("r4", "vrf->vpn routes", want)
+
+########################################################################
+# PE routers: exporting vrfs set MPLS vrf labels in kernel
+########################################################################
+
+luCommand(
+ "r1", 'vtysh -c "show mpls table"', " 101 *BGP *r1-cust1", "pass", "vrf labels"
+)
+luCommand(
+ "r3", 'vtysh -c "show mpls table"', " 103 *BGP *r3-cust1", "pass", "vrf labels"
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show mpls table"',
+ " 1041 *BGP *r4-cust1 .*1042 *BGP *r4-cust2",
+ "pass",
+ "vrf labels",
+)
+
+########################################################################
+# Core VPN router: all customer routes
+########################################################################
+
+want_rd_routes = [
+ {"rd": "10:1", "p": "5.1.0.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "5.1.0.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "99.0.0.1/32", "n": "1.1.1.1"},
+ {"rd": "10:3", "p": "5.1.0.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "5.1.0.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "99.0.0.2/32", "n": "3.3.3.3"},
+ {"rd": "10:41", "p": "5.1.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "5.1.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "99.0.0.3/32", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "99.0.0.4/32", "n": "4.4.4.4"},
+]
+bgpribRequireVpnRoutes("r2", "Customer routes in provider vpn core", want_rd_routes)
+
+########################################################################
+# PE routers: VPN routes from remote customers
+########################################################################
+#
+# r1 vtysh -c "show bgp ipv4 vpn"
+#
+want_r1_remote_vpn_routes = [
+ {"rd": "10:3", "p": "5.1.0.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "5.1.1.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "99.0.0.2/32", "n": "3.3.3.3"},
+ {"rd": "10:41", "p": "5.1.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "5.1.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "99.0.0.3/32", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "99.0.0.4/32", "n": "4.4.4.4"},
+]
+bgpribRequireVpnRoutes(
+ "r1", "Remote Customer routes in R1 vpn", want_r1_remote_vpn_routes
+)
+
+want_r3_remote_vpn_routes = [
+ {"rd": "10:1", "p": "5.1.0.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "5.1.1.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "99.0.0.1/32", "n": "1.1.1.1"},
+ {"rd": "10:41", "p": "5.1.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "5.1.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:41", "p": "99.0.0.3/32", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.2.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "5.4.3.0/24", "n": "4.4.4.4"},
+ {"rd": "10:42", "p": "99.0.0.4/32", "n": "4.4.4.4"},
+]
+bgpribRequireVpnRoutes(
+ "r3", "Remote Customer routes in R3 vpn", want_r3_remote_vpn_routes
+)
+
+want_r4_remote_vpn_routes = [
+ {"rd": "10:1", "p": "5.1.0.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "5.1.1.0/24", "n": "1.1.1.1"},
+ {"rd": "10:1", "p": "99.0.0.1/32", "n": "1.1.1.1"},
+ {"rd": "10:3", "p": "5.1.0.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "5.1.1.0/24", "n": "3.3.3.3"},
+ {"rd": "10:3", "p": "99.0.0.2/32", "n": "3.3.3.3"},
+]
+bgpribRequireVpnRoutes(
+ "r4", "Remote Customer routes in R4 vpn", want_r4_remote_vpn_routes
+)
+
+
+# r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
+########################################################################
+# PE routers: VRFs contain routes from remote customer nets
+########################################################################
+# First let's spot check and ensure that some of the routes
+# have showed up and been best path'd
+# After the first two are good. It's probably ok
+# to look at the rest of the routes in the vrf
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.1.0.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.0.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.1.1.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.1.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.1.2.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.1.2.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.1.3.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.1.3.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.4.2.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.4.2.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 5.4.2.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.4.3.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 6.0.1.0/24"',
+ "3 available, best",
+ "wait",
+ "Ensure 6.0.1.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 6.0.2.0/24"',
+ "3 available, best",
+ "wait",
+ "Ensure 6.0.2.0 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 99.0.0.1/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.1 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 99.0.0.2/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.2 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 99.0.0.3/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.3 shows up on r1",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 99.0.0.4/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.4 shows up on r1",
+ 10,
+)
+want_r1_remote_cust1_routes = [
+ {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "5.1.0.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "5.1.1.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "5.1.2.0/24", "n": "4.4.4.4"},
+ {"p": "5.1.3.0/24", "n": "4.4.4.4"},
+ {"p": "5.4.2.0/24", "n": "4.4.4.4"},
+ {"p": "5.4.3.0/24", "n": "4.4.4.4"},
+ {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "4.4.4.4", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": True},
+ {"p": "6.0.2.0/24", "n": "4.4.4.4", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.1", "bp": False},
+ {"p": "99.0.0.1/32", "n": "192.168.1.2", "bp": True},
+ {"p": "99.0.0.2/32", "n": "3.3.3.3"},
+ {"p": "99.0.0.3/32", "n": "4.4.4.4"},
+ {"p": "99.0.0.4/32", "n": "4.4.4.4"},
+]
+bgpribRequireUnicastRoutes(
+ "r1",
+ "ipv4",
+ "r1-cust1",
+ "Customer 1 routes in r1 vrf (2)",
+ want_r1_remote_cust1_routes,
+ debug=False,
+)
+
+
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.1.0.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.0.0 shows up r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.1.1.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.1.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.1.2.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.1.2.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.1.3.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.1.3.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.4.3.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.4.3.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.4.3.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.4.3.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 5.4.3.0/24"',
+ "1 available, best",
+ "wait",
+ "Ensure 5.4.3.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 6.0.1.0/24"',
+ "3 available, best",
+ "wait",
+ "Ensure 6.0.1.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 6.0.2.0/24"',
+ "3 available, best",
+ "wait",
+ "Ensure 6.0.2.0 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 99.0.0.1/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.1 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 99.0.0.3/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.3 shows up on r3",
+ 10,
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 99.0.0.4/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.4 shows up on r3",
+ 10,
+)
+want_r3_remote_cust1_routes = [
+ {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.0.0/24", "n": "99.0.0.2", "bp": False},
+ {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "99.0.0.2", "bp": False},
+ {"p": "5.1.2.0/24", "n": "4.4.4.4", "bp": True},
+ {"p": "5.1.3.0/24", "n": "4.4.4.4", "bp": True},
+ {"p": "5.4.2.0/24", "n": "4.4.4.4", "bp": True},
+ {"p": "5.4.3.0/24", "n": "4.4.4.4", "bp": True},
+ {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "4.4.4.4", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": False},
+ {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.2.0/24", "n": "4.4.4.4", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": False},
+ {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True},
+ {"p": "99.0.0.3/32", "n": "4.4.4.4", "bp": True},
+ {"p": "99.0.0.4/32", "n": "4.4.4.4", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "r3",
+ "ipv4",
+ "r3-cust1",
+ "Customer 1 routes in r3 vrf (2)",
+ want_r3_remote_cust1_routes,
+ debug=False,
+)
+
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 5.1.0.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.0.0 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 5.1.1.0/24"',
+ "2 available, best",
+ "wait",
+ "Ensure 5.1.1.0 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 6.0.1.0/24"',
+ "4 available, best",
+ "wait",
+ "Ensure 6.0.1.0 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 6.0.2.0/24"',
+ "4 available, best",
+ "wait",
+ "Ensure 6.0.2.0 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 99.0.0.1/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.1 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 99.0.0.2/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.2 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 99.0.0.3/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.3 shows up on r4",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni 99.0.0.4/32"',
+ "1 available, best",
+ "wait",
+ "Ensure 99.0.0.4 shows up on r4",
+ 10,
+)
+want_r4_remote_cust1_routes = [
+ {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False},
+ {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False},
+ {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True},
+ {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True},
+ {"p": "99.0.0.3/32", "n": "192.168.1.2", "bp": True},
+ {"p": "99.0.0.4/32", "n": "192.168.2.2", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "r4",
+ "ipv4",
+ "r4-cust1",
+ "Customer 1 routes in r4 vrf (2)",
+ want_r4_remote_cust1_routes,
+ debug=False,
+)
+
+want_r4_remote_cust2_routes = [
+ {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False},
+ {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True},
+ {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False},
+ {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False},
+ {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True},
+ {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True},
+ {"p": "99.0.0.3/32", "n": "192.168.1.2", "bp": True},
+ {"p": "99.0.0.4/32", "n": "192.168.2.2", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "r4",
+ "ipv4",
+ "r4-cust2",
+ "Customer 2 routes in r4 vrf (2)",
+ want_r4_remote_cust2_routes,
+ debug=False,
+)
+
+
+#########################################################################
+# CE routers: contain routes from remote customer nets
+#########################################################################
+# ce1 vtysh -c "show bgp ipv4 uni"
+# r1 vtysh -c "show bgp vrf r1-cust1 ipv4"
+# r1 vtysh -c "show bgp vrf r1-cust1 ipv4 5.1.2.0/24"
+
+luCommand(
+ "ce1",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "12 routes and 12",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+want = [
+ {"p": "5.1.0.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "5.1.2.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.1.3.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "99.0.0.1", "bp": True},
+ {"p": "6.0.2.0/24", "n": "99.0.0.1", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "ce1", "ipv4", "", "Cust 1 routes from remote", want, debug=False
+)
+
+luCommand(
+ "ce2",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "12 routes and 15",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+want = [
+ {"p": "5.1.0.0/24", "n": "192.168.1.1", "bp": False},
+ {"p": "5.1.0.0/24", "n": "99.0.0.2", "bp": True},
+ {"p": "5.1.1.0/24", "n": "192.168.1.1", "bp": False},
+ {"p": "5.1.1.0/24", "n": "99.0.0.2", "bp": True},
+ {"p": "5.1.2.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.1.3.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "192.168.1.1", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": True},
+ {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "ce2", "ipv4", "", "Cust 1 routes from remote", want, debug=False
+)
+
+# human readable output for debugging
+luCommand("r4", 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni"')
+luCommand("r4", 'vtysh -c "show bgp vrf r4-cust2 ipv4 uni"')
+luCommand("r4", 'vtysh -c "show bgp ipv4 vpn"')
+luCommand("r4", 'vtysh -c "show ip route vrf r4-cust1"')
+luCommand("r4", 'vtysh -c "show ip route vrf r4-cust2"')
+
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "12 routes and 14",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+# Requires bvl-bug-degenerate-no-label fix (FRR PR #2053)
+want = [
+ {"p": "5.1.0.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "192.168.1.1", "bp": False},
+ {"p": "6.0.2.0/24", "n": "192.168.1.1", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": True},
+ {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "ce3", "ipv4", "", "Cust 1 routes from remote", want, debug=False
+)
+
+luCommand(
+ "ce4",
+ 'vtysh -c "show bgp vrf ce4-cust2 ipv4 uni"',
+ "12 routes and 14",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+want = [
+ {"p": "5.1.0.0/24", "n": "192.168.2.1", "bp": True},
+ {"p": "5.1.1.0/24", "n": "192.168.2.1", "bp": True},
+ {"p": "5.1.2.0/24", "n": "192.168.2.1", "bp": True},
+ {"p": "5.1.3.0/24", "n": "192.168.2.1", "bp": True},
+ {"p": "6.0.1.0/24", "n": "192.168.2.1", "bp": False},
+ {"p": "6.0.2.0/24", "n": "192.168.2.1", "bp": False},
+ {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": True},
+ {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": True},
+]
+bgpribRequireUnicastRoutes(
+ "ce4", "ipv4", "ce4-cust2", "Cust 2 routes from remote", want, debug=False
+)
+
+# verify details of exported/imported routes
+luCommand(
+ "ce1",
+ 'vtysh -c "show bgp ipv4 uni 6.0.1.0"',
+ "1 available.*192.168.1.1.*99.0.0.1.*Community: 0:67.*Extended Community: RT:89:123.*Large Community: 12:34:56",
+ "pass",
+ "Redundant route 1 details",
+)
+luCommand(
+ "ce2",
+ 'vtysh -c "show bgp ipv4 uni 6.0.1.0"',
+ "2 available, best .*192.168.1.1.* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1"
+ + ".* Origin IGP, metric 98, localpref 123, valid, internal"
+ + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:56",
+ "pass",
+ "Redundant route 1 details",
+)
+luCommand(
+ "ce2",
+ 'vtysh -c "show bgp ipv4 uni 6.0.1.0"',
+ "2 available, best .*192.168.1.1.* Local.* 99.0.0.2 from 0.0.0.0 .99.0.0.2"
+ + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:56",
+ "pass",
+ "Redundant route 1 details",
+)
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni 6.0.1.0"',
+ "2 available, best "
+ ".* Local.* 99.0.0.3 from 0.0.0.0 .99.0.0.3"
+ + ".* Origin IGP, metric 200, localpref 50, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:56",
+ "pass",
+ "Redundant route 1 details",
+)
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni 6.0.1.0"',
+ "2 available, best "
+ ".* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1"
+ + ".* Origin IGP, metric 98, localpref 123, valid, internal"
+ + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:56",
+ "pass",
+ "Redundant route 1 details",
+)
+luCommand(
+ "ce4",
+ 'vtysh -c "show bgp vrf ce4-cust2 ipv4 6.0.1.0 json"',
+ (
+ '{"paths":['
+ + '{"aspath":{"string":"Local"},"origin":"IGP","metric":200,"locPrf":50,'
+ + '"weight":32768,"valid":true,"sourced":true,"local":true,'
+ + '"bestpath":{"overall":true,"selectionReason":"Weight"},'
+ + '"community":{"string":"0:67"},"extendedCommunity":{"string":"RT:89:123"},'
+ + '"largeCommunity":{"string":"12:34:56"},'
+ + '"peer":{"peerId":"0.0.0.0","routerId":"99.0.0.4"}},'
+ + '{"aspath":{"string":"Local"},"origin":"IGP","metric":98,"locPrf":123,'
+ + '"valid":true,'
+ + '"community":{"string":"0:67"},"extendedCommunity":{'
+ + '"string":"RT:52:100 RT:89:123"},"largeCommunity":{"string":"12:34:56"},'
+ + '"peer":{"peerId":"192.168.2.1","routerId":"192.168.2.1"}}'
+ + "]}"
+ ),
+ "jsoncmp_pass",
+ "Redundant route 1 details",
+)
+
+luCommand(
+ "ce1",
+ 'vtysh -c "show bgp ipv4 uni 6.0.2.0"',
+ "2 available, best .*192.168.1.1.* Local.* 99.0.0.1 from 0.0.0.0 .99.0.0.1"
+ + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:11",
+ "pass",
+ "Redundant route 2 details",
+)
+luCommand(
+ "ce2",
+ 'vtysh -c "show bgp ipv4 uni 6.0.2.0"',
+ "2 available, best .*192.168.1.1.* Local.* 99.0.0.2 from 0.0.0.0 .99.0.0.2"
+ + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:12",
+ "pass",
+ "Redundant route 2 details",
+)
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni 6.0.2.0"',
+ "2 available, best .*192.168.1.1.* Local.* 99.0.0.3 from 0.0.0.0 .99.0.0.3"
+ + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:13",
+ "pass",
+ "Redundant route 2 details",
+)
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni 6.0.2.0"',
+ "2 available, best .*192.168.1.1.* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1"
+ + ".* Origin IGP, metric 100, localpref 100, valid, internal"
+ + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:11",
+ "pass",
+ "Redundant route 2 details",
+)
+luCommand(
+ "ce4",
+ 'vtysh -c "show bgp vrf ce4-cust2 ipv4 6.0.2.0"',
+ "2 available, best .*192.168.2.1.* Local.* 192.168.2.1 from 192.168.2.1 .192.168.2.1"
+ + ".* Origin IGP, metric 100, localpref 100, valid, internal"
+ + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:11",
+ "pass",
+ "Redundant route 2 details",
+)
+luCommand(
+ "ce4",
+ 'vtysh -c "show bgp vrf ce4-cust2 ipv4 6.0.2.0"',
+ "2 available, best .*192.168.2.1.* Local.* 99.0.0.4 from 0.0.0.0 .99.0.0.4"
+ + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight"
+ + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:14",
+ "pass",
+ "Redundant route 2 details",
+)
+# done
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/cleanup_all.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/cleanup_all.py
new file mode 100644
index 0000000..a27b178
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/cleanup_all.py
@@ -0,0 +1,120 @@
+from lib.lutil import luCommand
+
+luCommand(
+ "r1",
+ 'vtysh -c "clear vrf r1-cust1 prefix 99.0.0.1/32"',
+ ".",
+ "none",
+ "Cleared VRF route",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "clear vrf r3-cust1 prefix 99.0.0.2/32"',
+ ".",
+ "none",
+ "Cleared VRF route",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "clear vrf r3-cust1 prefix 99.0.0.3/32"',
+ ".",
+ "none",
+ "Cleared VRF route",
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.1",
+ "fail",
+ "Local Registration cleared",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.2",
+ "fail",
+ "Local Registration cleared",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show vnc registrations local"',
+ "99.0.0.3",
+ "fail",
+ "Local Registration cleared",
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Unicast SAFI updated",
+ 10,
+)
+luCommand(
+ "r2",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "No BGP prefixes displayed",
+ "pass",
+ "Unicast SAFI",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Unicast SAFI updated",
+ 10,
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Unicast SAFI updated",
+ 10,
+)
+luCommand(
+ "ce1",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+luCommand(
+ "ce2",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+luCommand(
+ "ce3",
+ 'vtysh -c "show bgp ipv4 uni"',
+ "2 routes and 2",
+ "wait",
+ "Local and remote routes",
+ 10,
+)
+luCommand(
+ "r1",
+ 'vtysh -c "show vnc registrations remote"',
+ "Prefix ",
+ "fail",
+ "Remote Registration cleared",
+)
+luCommand(
+ "r3",
+ 'vtysh -c "show vnc registrations remote"',
+ "Prefix ",
+ "fail",
+ "Remote Registration cleared",
+)
+luCommand(
+ "r4",
+ 'vtysh -c "show vnc registrations remote"',
+ "Prefix ",
+ "fail",
+ "Remote Registration cleared",
+)
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/del_bgp_instances.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/del_bgp_instances.py
new file mode 100644
index 0000000..fcbc3df
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/del_bgp_instances.py
@@ -0,0 +1,30 @@
+from lib.lutil import luCommand
+
+luCommand(
+ "r1",
+ '/usr/lib/frr/vtysh -c "conf ter" -c "no router bgp 5227 vrf r1-cust1" -c "no router bgp 5226"',
+ ".",
+ "none",
+ "Cleared bgp instances",
+)
+luCommand(
+ "r2",
+ '/usr/lib/frr/vtysh -c "conf ter" -c "no router bgp 5226"',
+ ".",
+ "none",
+ "Cleared bgp instances",
+)
+luCommand(
+ "r3",
+ '/usr/lib/frr/vtysh -c "conf ter" -c "no router bgp 5227 vrf r3-cust1" -c "no router bgp 5226"',
+ ".",
+ "none",
+ "Cleared bgp instances",
+)
+luCommand(
+ "r4",
+ '/usr/lib/frr/vtysh -c "conf ter" -c "no router bgp 5228 vrf r4-cust2" -c "no router bgp 5227 vrf r4-cust1" -c "no router bgp 5226"',
+ ".",
+ "none",
+ "Cleared bgp instances",
+)
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py
new file mode 100644
index 0000000..73cd08f
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/notification_check.py
@@ -0,0 +1,22 @@
+from lib.lutil import luCommand, luLast
+
+rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
+for rtr in rtrs:
+ ret = luCommand(
+ rtr,
+ 'vtysh -c "show bgp neigh"',
+ "Notification received .([A-Za-z0-9/ ]*)",
+ "none",
+ "collect neighbor stats",
+ )
+ found = luLast()
+ if ret != False and found != None:
+ val = found.group(1)
+ ret = luCommand(
+ rtr,
+ 'vtysh -c "show bgp neigh"',
+ "Notification received",
+ "fail",
+ "Notify RXed! {}".format(val),
+ )
+# done
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py
new file mode 100644
index 0000000..36be926
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py
@@ -0,0 +1,87 @@
+from lib.lutil import luCommand, luLast
+
+ret = luCommand(
+ "ce1",
+ 'vtysh -c "show ip route" | grep -c \\ 10\\.\\*/32',
+ "(.*)",
+ "pass",
+ "Looking for sharp routes",
+)
+found = luLast()
+if ret != False and found != None:
+ num = int(found.group())
+ luCommand(
+ "ce3", 'vtysh -c "show bgp sum"', ".", "pass", "See %s sharp routes" % num
+ )
+ if num > 0:
+ rtrs = ["ce1", "ce2", "ce3"]
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ 'vtysh -c "show bgp ipv4 uni" | grep Display',
+ ".",
+ "none",
+ "BGP routes pre remove",
+ )
+ luCommand(
+ rtr,
+ "ip route show | cat -n | tail",
+ ".",
+ "none",
+ "Linux routes pre remove",
+ )
+ wait = 2 * num / 500
+ luCommand(
+ "ce1",
+ 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),
+ ".",
+ "none",
+ "Removing {} routes".format(num),
+ )
+ luCommand(
+ "ce2",
+ 'vtysh -c "sharp remove routes 10.0.0.0 {}"'.format(num),
+ ".",
+ "none",
+ "Removing {} routes".format(num),
+ )
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ 'vtysh -c "show bgp ipv4 uni" | grep Display',
+ " 12 route",
+ "wait",
+ "BGP routes removed",
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ rtr,
+ 'vtysh -c "show bgp ipv4 uni"',
+ ".",
+ "none",
+ "BGP routes post remove",
+ )
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip route show | grep -c \\^10\\.",
+ "^0$",
+ "wait",
+ "Linux routes removed",
+ wait,
+ wait_time=10,
+ )
+ luCommand(rtr, "ip route show", ".", "none", "Linux routes post remove")
+ rtrs = ["r1", "r3", "r4"]
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip route show vrf {}-cust1 | grep -c \\^10\\.".format(rtr),
+ "^0$",
+ "wait",
+ "VRF route removed",
+ wait,
+ wait_time=10,
+ )
+# done
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py
new file mode 100644
index 0000000..eaa6aa4
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_up.py
@@ -0,0 +1,234 @@
+from lib.lutil import luCommand, luLast
+
+num = 50000
+b = int(num / (256 * 256))
+if b > 0:
+ r = num - b * (256 * 256)
+else:
+ r = num
+c = int(r / 256)
+if c > 0:
+ d = r - c * 256 - 1
+else:
+ d = r
+wait = 2 * num / 1000
+mem_z = {}
+mem_b = {}
+rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
+for rtr in rtrs:
+ mem_z[rtr] = {"value": 0, "units": "unknown"}
+ mem_b[rtr] = {"value": 0, "units": "unknown"}
+ ret = luCommand(
+ rtr,
+ 'vtysh -c "show memory"',
+ r"zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)",
+ "none",
+ "collect bgpd memory stats",
+ )
+ found = luLast()
+ if ret != False and found != None:
+ mem_z[rtr] = {"value": int(found.group(1)), "units": found.group(2)}
+ mem_b[rtr] = {"value": int(found.group(3)), "units": found.group(4)}
+
+luCommand(
+ "ce1", 'vtysh -c "show mem"', "qmem sharpd", "none", "check if sharpd running"
+)
+doSharp = False
+found = luLast()
+if ret != False and found != None:
+ if len(found.group()):
+ doSharp = True
+
+if doSharp != True:
+ luCommand(
+ "ce1",
+ 'vtysh -c "sharp data nexthop"',
+ ".",
+ "pass",
+ "sharpd NOT running, skipping test",
+ )
+else:
+ luCommand(
+ "ce1",
+ 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.1 {}"'.format(num),
+ "",
+ "pass",
+ "Adding {} routes".format(num),
+ )
+ luCommand(
+ "ce2",
+ 'vtysh -c "sharp install routes 10.0.0.0 nexthop 99.0.0.2 {}"'.format(num),
+ "",
+ "pass",
+ "Adding {} routes".format(num),
+ )
+ rtrs = ["ce1", "ce2", "ce3"]
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ 'vtysh -c "show bgp ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
+ "Last update:",
+ "wait",
+ "RXed last route, 10.{}.{}.{}".format(b, c, d),
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ rtr,
+ 'vtysh -c "show bgp ipv4 uni" | grep -c 10\\.\\*/32',
+ str(num),
+ "wait",
+ "See all sharp routes in BGP",
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ "r1",
+ 'vtysh -c "show bgp vrf r1-cust1 ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
+ "99.0.0.1",
+ "wait",
+ "RXed -> 10.{}.{}.{} from CE1".format(b, c, d),
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ "r3",
+ 'vtysh -c "show bgp vrf r3-cust1 ipv4 uni 10.{}.{}.{}"'.format(b, c, d),
+ "99.0.0.2",
+ "wait",
+ "RXed -> 10.{}.{}.{} from CE2".format(b, c, d),
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "99.0.0.1",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
+ )
+ luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "99.0.0.2",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
+ )
+ luCommand(
+ "r3",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "1.1.1.1",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
+ )
+ luCommand(
+ "r1",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "3.3.3.3",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
+ )
+ luCommand(
+ "r4",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "1.1.1.1",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE1".format(b, c, d),
+ )
+ luCommand(
+ "r4",
+ 'vtysh -c "show bgp ipv4 vpn 10.{}.{}.{}"'.format(b, c, d),
+ "3.3.3.3",
+ "wait",
+ "see VPN safi -> 10.{}.{}.{} from CE2".format(b, c, d),
+ )
+ rtrs = ["ce1", "ce2", "ce3"]
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip route get 10.{}.{}.{}".format(b, c, d),
+ "dev",
+ "wait",
+ "Route to 10.{}.{}.{} available".format(b, c, d),
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ rtr,
+ "ip route show | grep -c \\^10\\.",
+ str(num),
+ "wait",
+ "See {} linux routes".format(num),
+ wait,
+ wait_time=10,
+ )
+
+ rtrs = ["r1", "r3", "r4"]
+ for rtr in rtrs:
+ luCommand(
+ rtr,
+ "ip route get vrf {}-cust1 10.{}.{}.{}".format(rtr, b, c, d),
+ "dev",
+ "wait",
+ "VRF route available",
+ wait,
+ wait_time=10,
+ )
+ luCommand(
+ rtr,
+ "ip route show vrf {}-cust1 | grep -c \\^10\\.".format(rtr),
+ str(num),
+ "wait",
+ "See {} linux routes".format(num),
+ wait,
+ wait_time=10,
+ )
+ rtrs = ["ce1", "ce2", "ce3", "r1", "r2", "r3", "r4"]
+ for rtr in rtrs:
+ ret = luCommand(
+ rtr,
+ 'vtysh -c "show memory"',
+ r"zebra: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*) .*bgpd: System allocator statistics: Total heap allocated: *(\d*) ([A-Za-z]*)",
+ "none",
+ "collect bgpd memory stats",
+ )
+ found = luLast()
+ if ret != False and found != None:
+ val_z = int(found.group(1))
+ if mem_z[rtr]["units"] != found.group(2):
+ val_z *= 1000
+ delta_z = val_z - int(mem_z[rtr]["value"])
+ ave_z = float(delta_z) / float(num)
+
+ val_b = int(found.group(3))
+ if mem_b[rtr]["units"] != found.group(4):
+ val_b *= 1000
+ delta_b = val_b - int(mem_b[rtr]["value"])
+ ave_b = float(delta_b) / float(num)
+ luCommand(
+ rtr,
+ 'vtysh -c "show thread cpu"',
+ ".",
+ "pass",
+ "BGPd heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)".format(
+ mem_b[rtr]["value"],
+ mem_b[rtr]["units"],
+ found.group(3),
+ found.group(4),
+ round(ave_b, 4),
+ ),
+ )
+ luCommand(
+ rtr,
+ 'vtysh -c "show thread cpu"',
+ ".",
+ "pass",
+ "Zebra heap: {0} {1} --> {2} {3} ({4} {1}/vpn route)".format(
+ mem_z[rtr]["value"],
+ mem_z[rtr]["units"],
+ found.group(1),
+ found.group(2),
+ round(ave_z, 4),
+ ),
+ )
+# done
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py
new file mode 100755
index 0000000..3844b5e
--- /dev/null
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/test_bgp_l3vpn_to_bgp_vrf.py
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+
+#
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2018, LabN Consulting, L.L.C.
+# Authored by Lou Berger <lberger@labn.net>
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+import os
+import sys
+import pytest
+
+sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
+
+from lib.ltemplate import *
+
+pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd]
+
+
+def test_check_linux_vrf():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest("scripts/check_linux_vrf.py", False, CliOnFail, CheckFunc)
+
+
+def test_adjacencies():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True)'
+ ltemplateTest("scripts/adjacencies.py", False, CliOnFail, CheckFunc)
+
+
+def test_notification_check():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest("scripts/notification_check.py", False, CliOnFail, CheckFunc)
+
+
+def SKIP_test_add_routes():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True)'
+ ltemplateTest("scripts/add_routes.py", False, CliOnFail, CheckFunc)
+
+
+def test_check_routes():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True)'
+ ltemplateTest("scripts/check_routes.py", False, CliOnFail, CheckFunc)
+
+
+# manual data path setup test - remove once have bgp/zebra vrf path working
+def test_check_linux_mpls():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest("scripts/check_linux_mpls.py", False, CliOnFail, CheckFunc)
+
+
+def test_check_scale_up():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest("scripts/scale_up.py", False, CliOnFail, CheckFunc)
+
+
+def test_check_scale_down():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1', iproute2='4.9')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True, iproute2=\'4.9\')'
+ ltemplateTest("scripts/scale_down.py", False, CliOnFail, CheckFunc)
+
+
+def SKIP_test_cleanup_all():
+ CliOnFail = None
+ # For debugging, uncomment the next line
+ # CliOnFail = 'tgen.mininet_cli'
+ CheckFunc = "ltemplateVersionCheck('4.1')"
+ # uncomment next line to start cli *before* script is run
+ # CheckFunc = 'ltemplateVersionCheck(\'4.1\', cli=True)'
+ ltemplateTest("scripts/cleanup_all.py", False, CliOnFail, CheckFunc)
+
+
+if __name__ == "__main__":
+ retval = pytest.main(["-s"])
+ sys.exit(retval)