diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
commit | e2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch) | |
tree | f0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/topotests/bgp_l3vpn_to_bgp_direct | |
parent | Initial commit. (diff) | |
download | frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip |
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/bgp_l3vpn_to_bgp_direct')
29 files changed, 1204 insertions, 0 deletions
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/__init__.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/__init__.py new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/__init__.py diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/ce1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce1/bgpd.conf new file mode 100644 index 0000000..8b88534 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce1/bgpd.conf @@ -0,0 +1,32 @@ +frr defaults traditional +! +hostname ce1 +password zebra +log stdout notifications +log commands +router bgp 5226 + no bgp network import-check + bgp router-id 99.0.0.1 + no bgp ebgp-requires-policy + neighbor 192.168.1.1 remote-as 5226 + neighbor 192.168.1.1 update-source 192.168.1.2 + neighbor 192.168.1.1 timers 3 10 + address-family ipv4 unicast + network 5.1.0.0/24 route-map rm-nh + network 5.1.1.0/24 route-map rm-nh + 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 +! + +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/ce1/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce1/zebra.conf new file mode 100644 index 0000000..46831bb --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/ce2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce2/bgpd.conf new file mode 100644 index 0000000..2accaae --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce2/bgpd.conf @@ -0,0 +1,32 @@ +frr defaults traditional +! +hostname ce2 +password zebra +log stdout notifications +log commands +router bgp 5226 + no bgp network import-check + bgp router-id 99.0.0.2 + no bgp ebgp-requires-policy + neighbor 192.168.1.1 remote-as 5226 + neighbor 192.168.1.1 update-source 192.168.1.2 + neighbor 192.168.1.1 timers 3 10 + address-family ipv4 unicast + network 5.1.0.0/24 route-map rm-nh + network 5.1.1.0/24 route-map rm-nh + 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 +! + +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/ce2/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce2/zebra.conf new file mode 100644 index 0000000..fb4d8cc --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/ce3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce3/bgpd.conf new file mode 100644 index 0000000..42eff1b --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce3/bgpd.conf @@ -0,0 +1,32 @@ +frr defaults traditional +! +hostname ce3 +password zebra +log stdout notifications +log commands +router bgp 5226 + no bgp network import-check + bgp router-id 99.0.0.3 + no bgp ebgp-requires-policy + neighbor 192.168.1.1 remote-as 5226 + neighbor 192.168.1.1 update-source 192.168.1.2 + neighbor 192.168.1.1 timers 3 10 + address-family ipv4 unicast + network 5.1.2.0/24 route-map rm-nh + network 5.1.3.0/24 route-map rm-nh + 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 +! + +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/ce3/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/ce3/zebra.conf new file mode 100644 index 0000000..77a1163 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py new file mode 100644 index 0000000..41114b6 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# Part of NetDEF Topology Tests +# +# Copyright (c) 2017 by +# Network Device Education Foundation, Inc. ("NetDEF") +# + +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 | + | 3.3.3.3 | | 4.4.4.4 | PE Routers + +-----------+ +---------+ + 192.168.1. | .1 192.168.1. | .1 rX-eth4 + | .2 | .2 ceX-eth0 + +-----+-----+ +----+-----+ + | ce2 | | ce3 | + | 99.0.0.2 | | 99.0.0.3 | CE Routers + +-----+-----+ +----+-----+ + | | + +""" + +import os + +# pylint: disable=C0413 +# Import topogen and topotest helpers +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 + tgen.add_router("r1") + # check for mpls + if tgen.hasmpls != True: + logger.info("MPLS not available, tests will be skipped") + return + for routern in range(2, 5): + tgen.add_router("r{}".format(routern)) + # Create CE routers + for routern in range(1, 4): + 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") + + # 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() + tgen = get_topogen() + logger.info("pre router-start hook") + # check for mpls + if tgen.hasmpls != True: + logger.info("MPLS not available, skipping setup") + return False + logger.info("setup mpls input") + return True + + +def ltemplatePostRouterStartHook(): + logger.info("post router-start hook") + return True diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/bgpd.conf new file mode 100644 index 0000000..a564da9 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/bgpd.conf @@ -0,0 +1,42 @@ +frr defaults traditional +! +hostname r1 +password zebra +log stdout notifications +log commands +router bgp 5226 + bgp router-id 1.1.1.1 + bgp cluster-id 1.1.1.1 + no bgp ebgp-requires-policy + neighbor 192.168.1.2 remote-as 5226 + neighbor 192.168.1.2 update-source 192.168.1.1 + neighbor 192.168.1.2 route-reflector-client + neighbor 192.168.1.2 timers 3 10 + 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 + redistribute vnc-direct + neighbor 192.168.1.2 activate + neighbor 192.168.1.2 next-hop-self + no neighbor 2.2.2.2 activate + exit-address-family +! + address-family ipv4 vpn + neighbor 2.2.2.2 activate + exit-address-family +! + vrf-policy cust1 + label 101 + rd 10:1 + rt both 52:100 + nexthop 192.168.1.1 + exit-vrf-policy +! + vnc export bgp mode group-nve + vnc export bgp group-nve group cust1 + vnc redistribute mode resolve-nve + vnc redistribute ipv4 bgp-direct + ! +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/ldpd.conf new file mode 100644 index 0000000..f7f2714 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/ldpd.conf @@ -0,0 +1,23 @@ +hostname r1 +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 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_direct/r1/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/ospfd.conf new file mode 100644 index 0000000..460a8fb --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/r1/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/zebra.conf new file mode 100644 index 0000000..767e17e --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r1/zebra.conf @@ -0,0 +1,27 @@ +log file zebra.log +! +hostname r1 +! +interface lo + mpls + ip address 1.1.1.1/32 +! +interface r1-eth0 + description to sw0 + mpls + ip address 10.0.1.1/24 + no link-detect +! +interface r1-eth4 + description to ce1 + mpls + ip address 192.168.1.1/24 + no link-detect +! +ip route 99.0.0.1/32 192.168.1.2 +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/bgpd.conf new file mode 100644 index 0000000..3167306 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/bgpd.conf @@ -0,0 +1,33 @@ +frr defaults traditional +! +hostname r2 +password zebra +log stdout notifications +log commands +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_direct/r2/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/ldpd.conf new file mode 100644 index 0000000..c4056e0 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/ldpd.conf @@ -0,0 +1,25 @@ +hostname r2 +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 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_direct/r2/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/ospfd.conf new file mode 100644 index 0000000..dbed618 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/r2/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/zebra.conf new file mode 100644 index 0000000..829ac96 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r2/zebra.conf @@ -0,0 +1,31 @@ +log file zebra.log +! +hostname r2 +! +interface lo + mpls + ip address 2.2.2.2/32 +! +interface r2-eth0 + description to sw0 + mpls + ip address 10.0.1.2/24 + no link-detect +! +interface r2-eth1 + description to sw1 + mpls + ip address 10.0.2.2/24 + no link-detect +! +interface r2-eth2 + description to sw2 + mpls + ip address 10.0.3.2/24 + no link-detect +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/bgpd.conf new file mode 100644 index 0000000..445da08 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/bgpd.conf @@ -0,0 +1,41 @@ +frr defaults traditional +! +hostname r3 +password zebra +log stdout notifications +log commands +router bgp 5226 + bgp router-id 3.3.3.3 + bgp cluster-id 3.3.3.3 + no bgp ebgp-requires-policy + neighbor 192.168.1.2 remote-as 5226 + neighbor 192.168.1.2 update-source 192.168.1.2 + neighbor 192.168.1.2 route-reflector-client + neighbor 192.168.1.2 timers 3 10 + 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 + redistribute vnc-direct + neighbor 192.168.1.2 activate + neighbor 192.168.1.2 next-hop-self + no neighbor 2.2.2.2 activate + exit-address-family + address-family ipv4 vpn + neighbor 2.2.2.2 activate + exit-address-family +! + vrf-policy cust1 + label 103 + rd 10:3 + rt both 52:100 + nexthop 192.168.1.1 + exit-vrf-policy +! + vnc export bgp mode group-nve + vnc export bgp group-nve group cust1 + vnc redistribute mode resolve-nve + vnc redistribute ipv4 bgp-direct +! +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/ldpd.conf new file mode 100644 index 0000000..48956cb --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/ldpd.conf @@ -0,0 +1,23 @@ +hostname r3 +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_direct/r3/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/ospfd.conf new file mode 100644 index 0000000..0e64ed6 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/r3/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/zebra.conf new file mode 100644 index 0000000..916dabf --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r3/zebra.conf @@ -0,0 +1,32 @@ +log file zebra.log +! +hostname r3 +! +interface lo + mpls + ip address 3.3.3.3/32 +! +interface r3-eth0 + description to sw1 + mpls + 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 + mpls + ip address 192.168.1.1/24 + no link-detect +! +ip route 99.0.0.2/32 192.168.1.2 +! +ip forwarding +! +! +line vty +! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/bgpd.conf new file mode 100644 index 0000000..1941352 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/bgpd.conf @@ -0,0 +1,41 @@ +frr defaults traditional +! +hostname r4 +password zebra +log stdout notifications +log commands +router bgp 5226 + bgp router-id 4.4.4.4 + bgp cluster-id 4.4.4.4 + no bgp ebgp-requires-policy + neighbor 192.168.1.2 remote-as 5226 + neighbor 192.168.1.2 update-source 192.168.1.1 + neighbor 192.168.1.2 route-reflector-client + neighbor 192.168.1.2 timers 3 10 + 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 + redistribute vnc-direct + neighbor 192.168.1.2 activate + neighbor 192.168.1.2 next-hop-self + no neighbor 2.2.2.2 activate + exit-address-family + address-family ipv4 vpn + neighbor 2.2.2.2 activate + exit-address-family +! + vrf-policy cust1 + label 104 + rd 10:4 + rt both 52:100 + nexthop 192.168.1.1 + exit-vrf-policy +! + vnc export bgp mode group-nve + vnc export bgp group-nve group cust1 + vnc redistribute mode resolve-nve + vnc redistribute ipv4 bgp-direct +! +end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/ldpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/ldpd.conf new file mode 100644 index 0000000..1d04aa0 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/ldpd.conf @@ -0,0 +1,23 @@ +hostname r4 +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_direct/r4/ospfd.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/ospfd.conf new file mode 100644 index 0000000..89e37df --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/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_direct/r4/zebra.conf b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/zebra.conf new file mode 100644 index 0000000..e08ac86 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/r4/zebra.conf @@ -0,0 +1,26 @@ +log file zebra.log +! +hostname r4 +! +interface lo + mpls + ip address 4.4.4.4/32 +! +interface r4-eth0 + description to sw1 + mpls + ip address 10.0.2.4/24 + no link-detect +! +interface r4-eth4 + description to ce3 + mpls + ip address 192.168.1.1/24 + no link-detect +! +ip route 99.0.0.3/32 192.168.1.2 +! +ip forwarding +! +line vty +! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/add_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/add_routes.py new file mode 100644 index 0000000..0deb181 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/add_routes.py @@ -0,0 +1,193 @@ +from lib.lutil import luCommand + +luCommand( + "r1", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" +) +luCommand( + "r3", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" +) +luCommand( + "r4", 'vtysh -c "show bgp next"', "99.0.0.. valid", "wait", "See CE static NH" +) +luCommand("r1", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") +luCommand("r3", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") +luCommand("r4", 'vtysh -c "show bgp ipv4 uni"', "i5.*i5", "wait", "See CE routes") +luCommand("ce1", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") +luCommand("r1", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") +luCommand("ce2", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") +luCommand("r3", 'vtysh -c "show bgp ipv4 uni 5.1.0.0/24"', "", "none", "See CE routes") +luCommand("ce3", 'vtysh -c "show bgp ipv4 uni 5.1.2.0/24"', "", "none", "See CE routes") +luCommand("r4", 'vtysh -c "show bgp ipv4 uni 5.1.2.0/24"', "", "none", "See CE routes") + +luCommand( + "r1", 'vtysh -c "add vrf cust1 prefix 99.0.0.1/32"', ".", "none", "IP Address" +) +luCommand( + "r1", + 'vtysh -c "show vnc registrations local"', + "99.0.0.1", + "wait", + "Local Registration", +) +luCommand( + "r1", + 'vtysh -c "show vnc registrations imported"', + "2 out of 2 imported", + "wait", + "Imported Registrations", +) +luCommand( + "r3", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.1/32", + "wait", + "See R1s static address", +) +luCommand( + "r4", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.1/32", + "wait", + "See R1s static address", +) +luCommand( + "r3", 'vtysh -c "show bgp ipv4 vpn rd 10:1"', "i5.*i5", "wait", "See R1s imports" +) +luCommand( + "r4", 'vtysh -c "show bgp ipv4 vpn rd 10:1"', "i5.*i5", "wait", "See R1s imports" +) + +luCommand( + "r3", 'vtysh -c "add vrf cust1 prefix 99.0.0.2/32"', ".", "none", "IP Address" +) +luCommand( + "r3", + 'vtysh -c "show vnc registrations local"', + "99.0.0.2", + "wait", + "Local Registration", +) +have2ndImports = luCommand( + "r3", + 'vtysh -c "show vnc registrations imported"', + "2 out of 2 imported", + "none", + "Imported Registrations", + 2, +) +if have2ndImports: + luCommand( + "r3", + 'vtysh -c "show vnc registrations imported"', + "2 out of 2 imported", + "pass", + "Imported Registrations", + ) +luCommand( + "r1", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.2/32", + "wait", + "See R3s static address", +) +luCommand( + "r4", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.2/32", + "wait", + "See R3s static address", +) +if have2ndImports: + luCommand( + "r1", + 'vtysh -c "show bgp ipv4 vpn rd 10:3"', + "i5.*i5", + "none", + "See R3s imports", + ) + luCommand( + "r4", + 'vtysh -c "show bgp ipv4 vpn rd 10:3"', + "i5.*i5", + "none", + "See R3s imports", + ) + +luCommand( + "r4", 'vtysh -c "add vrf cust1 prefix 99.0.0.3/32"', ".", "none", "IP Address" +) +luCommand( + "r4", + 'vtysh -c "show vnc registrations local"', + "99.0.0.3", + "wait", + "Local Registration", +) +luCommand( + "r4", + 'vtysh -c "show vnc registrations imported"', + "2 out of 2 imported", + "wait", + "Imported Registrations", +) +luCommand( + "r1", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.3/32", + "wait", + "See R4s static address", +) +luCommand( + "r3", + 'vtysh -c "show bgp ipv4 vpn"', + "i99.0.0.3/32", + "wait", + "See R4s static address", +) +luCommand( + "r1", 'vtysh -c "show bgp ipv4 vpn rd 10:4"', "i5.*i5", "wait", "See R4s imports" +) +luCommand( + "r3", 'vtysh -c "show bgp ipv4 vpn rd 10:4"', "i5.*i5", "wait", "See R4s imports" +) + + +luCommand( + "r1", + 'vtysh -c "show vnc registrations remote"', + "5.1.2.0/24 .*5.1.3.0/24", + "wait", + "R4s registrations", +) +luCommand( + "r3", + 'vtysh -c "show vnc registrations remote"', + "5.1.2.0/24 .*5.1.3.0/24", + "wait", + "R4s registrations", +) +if have2ndImports: + luCommand( + "r1", + 'vtysh -c "show vnc registrations remote"', + "5.1.0.0/24 .*5.1.1.0/24", + "wait", + "Remote registrations", + ) + luCommand( + "r3", + 'vtysh -c "show vnc registrations remote"', + "5.1.0.0/24 .*5.1.1.0/24", + "wait", + "Remote registrations", + ) +luCommand( + "r4", + 'vtysh -c "show vnc registrations remote"', + "5.1.0.0/24 .*5.1.1.0/24", + "wait", + "Remote registrations", +) +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_direct/scripts/adjacencies.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/adjacencies.py new file mode 100644 index 0000000..6cd92e2 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/adjacencies.py @@ -0,0 +1,71 @@ +from lib.lutil import luCommand + +luCommand("ce1", "ping 192.168.1.1 -c 1", " 0. packet loss", "pass", "CE->PE ping") +luCommand("ce2", "ping 192.168.1.1 -c 1", " 0. packet loss", "pass", "CE->PE ping") +luCommand("ce3", "ping 192.168.1.1 -c 1", " 0. packet loss", "pass", "CE->PE ping") +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( + "r1", 'vtysh -c "show ip route ospf"', "2.2.2.2", "wait", "OSPF Route has Arrived", 60) +luCommand( + "r1", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60 +) +luCommand( + "r3", 'vtysh -c "show ip route ospf"', "2.2.2.2", "wait", "OSPF Route has Arrived", 60) +luCommand( + "r3", "ping 2.2.2.2 -c 1", " 0. packet loss", "wait", "PE->P2 (loopback) ping", 60 +) + +luCommand( + "r4", 'vtysh -c "show ip route ospf"', "2.2.2.2", "wait", "OSPF Route has Arrived", 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", + "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_direct/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/check_routes.py new file mode 100644 index 0000000..af39a95 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/check_routes.py @@ -0,0 +1,55 @@ +from lib.lutil import luCommand + +luCommand( + "ce1", + 'vtysh -c "show bgp ipv4 uni"', + "7 routes and 7", + "wait", + "Local and remote routes", +) +luCommand( + "ce2", + 'vtysh -c "show bgp ipv4 uni"', + "7 routes and 9", + "wait", + "Local and remote routes", +) +luCommand( + "ce3", + 'vtysh -c "show bgp ipv4 uni"', + "7 routes and 7", + "wait", + "Local and remote routes", +) +luCommand( + "r1", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 9", "pass", "Unicast SAFI" +) +luCommand( + "r2", + 'vtysh -c "show bgp ipv4 uni"', + "No BGP prefixes displayed", + "pass", + "Unicast SAFI", +) +luCommand( + "r3", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 9", "pass", "Unicast SAFI" +) +luCommand( + "r4", 'vtysh -c "show bgp ipv4 uni"', "7 routes and 9", "pass", "Unicast SAFI" +) +have2ndImports = luCommand( + "r3", + 'vtysh -c "show vnc registrations imported"', + "2 out of 2 imported", + "none", + "Imported Registrations", + 2, +) +if have2ndImports: + num = "9 routes and 9" +else: + num = "7 routes and 7" +luCommand("r1", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI") +luCommand("r2", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI") +luCommand("r3", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI") +luCommand("r4", 'vtysh -c "show bgp ipv4 vpn"', num, "pass", "VPN SAFI") diff --git a/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/cleanup_all.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/cleanup_all.py new file mode 100644 index 0000000..38eac14 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/scripts/cleanup_all.py @@ -0,0 +1,114 @@ +from lib.lutil import luCommand + +luCommand( + "r1", + 'vtysh -c "clear vrf cust1 prefix 99.0.0.1/32"', + ".", + "none", + "Cleared VRF route", +) +luCommand( + "r3", + 'vtysh -c "clear vrf cust1 prefix 99.0.0.2/32"', + ".", + "none", + "Cleared VRF route", +) +luCommand( + "r4", + 'vtysh -c "clear vrf 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", +) +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", +) +luCommand( + "r4", + 'vtysh -c "show bgp ipv4 uni"', + "2 routes and 2", + "wait", + "Unicast SAFI updated", +) +luCommand( + "ce1", + 'vtysh -c "show bgp ipv4 uni"', + "2 routes and 2", + "wait", + "Local and remote routes", +) +luCommand( + "ce2", + 'vtysh -c "show bgp ipv4 uni"', + "2 routes and 2", + "wait", + "Local and remote routes", +) +luCommand( + "ce3", + 'vtysh -c "show bgp ipv4 uni"', + "2 routes and 2", + "wait", + "Local and remote routes", +) +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_direct/test_bgp_l3vpn_to_bgp_direct.py b/tests/topotests/bgp_l3vpn_to_bgp_direct/test_bgp_l3vpn_to_bgp_direct.py new file mode 100755 index 0000000..7930f09 --- /dev/null +++ b/tests/topotests/bgp_l3vpn_to_bgp_direct/test_bgp_l3vpn_to_bgp_direct.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# Part of NetDEF Topology Tests +# +# Copyright (c) 2018, LabN Consulting, L.L.C. +# Authored by Lou Berger <lberger@labn.net> +# + +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_adjacencies(): + CliOnFail = None + # For debugging, uncomment the next line + # CliOnFail = 'tgen.mininet_cli' + CheckFunc = "ltemplateVersionCheck('3.1')" + # uncomment next line to start cli *before* script is run + # CheckFunc = 'ltemplateVersionCheck(\'3.1\', cli=True)' + ltemplateTest("scripts/adjacencies.py", False, CliOnFail, CheckFunc) + + +def test_add_routes(): + CliOnFail = None + # For debugging, uncomment the next line + # CliOnFail = 'tgen.mininet_cli' + CheckFunc = "ltemplateVersionCheck('3.1')" + # uncomment next line to start cli *before* script is run + # CheckFunc = 'ltemplateVersionCheck(\'3.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('3.1')" + # uncomment next line to start cli *before* script is run + # CheckFunc = 'ltemplateVersionCheck(\'3.1\', cli=True)' + ltemplateTest("scripts/check_routes.py", False, CliOnFail, CheckFunc) + + +def test_cleanup_all(): + CliOnFail = None + # For debugging, uncomment the next line + # CliOnFail = 'tgen.mininet_cli' + CheckFunc = "ltemplateVersionCheck('3.1')" + # uncomment next line to start cli *before* script is run + # CheckFunc = 'ltemplateVersionCheck(\'3.1\', cli=True)' + ltemplateTest("scripts/cleanup_all.py", False, CliOnFail, CheckFunc) + + +if __name__ == "__main__": + retval = pytest.main(["-s"]) + sys.exit(retval) |