Skip to content

Commit 1b0243e

Browse files
committed
topotests: bgp_vpnv4_gre, add l3vpn route-map test for gretap
Add a test that demonstrates that an MPLS path can be installed over a GRETAP interface, if a route-map autorises it. Signed-off-by: Philippe Guibert <[email protected]>
1 parent 09d8e96 commit 1b0243e

File tree

4 files changed

+79
-11
lines changed

4 files changed

+79
-11
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
router bgp 65500
2+
bgp router-id 192.0.2.1
3+
neighbor 192.0.2.2 remote-as 65500
4+
neighbor 192.0.2.2 update-source 192.0.2.1
5+
address-family ipv4 unicast
6+
no neighbor 192.0.2.2 activate
7+
exit-address-family
8+
address-family ipv4 vpn
9+
neighbor 192.0.2.2 activate
10+
neighbor 192.0.2.2 route-map rmap in
11+
exit-address-family
12+
!
13+
router bgp 65500 vrf vrf1
14+
bgp router-id 192.0.2.1
15+
address-family ipv4 unicast
16+
redistribute connected
17+
distance bgp 21 201 41
18+
label vpn export 101
19+
rd vpn export 444:1
20+
rt vpn both 52:100
21+
export vpn
22+
import vpn
23+
exit-address-family
24+
!
25+
route-map rmap permit 1
26+
set l3vpn next-hop encapsulation gretap
27+
!

tests/topotests/bgp_vpnv4_gre/test_bgp_vpnv4_gre.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
pytestmark = [pytest.mark.bgpd]
3737

38+
TUNNEL_TYPE = None
39+
3840

3941
def build_topo(tgen):
4042
"Build function"
@@ -54,29 +56,37 @@ def build_topo(tgen):
5456
switch.add_link(tgen.gears["r2"])
5557

5658

57-
def _populate_iface():
59+
def _populate_iface(mod):
60+
global TUNNEL_TYPE
61+
5862
tgen = get_topogen()
63+
64+
if "gretap" in mod.__name__:
65+
TUNNEL_TYPE = "gretap"
66+
else:
67+
TUNNEL_TYPE = "gre"
68+
5969
cmds_list = [
6070
"ip link add vrf1 type vrf table 10",
6171
"echo 10 > /proc/sys/net/mpls/platform_labels",
6272
"ip link set dev vrf1 up",
6373
"ip link set dev {0}-eth1 master vrf1",
6474
"echo 1 > /proc/sys/net/mpls/conf/{0}-eth0/input",
65-
"ip tunnel add {0}-gre0 mode gre ttl 64 dev {0}-eth0 local 10.125.0.{1} remote 10.125.0.{2}",
75+
"ip link add {0}-gre0 type {3} ttl 64 dev {0}-eth0 local 10.125.0.{1} remote 10.125.0.{2}",
6676
"ip link set dev {0}-gre0 up",
6777
"echo 1 > /proc/sys/net/mpls/conf/{0}-gre0/input",
6878
]
6979

7080
for cmd in cmds_list:
71-
input = cmd.format("r1", "1", "2")
72-
logger.info("input: " + cmd)
73-
output = tgen.net["r1"].cmd(cmd.format("r1", "1", "2"))
81+
input = cmd.format("r1", "1", "2", TUNNEL_TYPE)
82+
logger.info("input: " + input)
83+
output = tgen.net["r1"].cmd(cmd.format("r1", "1", "2", TUNNEL_TYPE))
7484
logger.info("output: " + output)
7585

7686
for cmd in cmds_list:
77-
input = cmd.format("r2", "2", "1")
78-
logger.info("input: " + cmd)
79-
output = tgen.net["r2"].cmd(cmd.format("r2", "2", "1"))
87+
input = cmd.format("r2", "2", "1", TUNNEL_TYPE)
88+
logger.info("input: " + input)
89+
output = tgen.net["r2"].cmd(cmd.format("r2", "2", "1", TUNNEL_TYPE))
8090
logger.info("output: " + output)
8191

8292

@@ -86,15 +96,18 @@ def setup_module(mod):
8696
tgen.start_topology()
8797

8898
router_list = tgen.routers()
89-
_populate_iface()
99+
_populate_iface(mod)
90100

91101
for rname, router in router_list.items():
92102
router.load_config(
93103
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
94104
)
95-
router.load_config(
96-
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
105+
bgp_config = (
106+
f"{rname}/bgpd.{TUNNEL_TYPE}.conf"
107+
if rname == "r1"
108+
else f"{rname}/bgpd.conf"
97109
)
110+
router.load_config(TopoRouter.RD_BGP, os.path.join(CWD, bgp_config))
98111

99112
# Initialize all routers.
100113
tgen.start_router()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
# SPDX-License-Identifier: ISC
3+
4+
#
5+
# test_bgp_vpnv4_gretap.py
6+
# Part of NetDEF Topology Tests
7+
#
8+
# Copyright (c) 2021 by 6WIND
9+
#
10+
11+
"""
12+
test_bgp_vpnv4_gretap.py: Test the FRR BGP daemon with BGP IPv6 interface
13+
with route advertisements on a separate netns.
14+
"""
15+
16+
import os
17+
import sys
18+
19+
CWD = os.path.dirname(os.path.realpath(__file__))
20+
sys.path.append(os.path.join(CWD, "../"))
21+
22+
from bgp_vpnv4_gre.test_bgp_vpnv4_gre import *
23+
24+
if __name__ == "__main__":
25+
# run test_bgp_vpnv4_gre.py test but with different parameters
26+
# the name of the file controls the name of the global variable TUNNEL_TYPE
27+
args = ["-s"] + sys.argv[1:]
28+
sys.exit(pytest.main(args))

0 commit comments

Comments
 (0)