]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: bgp_bmp, add vpn tests
authorLouis Scalbert <louis.scalbert@6wind.com>
Tue, 27 Feb 2024 14:42:16 +0000 (15:42 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Thu, 29 Feb 2024 15:55:02 +0000 (16:55 +0100)
Test vpn prefixes sending to BMP

Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/bgp_bmp/r1/bgpd.conf
tests/topotests/bgp_bmp/r2/bgpd.conf
tests/topotests/bgp_bmp/test_bgp_bmp.py

index edca6bf1d7e9552db70fd57906a1559c1677ec7b..24505de4a84178b3ef43c8cf329b5681f5b5eaad 100644 (file)
@@ -9,6 +9,14 @@ router bgp 65501
   bmp connect 192.0.2.10 port 1789 min-retry 100 max-retry 10000
  exit
 !
+ address-family ipv4 vpn
+  neighbor 192.168.0.2 activate
+  neighbor 192.168.0.2 soft-reconfiguration inbound
+ exit-address-family
+ address-family ipv6 vpn
+  neighbor 192:168::2 activate
+  neighbor 192:168::2 soft-reconfiguration inbound
+ exit-address-family
  address-family ipv4 unicast
   neighbor 192.168.0.2 activate
   neighbor 192.168.0.2 soft-reconfiguration inbound
@@ -20,3 +28,21 @@ router bgp 65501
   neighbor 192:168::2 soft-reconfiguration inbound
  exit-address-family
 !
+router bgp 65502 vrf vrf1
+ bgp router_id 192.168.0.1
+ bgp log-neighbor-changes
+ address-family ipv4 unicast
+  label vpn export 101
+  rd vpn export 444:1
+  rt vpn both 52:100
+  export vpn
+  import vpn
+  exit-address-family
+ address-family ipv6 unicast
+  label vpn export 103
+  rd vpn export 555:1
+  rt vpn both 54:200
+  export vpn
+  import vpn
+  exit-address-family
+exit
index 7c8255a175637e86ea89c7931ce6293112b3c206..40e2cd5bbcb9eec6022c527479610587ce4ba0ee 100644 (file)
@@ -11,9 +11,36 @@ router bgp 65502
   no neighbor 192:168::1 activate
   redistribute connected
  exit-address-family
+!
+ address-family ipv4 vpn
+  neighbor 192.168.0.1 activate
+ exit-address-family
+!
+ address-family ipv6 vpn
+  neighbor 192:168::1 activate
+ exit-address-family
 !
  address-family ipv6 unicast
   neighbor 192:168::1 activate
   redistribute connected
  exit-address-family
 !
+router bgp 65502 vrf vrf1
+ bgp router-id 192.168.0.2
+ bgp log-neighbor-changes
+ no bgp network import-check
+ address-family ipv4 unicast
+  label vpn export 102
+  rd vpn export 444:2
+  rt vpn both 52:100
+  export vpn
+  import vpn
+ exit-address-family
+ address-family ipv6 unicast
+  label vpn export 105
+  rd vpn export 555:2
+  rt vpn both 54:200
+  export vpn
+  import vpn
+ exit-address-family
+exit
index 059875a1af3993953e802728a8c8d1f710a22196..0c34bdfe29eb4abb15c05e45071f51396244a19f 100644 (file)
@@ -174,7 +174,7 @@ def configure_prefixes(tgen, node, asn, safi, prefixes, vrf=None, update=True):
     Configure the bgp prefixes.
     """
     withdraw = "no " if not update else ""
-    vrf = " vrf {}" if vrf else ""
+    vrf = " vrf {}".format(vrf) if vrf else ""
     for p in prefixes:
         ip = ip_network(p)
         cmd = [
@@ -216,6 +216,34 @@ def unicast_prefixes(policy):
     assert success, "Checking the withdrawed prefixes has been failed !."
 
 
+def vpn_prefixes(policy):
+    """
+    Setup the BMP  monitor policy, Add and withdraw ipv4/v6 prefixes.
+    Check if the previous actions are logged in the BMP server with the right
+    message type and the right policy.
+    """
+    tgen = get_topogen()
+    set_bmp_policy(tgen, "r1", 65501, "bmp1", "vpn", policy)
+
+    prefixes = ["172.31.10.1/32", "2001::2222/128"]
+    # add prefixes
+    configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, vrf="vrf1")
+
+    logger.info("checking for updated prefixes")
+    # check
+    test_func = partial(check_for_prefixes, prefixes, "update", policy)
+    success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
+    assert success, "Checking the updated prefixes has been failed !."
+
+    # withdraw prefixes
+    configure_prefixes(tgen, "r2", 65502, "unicast", prefixes, vrf="vrf1", update=False)
+    logger.info("checking for withdrawed prefixes")
+    # check
+    test_func = partial(check_for_prefixes, prefixes, "withdraw", policy)
+    success, _ = topotest.run_and_expect(test_func, True, wait=0.5)
+    assert success, "Checking the withdrawed prefixes has been failed !."
+
+
 def test_bmp_server_logging():
     """
     Assert the logging of the bmp server.
@@ -244,6 +272,16 @@ def test_bmp_bgp_unicast():
     unicast_prefixes(LOC_RIB)
 
 
+def test_bmp_bgp_vpn():
+    # check for the prefixes in the BMP server logging file
+    logger.info("***** VPN prefixes pre-policy logging *****")
+    vpn_prefixes(PRE_POLICY)
+    logger.info("***** VPN prefixes post-policy logging *****")
+    vpn_prefixes(POST_POLICY)
+    logger.info("***** VPN prefixes loc-rib logging *****")
+    vpn_prefixes(LOC_RIB)
+
+
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]
     sys.exit(pytest.main(args))