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
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
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
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 = [
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.
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))