diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/ce1/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/ce1/frr.conf new file mode 100644 index 000000000000..5afbf6fdd759 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/ce1/frr.conf @@ -0,0 +1,14 @@ +hostname ce1 +! +interface eth0 + ip address 192.168.1.2/24 + ipv6 address 1001:1::2/64 +! +ip forwarding +ipv6 forwarding +! +ip route 0.0.0.0/0 192.168.1.1 +ipv6 route ::/0 1001:1::1 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/ce2/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/ce2/frr.conf new file mode 100644 index 000000000000..aa37ee19d6d2 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/ce2/frr.conf @@ -0,0 +1,14 @@ +hostname ce2 +! +interface eth0 + ip address 192.168.2.2/24 + ipv6 address 1001:2::2/64 +! +ip forwarding +ipv6 forwarding +! +ip route 0.0.0.0/0 192.168.2.1 +ipv6 route ::/0 1001:2::1 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/ce3/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/ce3/frr.conf new file mode 100644 index 000000000000..0dd8cde58baa --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/ce3/frr.conf @@ -0,0 +1,14 @@ +hostname ce3 +! +interface eth0 + ip address 192.168.3.2/24 + ipv6 address 1001:3::2/64 +! +ip forwarding +ipv6 forwarding +! +ip route 0.0.0.0/0 192.168.3.1 +ipv6 route ::/0 1001:3::1 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/ce4/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/ce4/frr.conf new file mode 100644 index 000000000000..34fc1ca74064 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/ce4/frr.conf @@ -0,0 +1,14 @@ +hostname ce2 +! +interface eth0 + ip address 192.168.4.2/24 + ipv6 address 1001:4::2/64 +! +ip forwarding +ipv6 forwarding +! +ip route 0.0.0.0/0 192.168.4.1 +ipv6 route ::/0 1001:4::1 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf1_rib_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf1_rib_route.json new file mode 100644 index 000000000000..e1d0695a9783 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf1_rib_route.json @@ -0,0 +1,60 @@ +{ + "1:10":{ + "prefix":"192.168.1.0/24", + "version":1, + "advertisedTo":{ + "1000::1":{ + "hostname":"pe1" + } + }, + "paths":[ + { + "aspath":{ + "string":"65501", + "segments":[ + { + "type":"as-sequence", + "list":[ + 65501 + ] + } + ], + "length":1 + }, + "origin":"incomplete", + "metric":0, + "valid":true, + "version":1, + "bestpath":{ + "overall":true, + "selectionReason":"First path received" + }, + "extendedCommunity":{ + "string":"RT:99:99 Color:01:100" + }, + "remoteLabel":"*", + "remoteSid":"2001:db8:1:1::", + "lastUpdate":{ + "epoch":"*", + "string":"*" + }, + "nexthops":[ + { + "ip":"0.0.0.0", + "hostname":"pe1", + "afi":"ipv4", + "metric":0, + "accessible":true, + "used":true + } + ], + "peer":{ + "peerId":"1000::1", + "routerId":"1.1.1.1", + "hostname":"pe1", + "type":"external" + } + } + ] + } +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf2_rib_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf2_rib_route.json new file mode 100644 index 000000000000..2308493255e9 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv4_vrf2_rib_route.json @@ -0,0 +1,60 @@ +{ + "1:20":{ + "prefix":"192.168.2.0/24", + "version":1, + "advertisedTo":{ + "1000::1":{ + "hostname":"pe1" + } + }, + "paths":[ + { + "aspath":{ + "string":"65501", + "segments":[ + { + "type":"as-sequence", + "list":[ + 65501 + ] + } + ], + "length":1 + }, + "origin":"incomplete", + "metric":0, + "valid":true, + "version":1, + "bestpath":{ + "overall":true, + "selectionReason":"First path received" + }, + "extendedCommunity":{ + "string":"RT:88:88 Color:01:200" + }, + "remoteLabel":"*", + "remoteSid":"2001:db8:1:1::", + "lastUpdate":{ + "epoch":"*", + "string":"*" + }, + "nexthops":[ + { + "ip":"0.0.0.0", + "hostname":"pe1", + "afi":"ipv4", + "metric":0, + "accessible":true, + "used":true + } + ], + "peer":{ + "peerId":"1000::1", + "routerId":"1.1.1.1", + "hostname":"pe1", + "type":"external" + } + } + ] + } +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf1_rib_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf1_rib_route.json new file mode 100644 index 000000000000..5ed7a0a6bda9 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf1_rib_route.json @@ -0,0 +1,61 @@ +{ + "1:10":{ + "prefix":"1001:1::/64", + "version":1, + "advertisedTo":{ + "1000::1":{ + "hostname":"pe1" + } + }, + "paths":[ + { + "aspath":{ + "string":"65501", + "segments":[ + { + "type":"as-sequence", + "list":[ + 65501 + ] + } + ], + "length":1 + }, + "origin":"incomplete", + "metric":0, + "valid":true, + "version":1, + "bestpath":{ + "overall":true, + "selectionReason":"First path received" + }, + "extendedCommunity":{ + "string":"RT:99:99 Color:01:100" + }, + "remoteLabel":"*", + "remoteSid":"2001:db8:1:1::", + "lastUpdate":{ + "epoch":"*", + "string":"*" + }, + "nexthops":[ + { + "ip":"1000::1", + "hostname":"pe1", + "afi":"ipv6", + "scope":"global", + "metric":0, + "accessible":true, + "used":true + } + ], + "peer":{ + "peerId":"1000::1", + "routerId":"1.1.1.1", + "hostname":"pe1", + "type":"external" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf2_rib_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf2_rib_route.json new file mode 100644 index 000000000000..f7d6a1249f4d --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vpnv6_vrf2_rib_route.json @@ -0,0 +1,61 @@ +{ + "1:20":{ + "prefix":"1001:2::/64", + "version":1, + "advertisedTo":{ + "1000::1":{ + "hostname":"pe1" + } + }, + "paths":[ + { + "aspath":{ + "string":"65501", + "segments":[ + { + "type":"as-sequence", + "list":[ + 65501 + ] + } + ], + "length":1 + }, + "origin":"incomplete", + "metric":0, + "valid":true, + "version":1, + "bestpath":{ + "overall":true, + "selectionReason":"First path received" + }, + "extendedCommunity":{ + "string":"RT:88:88 Color:01:200" + }, + "remoteLabel":"*", + "remoteSid":"2001:db8:1:1::", + "lastUpdate":{ + "epoch":"*", + "string":"*" + }, + "nexthops":[ + { + "ip":"1000::1", + "hostname":"pe1", + "afi":"ipv6", + "scope":"global", + "metric":0, + "accessible":true, + "used":true + } + ], + "peer":{ + "peerId":"1000::1", + "routerId":"1.1.1.1", + "hostname":"pe1", + "type":"external" + } + } + ] + } +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route.json new file mode 100644 index 000000000000..a10287700a95 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route.json @@ -0,0 +1,67 @@ +{ + "192.168.1.0/24":[ + { + "prefix":"192.168.1.0/24", + "prefixLen":24, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf1", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":1, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":5, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:1::" + } + }, + { + "flags":3, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:1::" + } + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route_te_policy.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route_te_policy.json new file mode 100644 index 000000000000..953390b5518f --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv4_route_te_policy.json @@ -0,0 +1,70 @@ +{ + "192.168.1.0/24":[ + { + "prefix":"192.168.1.0/24", + "prefixLen":24, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf1", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":1, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":3205, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "srteColor":100, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:3:3::3", + "2001:db8:1:1::1" + ] + }, + { + "flags":2051, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:3:3::3", + "2001:db8:1:1::1" + ] + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route.json new file mode 100644 index 000000000000..ce71b0271014 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route.json @@ -0,0 +1,67 @@ +{ + "1001:1::/64":[ + { + "prefix":"1001:1::/64", + "prefixLen":64, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf1", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":1, + "internalStatus":"*", + "internalFlags":"*", + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":5, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:1::" + } + }, + { + "flags":3, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:1::" + } + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route_te_policy.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route_te_policy.json new file mode 100644 index 000000000000..7afed522d9e8 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf1_ipv6_route_te_policy.json @@ -0,0 +1,70 @@ +{ + "1001:1::/64":[ + { + "prefix":"1001:1::/64", + "prefixLen":64, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf1", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":1, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":3205, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "srteColor":100, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:3:3::3", + "2001:db8:1:1::1" + ] + }, + { + "flags":2051, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:3:3::3", + "2001:db8:1:1::1" + ] + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route.json new file mode 100644 index 000000000000..4e7b5e029d58 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route.json @@ -0,0 +1,67 @@ +{ + "192.168.2.0/24":[ + { + "prefix":"192.168.2.0/24", + "prefixLen":24, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf2", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":2, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":5, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:2::" + } + }, + { + "flags":3, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:2::" + } + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route_te_policy.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route_te_policy.json new file mode 100644 index 000000000000..17d56859cca0 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv4_route_te_policy.json @@ -0,0 +1,70 @@ +{ + "192.168.2.0/24":[ + { + "prefix":"192.168.2.0/24", + "prefixLen":24, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf2", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":2, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":3205, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "srteColor":200, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:4:4::4", + "2001:db8:1:1::1" + ] + }, + { + "flags":2051, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:4:4::4", + "2001:db8:1:1::1" + ] + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route.json new file mode 100644 index 000000000000..2e5df058296e --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route.json @@ -0,0 +1,67 @@ +{ + "1001:2::/64":[ + { + "prefix":"1001:2::/64", + "prefixLen":64, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf2", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":2, + "internalStatus":"*", + "internalFlags":"*", + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":5, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:2::" + } + }, + { + "flags":3, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":{ + "segs":"2001:db8:1:1:2::" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route_te_policy.json b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route_te_policy.json new file mode 100644 index 000000000000..6ce752f6da90 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/json/vrf2_ipv6_route_te_policy.json @@ -0,0 +1,70 @@ +{ + "1001:2::/64":[ + { + "prefix":"1001:2::/64", + "prefixLen":64, + "protocol":"bgp", + "vrfId":"*", + "vrfName":"vrf2", + "selected":true, + "destSelected":true, + "distance":20, + "metric":0, + "installed":true, + "table":2, + "internalStatus":16, + "internalFlags":9, + "internalNextHopNum":"*", + "internalNextHopActiveNum":"*", + "nexthopGroupId":"*", + "installedNexthopGroupId":"*", + "uptime":"*", + "nexthops":[ + { + "flags":3205, + "ip":"1000::1", + "afi":"ipv6", + "vrf":"default", + "active":true, + "recursive":true, + "labels":"*", + "weight":1, + "srteColor":200, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:4:4::4", + "2001:db8:1:1::1" + ] + }, + { + "flags":2051, + "fib":true, + "ip":"*", + "afi":"ipv6", + "interfaceIndex":"*", + "interfaceName":"eth1", + "resolver":true, + "vrf":"default", + "active":true, + "labels":"*", + "weight":1, + "seg6local":{ + "action":"unspec" + }, + "seg6localContext":{ + "unknown":true + }, + "seg6":[ + "2001:db8:4:4::4", + "2001:db8:1:1::1" + ] + } + ] + } + ] +} diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/p1/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/p1/frr.conf new file mode 100644 index 000000000000..6f38d125e894 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/p1/frr.conf @@ -0,0 +1,47 @@ +hostname p1 +! +interface lo + ipv6 address 3000::1/64 +! +interface eth1 + ipv6 address 2001:1::2/64 +! +interface eth2 + ipv6 address 2002:1::1/64 +! +interface eth3 + ipv6 address 2002:3::2/64 +! +router bgp 65503 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor 2001:1::1 remote-as 65501 + neighbor 2001:1::1 timers 3 10 + neighbor 2001:1::1 timers connect 1 + neighbor 2002:1::2 remote-as 65502 + neighbor 2002:1::2 timers 3 10 + neighbor 2002:1::2 timers connect 1 + ! + address-family ipv6 unicast + neighbor 2001:1::1 activate + neighbor 2002:1::2 activate + exit-address-family + ! +! +ip forwarding +ipv6 forwarding +! +segment-routing + srv6 + locators + locator loc1 + prefix 2001:db8:3:3::/64 + ! + ! +! +ipv6 route 2001:db8:1:1::/64 2001:1::1 +ipv6 route 2001:db8:2:2::/64 2002:1::2 +ipv6 route 2001:db8:4:4::/64 2002:3::1 +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/p2/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/p2/frr.conf new file mode 100644 index 000000000000..4ebe8bdb9def --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/p2/frr.conf @@ -0,0 +1,48 @@ +hostname p2 +! +interface lo + ipv6 address 4000::1/64 +! +interface eth1 + ipv6 address 2001:2::2/64 +! +interface eth2 + ipv6 address 2002:2::1/64 +! +interface eth3 + ipv6 address 2002:3::1/64 +! +router bgp 65504 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor 2001:2::1 remote-as 65501 + neighbor 2001:2::1 timers 3 10 + neighbor 2001:2::1 timers connect 1 + neighbor 2002:2::2 remote-as 65502 + neighbor 2002:2::2 timers 3 10 + neighbor 2002:2::2 timers connect 1 + ! + address-family ipv6 unicast + neighbor 2001:2::1 activate + neighbor 2002:2::2 activate + exit-address-family + ! +! +ip forwarding +ipv6 forwarding +! +segment-routing + srv6 + locators + locator loc1 + prefix 2001:db8:4:4::/64 + ! + ! +! +! +ipv6 route 2001:db8:1:1::/64 2001:2::1 +ipv6 route 2001:db8:2:2::/64 2002:2::2 +ipv6 route 2001:db8:3:3::/64 2002:3::2 +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/pe1/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/pe1/frr.conf new file mode 100644 index 000000000000..3ac0240e4a8f --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/pe1/frr.conf @@ -0,0 +1,125 @@ +hostname pe1 +! +!debug zebra packet +!debug zebra dplane +!debug zebra kernel +! +interface lo + ipv6 address 1000::1/64 +! +interface eth1 + ipv6 address 2001:1::1/64 +! +interface eth2 + ipv6 address 2001:2::1/64 +! +interface eth3 vrf vrf1 + ip address 192.168.1.1/24 + ipv6 address 1001:1::1/64 +! +interface eth4 vrf vrf2 + ip address 192.168.2.1/24 + ipv6 address 1001:2::1/64 +! +! +route-map color_vrf1 permit 10 + set extcommunity color 01:100 +! +route-map color_vrf2 permit 10 + set extcommunity color 01:200 +! +router bgp 65501 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor 2001:1::2 remote-as 65503 + neighbor 2001:1::2 timers 3 10 + neighbor 2001:1::2 timers connect 1 + neighbor 2001:2::2 remote-as 65504 + neighbor 2001:2::2 timers 3 10 + neighbor 2001:2::2 timers connect 1 + neighbor 2000::1 remote-as 65502 + neighbor 2000::1 timers 3 10 + neighbor 2000::1 timers connect 1 + neighbor 2000::1 ebgp-multihop 254 + neighbor 2000::1 update-source 1000::1 + neighbor 2000::1 capability extended-nexthop + ! + address-family ipv4 vpn + neighbor 2000::1 activate + exit-address-family + ! + address-family ipv6 vpn + neighbor 2000::1 activate + exit-address-family + ! + address-family ipv6 unicast + network 1000::1/64 + neighbor 2001:1::2 activate + neighbor 2001:2::2 activate + exit-address-family + + segment-routing srv6 + locator loc1 + ! +! +router bgp 65501 vrf vrf1 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + sid vpn per-vrf export auto + ! + address-family ipv4 unicast + nexthop vpn export 2001::1 + rd vpn export 1:10 + rt vpn both 99:99 + export vpn + route-map vpn export color_vrf1 + redistribute connected + exit-address-family + ! + address-family ipv6 unicast + rd vpn export 1:10 + rt vpn both 99:99 + export vpn + route-map vpn export color_vrf1 + redistribute connected + exit-address-family +! +router bgp 65501 vrf vrf2 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + sid vpn per-vrf export auto + ! + address-family ipv4 unicast + nexthop vpn export 2001::1 + rd vpn export 1:20 + rt vpn both 88:88 + export vpn + route-map vpn export color_vrf2 + redistribute connected + exit-address-family + ! + address-family ipv6 unicast + rd vpn export 1:20 + rt vpn both 88:88 + export vpn + route-map vpn export color_vrf2 + redistribute connected + exit-address-family +! +ip forwarding +ipv6 forwarding +! +segment-routing + srv6 + locators + locator loc1 + prefix 2001:db8:1:1::/64 + ! + ! +! +ipv6 route 2001:db8:2:2::/64 2001:1::2 +ipv6 route 2001:db8:2:2::/64 2001:2::2 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/pe2/frr.conf b/tests/topotests/bgp_srv6l3vpn_te_policy/pe2/frr.conf new file mode 100644 index 000000000000..d237f6f07a57 --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/pe2/frr.conf @@ -0,0 +1,121 @@ +hostname pe2 +! +!debug zebra packet +!debug zebra dplane +!debug zebra kernel +! +interface lo + ipv6 address 2000::1/64 +! +interface eth1 + ipv6 address 2002:1::2/64 +! +interface eth2 + ipv6 address 2002:2::2/64 +! +interface eth3 vrf vrf1 + ip address 192.168.3.1/24 + ipv6 address 1001:3::1/64 +! +interface eth4 vrf vrf2 + ip address 192.168.4.1/24 + ipv6 address 1001:4::1/64 +! +! +route-map color permit 10 + set extcommunity color 01:200 +! +router bgp 65502 + bgp router-id 1.1.1.1 + no bgp ebgp-requires-policy + no bgp default ipv4-unicast + neighbor 2002:1::1 remote-as 65503 + neighbor 2002:1::1 timers 3 10 + neighbor 2002:1::1 timers connect 1 + neighbor 2002:2::1 remote-as 65504 + neighbor 2002:2::1 timers 3 10 + neighbor 2002:2::1 timers connect 1 + neighbor 1000::1 remote-as 65501 + neighbor 1000::1 timers 3 10 + neighbor 1000::1 timers connect 1 + neighbor 1000::1 ebgp-multihop 254 + neighbor 1000::1 update-source 2000::1 + neighbor 1000::1 capability extended-nexthop + ! + address-family ipv4 vpn + neighbor 1000::1 activate + neighbor 1000::1 route-map color out + exit-address-family + ! + address-family ipv6 vpn + neighbor 1000::1 activate + neighbor 1000::1 route-map color out + exit-address-family + ! + address-family ipv6 unicast + network 2000::1/64 + neighbor 2002:1::1 activate + neighbor 2002:2::1 activate + exit-address-family + + segment-routing srv6 + locator loc1 + ! +! +router bgp 65502 vrf vrf1 + bgp router-id 2.2.2.2 + no bgp ebgp-requires-policy + ! + address-family ipv4 unicast + nexthop vpn export 2001::2 + rd vpn export 2:10 + rt vpn both 99:99 + import vpn + exit-address-family + ! + address-family ipv6 unicast + rd vpn export 2:10 + rt vpn both 99:99 + import vpn + exit-address-family +! +router bgp 65502 vrf vrf2 + bgp router-id 2.2.2.2 + no bgp ebgp-requires-policy + ! + address-family ipv4 unicast + nexthop vpn export 2001::2 + rd vpn export 2:20 + rt vpn both 88:88 + import vpn + exit-address-family + ! + address-family ipv6 unicast + rd vpn export 2:20 + rt vpn both 88:88 + import vpn + exit-address-family +! +ip forwarding +ipv6 forwarding +! +segment-routing + srv6 + locators + locator loc1 + prefix 2001:db8:2:2::/64 + ! + ! + traffic-eng + segment-list default + index 10 ipv6-address 2001:db8:4:4::4 + index 20 ipv6-address 2001:db8:1:1::1 + segment-list test + index 10 ipv6-address 2001:db8:3:3::3 + index 20 ipv6-address 2001:db8:1:1::1 +! +ipv6 route 2001:db8:1:1::/64 2002:1::1 +ipv6 route 2001:db8:1:1::/64 2002:2::1 +! +line vty +! diff --git a/tests/topotests/bgp_srv6l3vpn_te_policy/test_bgp_srv6l3vpn_te_policy.py b/tests/topotests/bgp_srv6l3vpn_te_policy/test_bgp_srv6l3vpn_te_policy.py new file mode 100644 index 000000000000..b7830e5488fd --- /dev/null +++ b/tests/topotests/bgp_srv6l3vpn_te_policy/test_bgp_srv6l3vpn_te_policy.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# Part of NetDEF Topology Tests +# +# Copyright (c) 2022, Alibaba Group +# Authored by Guoguo +# + +import os +import sys +import json +import functools +import pytest + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from lib.common_config import required_linux_kernel_version +from lib.checkping import check_ping + +pytestmark = [pytest.mark.bgpd] + + +def build_topo(tgen): + r""" + ┌──────┐ ┌──────┐ ┌──────┐ + │ CE1 ┼─┐ ┌───┤ P1 ┼──┐ ┌─┤ CE3 │ + └──────┘ │ Vrf1 │ └───|──┘ │ │ └──────┘ + │ ┌──────┐ │ | │ ┌──────┐ │ Vrf1 + ┼─┼ PE1 ┼───┤ | ┼────┤ PE2 ┼──┤ + │ └──────┘ │ | │ └──────┘ │ Vrf2 + ┌──────┐ │ Vrf2 │ ┌───|──┐ │ │ ┌──────┐ + │ CE2 ┼─┘ └───┤ P2 ┼──┘ └─┼ CE4 │ + └──────┘ └──────┘ └──────┘ + """ + tgen.add_router("pe1") + tgen.add_router("pe2") + tgen.add_router("ce1") + tgen.add_router("ce2") + tgen.add_router("ce3") + tgen.add_router("ce4") + tgen.add_router("p1") + tgen.add_router("p2") + + tgen.add_link(tgen.gears["pe1"], tgen.gears["p1"], "eth1", "eth1") + tgen.add_link(tgen.gears["pe1"], tgen.gears["p2"], "eth2", "eth1") + tgen.add_link(tgen.gears["pe2"], tgen.gears["p1"], "eth1", "eth2") + tgen.add_link(tgen.gears["pe2"], tgen.gears["p2"], "eth2", "eth2") + tgen.add_link(tgen.gears["ce1"], tgen.gears["pe1"], "eth0", "eth3") + tgen.add_link(tgen.gears["ce2"], tgen.gears["pe1"], "eth0", "eth4") + tgen.add_link(tgen.gears["ce3"], tgen.gears["pe2"], "eth0", "eth3") + tgen.add_link(tgen.gears["ce4"], tgen.gears["pe2"], "eth0", "eth4") + tgen.add_link(tgen.gears["p1"], tgen.gears["p2"], "eth3", "eth3") + +def setup_module(module): + tgen = Topogen(build_topo, module.__name__) + tgen.start_topology() + + # This is a sample of configuration loading. + router_list = tgen.routers() + for rname, router in router_list.items(): + router.load_frr_config( + os.path.join(CWD, "{}/frr.conf".format(rname)), + [ + (TopoRouter.RD_ZEBRA, None), + (TopoRouter.RD_PATH, None), + (TopoRouter.RD_BGP, None), + (TopoRouter.RD_STATIC, None), + (TopoRouter.RD_MGMTD, None), + ], + ) + tgen.gears["pe1"].run("ip link add vrf1 type vrf table 1") + tgen.gears["pe1"].run("ip link set vrf1 up") + tgen.gears["pe1"].run("ip link add vrf2 type vrf table 2") + tgen.gears["pe1"].run("ip link set vrf2 up") + tgen.gears["pe1"].run("ip link set eth3 master vrf1") + tgen.gears["pe1"].run("ip link set eth4 master vrf2") + + tgen.gears["pe2"].run("ip link add vrf1 type vrf table 1") + tgen.gears["pe2"].run("ip link set vrf1 up") + tgen.gears["pe2"].run("ip link add vrf2 type vrf table 2") + tgen.gears["pe2"].run("ip link set vrf2 up") + tgen.gears["pe2"].run("ip link set eth3 master vrf1") + tgen.gears["pe2"].run("ip link set eth4 master vrf2") + + tgen.start_router() + + +def teardown_module(mod): + tgen = get_topogen() + tgen.stop_topology() + + +def open_json_file(filename): + try: + with open(filename, "r") as f: + return json.load(f) + except IOError: + assert False, "Could not read file {}".format(filename) + + +def check_rib(name, cmd, expected_file): + def _check(name, cmd, expected_file): + logger.info("polling") + tgen = get_topogen() + router = tgen.gears[name] + output = json.loads(router.vtysh_cmd(cmd)) + expected = open_json_file("{}/{}".format(CWD, expected_file)) + return topotest.json_cmp(output, expected) + + logger.info('[+] check {} "{}" {}'.format(name, cmd, expected_file)) + tgen = get_topogen() + func = functools.partial(_check, name, cmd, expected_file) + _, result = topotest.run_and_expect(func, None, count=30, wait=0.5) + assert result is None, "Failed" + +def create_srv6_policy(rname, endpoint, color=100): + tgen = get_topogen() + router = tgen.gears[rname] + router.vtysh_cmd( + "configure terminal\nsegment-routing\ntraffic-eng\npolicy color {} endpoint {}".format(color, endpoint) + ) + + +def delete_srv6_policy(rname, endpoint, color=100): + tgen = get_topogen() + router = tgen.gears[rname] + router.vtysh_cmd( + "configure terminal\nsegment-routing\ntraffic-eng\nno policy color {} endpoint {}".format(color, endpoint) + ) + +def add_candidate_path(rname, endpoint, pref, name, segment_list="default", color=100): + tgen = get_topogen() + router = tgen.gears[rname] + router.vtysh_cmd( + "configure terminal\nsegment-routing\ntraffic-eng\npolicy color {} endpoint {}\ncandidate-path preference {} name {} explicit segment-list {}".format( + color, endpoint, pref, name, segment_list) + ) + + +def delete_candidate_path(rname, endpoint, pref, color=100): + tgen = get_topogen() + router = tgen.gears[rname] + router.vtysh_cmd( + "configure terminal\nsegment-routing\ntraffic-eng\npolicy color {} endpoint {}\nno candidate-path preference {}".format(color, endpoint, pref) + ) + +def test_bgp_srv6_ipv4_vpn_route(): + check_rib("pe2", "show bgp ipv4 vpn 192.168.1.0/24 json", "json/vpnv4_vrf1_rib_route.json") + check_rib("pe2", "show bgp ipv4 vpn 192.168.2.0/24 json", "json/vpnv4_vrf2_rib_route.json") + check_rib("pe2", "show ip route vrf vrf1 192.168.1.0/24 json", "json/vrf1_ipv4_route.json") + check_rib("pe2", "show ip route vrf vrf2 192.168.2.0/24 json", "json/vrf2_ipv4_route.json") + + add_candidate_path("pe2", "1000::1", 100, "test", "test", 100) + + add_candidate_path("pe2", "1000::1", 100, "default", "default", 200) + check_rib("pe2", "show ip route vrf vrf1 192.168.1.0/24 json", "json/vrf1_ipv4_route_te_policy.json") + check_rib("pe2", "show ip route vrf vrf2 192.168.2.0/24 json", "json/vrf2_ipv4_route_te_policy.json") + + delete_candidate_path("pe2", "1000::1", 100) + delete_candidate_path("pe2", "1000::1", 100, 200) + check_rib("pe2", "show ip route vrf vrf1 192.168.1.0/24 json", "json/vrf1_ipv4_route.json") + check_rib("pe2", "show ip route vrf vrf2 192.168.2.0/24 json", "json/vrf2_ipv4_route.json") + +def test_bgp_srv6_ipv6_vpn_route(): + check_rib("pe2", "show bgp ipv6 vpn 1001:1::/64 json", "json/vpnv6_vrf1_rib_route.json") + check_rib("pe2", "show bgp ipv6 vpn 1001:2::/64 json", "json/vpnv6_vrf2_rib_route.json") + check_rib("pe2", "show ipv6 route vrf vrf1 1001:1::/64 json", "json/vrf1_ipv6_route.json") + check_rib("pe2", "show ipv6 route vrf vrf2 1001:2::/64 json", "json/vrf2_ipv6_route.json") + + add_candidate_path("pe2", "1000::1", 100, "test", "test", 100) + + add_candidate_path("pe2", "1000::1", 100, "default", "default", 200) + check_rib("pe2", "show ipv6 route vrf vrf1 1001:1::/64 json", "json/vrf1_ipv6_route_te_policy.json") + check_rib("pe2", "show ipv6 route vrf vrf2 1001:2::/64 json", "json/vrf2_ipv6_route_te_policy.json") + + delete_srv6_policy("pe2", "1000::1", 100) + delete_srv6_policy("pe2", "1000::1", 200) + check_rib("pe2", "show ipv6 route vrf vrf1 1001:1::/64 json", "json/vrf1_ipv6_route.json") + check_rib("pe2", "show ipv6 route vrf vrf2 1001:2::/64 json", "json/vrf2_ipv6_route.json") + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args))