]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: bgp_evpn_rt5, add test for advertise route-map service 17491/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 22 Nov 2024 14:57:25 +0000 (15:57 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 27 Nov 2024 07:47:24 +0000 (08:47 +0100)
Use the advertise route-map command, and check that it
filters out correctly the undesirable prefixes. Reversely,
check that undoing that route-map recovers all prefixes.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/bgp_evpn_rt5/r1/bgp_l2vpn_evpn_routes_all.json [new file with mode: 0644]
tests/topotests/bgp_evpn_rt5/r2/bgpd.conf
tests/topotests/bgp_evpn_rt5/test_bgp_evpn.py

diff --git a/tests/topotests/bgp_evpn_rt5/r1/bgp_l2vpn_evpn_routes_all.json b/tests/topotests/bgp_evpn_rt5/r1/bgp_l2vpn_evpn_routes_all.json
new file mode 100644 (file)
index 0000000..a14ba12
--- /dev/null
@@ -0,0 +1,191 @@
+{
+    "bgpLocalRouterId":"192.168.100.21",
+    "defaultLocPrf":100,
+    "localAS":65000,
+    "192.168.101.41:2":{
+        "rd":"192.168.101.41:2",
+        "[5]:[0]:[32]:[192.168.101.41]":{
+            "prefix":"[5]:[0]:[32]:[192.168.101.41]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"internal",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":32,
+                    "ip":"192.168.101.41",
+                    "metric":0,
+                    "locPrf":100,
+                    "weight":0,
+                    "peerId":"192.168.100.41",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.41",
+                            "hostname":"r2",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        },
+        "[5]:[0]:[32]:[192.168.102.41]":{
+            "prefix":"[5]:[0]:[32]:[192.168.102.41]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"internal",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":32,
+                    "ip":"192.168.102.41",
+                    "metric":0,
+                    "locPrf":100,
+                    "weight":0,
+                    "peerId":"192.168.100.41",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.41",
+                            "hostname":"r2",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        },
+        "[5]:[0]:[128]:[fd00::2]":{
+            "prefix":"[5]:[0]:[128]:[fd00::2]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"internal",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":128,
+                    "ip":"fd00::2",
+                    "metric":0,
+                    "locPrf":100,
+                    "weight":0,
+                    "peerId":"192.168.100.41",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.41",
+                            "hostname":"r2",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        },
+        "[5]:[0]:[128]:[fd00::3]":{
+            "prefix":"[5]:[0]:[128]:[fd00::3]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"internal",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":128,
+                    "ip":"fd00::3",
+                    "metric":0,
+                    "locPrf":100,
+                    "weight":0,
+                    "peerId":"192.168.100.41",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.41",
+                            "hostname":"r2",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        }
+    },
+    "192.168.102.21:2":{
+        "rd":"192.168.102.21:2",
+        "[5]:[0]:[32]:[192.168.102.21]":{
+            "prefix":"[5]:[0]:[32]:[192.168.102.21]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"external",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":32,
+                    "ip":"192.168.102.21",
+                    "metric":0,
+                    "weight":32768,
+                    "peerId":"(unspec)",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.21",
+                            "hostname":"r1",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        },
+        "[5]:[0]:[128]:[fd00::1]":{
+            "prefix":"[5]:[0]:[128]:[fd00::1]",
+            "prefixLen":352,
+            "paths":[
+                {
+                    "valid":true,
+                    "bestpath":true,
+                    "selectionReason":"First path received",
+                    "pathFrom":"external",
+                    "routeType":5,
+                    "ethTag":0,
+                    "ipLen":128,
+                    "ip":"fd00::1",
+                    "metric":0,
+                    "weight":32768,
+                    "peerId":"(unspec)",
+                    "path":"",
+                    "origin":"IGP",
+                    "nexthops":[
+                        {
+                            "ip":"192.168.100.21",
+                            "hostname":"r1",
+                            "afi":"ipv4",
+                            "used":true
+                        }
+                    ]
+                }
+            ]
+        }
+    },
+    "numPrefix":6,
+    "totalPrefix":6
+}
index de5a0efc445f8df9ddb4b9778d4ffe5cc236ad12..4f1d8e4a3788ea1a7a8717a56bb5619936b88a83 100644 (file)
@@ -20,12 +20,30 @@ router bgp 65000 vrf r2-vrf-101
  no bgp network import-check
  address-family ipv4 unicast
   network 192.168.101.41/32
+  network 192.168.102.41/32
  exit-address-family
  address-family ipv6 unicast
   network fd00::2/128
+  network fd00::3/128
  exit-address-family
  address-family l2vpn evpn
-  advertise ipv4 unicast
-  advertise ipv6 unicast
+  advertise ipv4 unicast route-map rmap4
+  advertise ipv6 unicast route-map rmap6
  exit-address-family
  !
+access-list acl4_1 seq 10 permit 192.168.101.41/32
+access-list acl4_2 seq 10 permit 192.168.102.41/32
+ipv6 access-list acl6_1 seq 10 permit fd00::2/128
+ipv6 access-list acl6_2 seq 10 permit fd00::3/128
+route-map rmap4 permit 1
+ match ip address acl4_1
+exit
+route-map rmap4 deny 2
+ match ip address acl4_2
+exit
+route-map rmap6 permit 1
+ match ipv6 address acl6_1
+exit
+route-map rmap6 deny 2
+ match ipv6 address acl6_2
+exit
index 85d825bce303ab540a3850c9fd8464264f2b69a0..a9636a92f4b2e5997fb6b36279995bfe3e1174ec 100644 (file)
@@ -347,6 +347,40 @@ def test_evpn_ping():
     _test_evpn_ping_router(tgen.gears["r1"])
 
 
+def test_evpn_disable_routemap():
+    """
+    Check the removal of a route-map on R2. More EVPN Prefixes are expected
+    """
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    tgen.gears["r2"].vtysh_cmd(
+        """
+        configure terminal\n
+        router bgp 65000 vrf r2-vrf-101\n
+        address-family l2vpn evpn\n
+        advertise ipv4 unicast\n
+        advertise ipv6 unicast\n
+        """
+    )
+    router = tgen.gears["r1"]
+    json_file = "{}/{}/bgp_l2vpn_evpn_routes_all.json".format(CWD, router.name)
+    if not os.path.isfile(json_file):
+        assert 0, "bgp_l2vpn_evpn_routes.json file not found"
+
+    expected = json.loads(open(json_file).read())
+    test_func = partial(
+        topotest.router_json_cmp,
+        router,
+        "show bgp l2vpn evpn json",
+        expected,
+    )
+    _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+    assertmsg = '"{}" JSON output mismatches'.format(router.name)
+    assert result is None, assertmsg
+
+
 def test_evpn_remove_ip():
     """
     Check the removal of an EVPN route is correctly handled
@@ -360,6 +394,7 @@ def test_evpn_remove_ip():
             "raw_config": [
                 "router bgp 65000 vrf r2-vrf-101",
                 "address-family ipv6 unicast",
+                "no network fd00::3/128",
                 "no network fd00::2/128",
             ]
         }