From 82a843fa3df4adff6d2eaffbaba96eb136fcaebb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 16 Sep 2020 15:04:16 -0400 Subject: [PATCH 1/6] bgpd: allow bestpath to handle mutliple locally-originated paths Current code in bgp bestpath selection would accept the newest locally originated path as the best path. Making the selection non-deterministic. Modify the code to always come to the same bestpath conclusion when you have multiple locally originated paths in bestpath selection. Before: eva# conf eva(config)# router bgp 323 eva(config-router)# address-family ipv4 uni eva(config-router-af)# redistribute connected eva(config-router-af)# network 192.168.161.0/24 eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (2 available, best #1, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin) Last update: Wed Sep 16 15:03:03 2020 Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin incomplete, metric 0, weight 32768, valid, sourced Last update: Wed Sep 16 15:02:52 2020 eva(config-router-af)# no redistribute connected eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (1 available, best #1, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (First path received) Last update: Wed Sep 16 15:03:03 2020 eva(config-router-af)# redistribute connected eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (2 available, best #2, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin incomplete, metric 0, weight 32768, valid, sourced Last update: Wed Sep 16 15:03:32 2020 Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin) Last update: Wed Sep 16 15:03:03 2020 eva(config-router-af)# Notice the route choosen depends on order received Fixed behavior: eva# conf eva(config)# router bgp 323 eva(config-router)# address-family ipv4 uni eva(config-router-af)# redistribute connected eva(config-router-af)# network 192.168.161.0/24 eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (2 available, best #1, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin) Last update: Wed Sep 16 15:03:03 2020 Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin incomplete, metric 0, weight 32768, valid, sourced Last update: Wed Sep 16 15:02:52 2020 eva(config-router-af)# no redistribute connected eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (1 available, best #1, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (First path received) Last update: Wed Sep 16 15:03:03 2020 eva(config-router-af)# redistribute connected eva(config-router-af)# do show bgp ipv4 uni 192.168.161.0 BGP routing table entry for 192.168.161.0/24 Paths: (2 available, best #2, table default) Not advertised to any peer Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin incomplete, metric 0, weight 32768, valid, sourced Last update: Wed Sep 16 15:03:32 2020 Local 0.0.0.0(eva) from 0.0.0.0 (192.168.161.245) Origin IGP, metric 0, weight 32768, valid, sourced, local, bestpath-from-AS Local, best (Origin) Last update: Wed Sep 16 15:03:03 2020 eva(config-router-af)# Ticket: CM-31490 Found-by: Trey Aspelund Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 15c1df8473..941bae4ff4 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -550,6 +550,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, bool same_esi; bool old_proxy; bool new_proxy; + bool new_origin, exist_origin; *paths_eq = 0; @@ -794,8 +795,12 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, * - BGP_ROUTE_AGGREGATE * - BGP_ROUTE_REDISTRIBUTE */ - if (!(new->sub_type == BGP_ROUTE_NORMAL || - new->sub_type == BGP_ROUTE_IMPORTED)) { + new_origin = !(new->sub_type == BGP_ROUTE_NORMAL || + new->sub_type == BGP_ROUTE_IMPORTED); + exist_origin = !(exist->sub_type == BGP_ROUTE_NORMAL || + exist->sub_type == BGP_ROUTE_IMPORTED); + + if (new_origin && !exist_origin) { *reason = bgp_path_selection_local_route; if (debug) zlog_debug( @@ -804,8 +809,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, return 1; } - if (!(exist->sub_type == BGP_ROUTE_NORMAL || - exist->sub_type == BGP_ROUTE_IMPORTED)) { + if (!new_origin && exist_origin) { *reason = bgp_path_selection_local_route; if (debug) zlog_debug( From 801f483b4ed73858b19fa2e3febe6120c8e04e9a Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Tue, 29 Sep 2020 14:23:32 -0400 Subject: [PATCH 2/6] tests: bgp_l3vpn_to_bgp_vrf - add redundant ce routes Signed-off-by: Lou Berger --- .../bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf | 2 + .../bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf | 2 + .../bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf | 2 + .../bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf | 2 + .../scripts/check_routes.py | 76 ++++++++++++++++--- .../scripts/scale_down.py | 2 +- 6 files changed, 75 insertions(+), 11 deletions(-) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf index 6e6b9edde2..dbb1c2437c 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf @@ -18,6 +18,8 @@ router bgp 5227 network 5.1.0.0/24 route-map rm-nh network 5.1.1.0/24 route-map rm-nh redistribute sharp route-map sharp-nh + network 6.0.1.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh neighbor 192.168.1.1 activate exit-address-family ! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf index 618acabd9f..b0e19e6645 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf @@ -18,6 +18,8 @@ router bgp 5227 network 5.1.0.0/24 route-map rm-nh network 5.1.1.0/24 route-map rm-nh redistribute sharp route-map sharp-nh + network 6.0.1.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh neighbor 192.168.1.1 activate exit-address-family ! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf index 85c5973e6f..ec93c5ba2f 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf @@ -17,6 +17,8 @@ router bgp 5227 network 99.0.0.3/32 network 5.1.2.0/24 route-map rm-nh network 5.1.3.0/24 route-map rm-nh + network 6.0.1.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh neighbor 192.168.1.1 activate exit-address-family ! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf index 6a5075a000..e1cc9574e8 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf @@ -17,6 +17,8 @@ router bgp 5228 vrf ce4-cust2 network 99.0.0.4/32 network 5.4.2.0/24 route-map rm-nh network 5.4.3.0/24 route-map rm-nh + network 6.0.1.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh neighbor 192.168.2.1 activate exit-address-family ! diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py index f5a29b95c9..a89cdc0b35 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py @@ -14,6 +14,8 @@ from bgprib import bgpribRequireVpnRoutes, bgpribRequireUnicastRoutes want = [ {"p": "5.1.0.0/24", "n": "99.0.0.1"}, {"p": "5.1.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.2.0/24", "n": "99.0.0.1"}, {"p": "99.0.0.1/32", "n": "0.0.0.0"}, ] bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes in ce1", want) @@ -21,6 +23,8 @@ bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes in ce1", want) want = [ {"p": "5.1.0.0/24", "n": "99.0.0.2"}, {"p": "5.1.1.0/24", "n": "99.0.0.2"}, + {"p": "6.0.1.0/24", "n": "99.0.0.2"}, + {"p": "6.0.2.0/24", "n": "99.0.0.2"}, {"p": "99.0.0.2/32", "n": "0.0.0.0"}, ] bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 2 routes in ce1", want) @@ -28,6 +32,8 @@ bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 2 routes in ce1", want) want = [ {"p": "5.1.2.0/24", "n": "99.0.0.3"}, {"p": "5.1.3.0/24", "n": "99.0.0.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.3"}, + {"p": "6.0.2.0/24", "n": "99.0.0.3"}, {"p": "99.0.0.3/32", "n": "0.0.0.0"}, ] bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 3 routes in ce1", want) @@ -35,6 +41,8 @@ bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 3 routes in ce1", want) want = [ {"p": "5.4.2.0/24", "n": "99.0.0.4"}, {"p": "5.4.3.0/24", "n": "99.0.0.4"}, + {"p": "6.0.1.0/24", "n": "99.0.0.4"}, + {"p": "6.0.2.0/24", "n": "99.0.0.4"}, {"p": "99.0.0.4/32", "n": "0.0.0.0"}, ] bgpribRequireUnicastRoutes("ce4", "ipv4", "ce4-cust2", "Cust 4 routes in ce1", want) @@ -49,6 +57,8 @@ bgpribRequireUnicastRoutes("ce4", "ipv4", "ce4-cust2", "Cust 4 routes in ce1", w want_r1_cust1_routes = [ {"p": "5.1.0.0/24", "n": "99.0.0.1"}, {"p": "5.1.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.2.0/24", "n": "99.0.0.1"}, {"p": "99.0.0.1/32", "n": "192.168.1.2"}, ] bgpribRequireUnicastRoutes( @@ -58,6 +68,8 @@ bgpribRequireUnicastRoutes( want_r3_cust1_routes = [ {"p": "5.1.0.0/24", "n": "99.0.0.2"}, {"p": "5.1.1.0/24", "n": "99.0.0.2"}, + {"p": "6.0.1.0/24", "n": "99.0.0.2"}, + {"p": "6.0.2.0/24", "n": "99.0.0.2"}, {"p": "99.0.0.2/32", "n": "192.168.1.2"}, ] bgpribRequireUnicastRoutes( @@ -67,6 +79,8 @@ bgpribRequireUnicastRoutes( want_r4_cust1_routes = [ {"p": "5.1.2.0/24", "n": "99.0.0.3"}, {"p": "5.1.3.0/24", "n": "99.0.0.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.3"}, + {"p": "6.0.2.0/24", "n": "99.0.0.3"}, {"p": "99.0.0.3/32", "n": "192.168.1.2"}, ] bgpribRequireUnicastRoutes( @@ -76,6 +90,8 @@ bgpribRequireUnicastRoutes( want_r4_cust2_routes = [ {"p": "5.4.2.0/24", "n": "99.0.0.4"}, {"p": "5.4.3.0/24", "n": "99.0.0.4"}, + {"p": "6.0.1.0/24", "n": "99.0.0.4"}, + {"p": "6.0.2.0/24", "n": "99.0.0.4"}, {"p": "99.0.0.4/32", "n": "192.168.2.2"}, ] bgpribRequireUnicastRoutes( @@ -152,23 +168,27 @@ else: luCommand( "r1", 'vtysh -c "show bgp ipv4 vpn"', - r"Distinguisher: *10:1.*5.1.0.0/24 *99.0.0.1\b.*5.1.1.0/24 *99.0.0.1\b.*99.0.0.1/32 *192.168.1.2\b", + r"Distinguisher: *10:1.*5.1.0.0/24 *99.0.0.1\b.*5.1.1.0/24 *99.0.0.1\b.*6.0.1.0/24 *99.0.0.1\b.*6.0.2.0/24 *99.0.0.1\b.*99.0.0.1/32 *192.168.1.2\b", "pass", "vrf->vpn routes", ) luCommand( "r3", 'vtysh -c "show bgp ipv4 vpn"', - r"Distinguisher: *10:3.*5.1.0.0/24 *99.0.0.2\b.*5.1.1.0/24 *99.0.0.2\b.*99.0.0.2/32 *192.168.1.2\b", + r"Distinguisher: *10:3.*5.1.0.0/24 *99.0.0.2\b.*5.1.1.0/24 *99.0.0.2\b.*6.0.1.0/24 *99.0.0.2\b.*6.0.2.0/24 *99.0.0.2\b.*99.0.0.2/32 *192.168.1.2\b", "pass", "vrf->vpn routes", ) want = [ {"rd": "10:41", "p": "5.1.2.0/24", "n": "99.0.0.3"}, {"rd": "10:41", "p": "5.1.3.0/24", "n": "99.0.0.3"}, + {"rd": "10:41", "p": "6.0.1.0/24", "n": "99.0.0.3"}, + {"rd": "10:41", "p": "6.0.2.0/24", "n": "99.0.0.3"}, {"rd": "10:41", "p": "99.0.0.3/32", "n": "192.168.1.2"}, {"rd": "10:42", "p": "5.4.2.0/24", "n": "99.0.0.4"}, {"rd": "10:42", "p": "5.4.3.0/24", "n": "99.0.0.4"}, + {"rd": "10:42", "p": "6.0.1.0/24", "n": "99.0.0.4"}, + {"rd": "10:42", "p": "6.0.2.0/24", "n": "99.0.0.4"}, {"rd": "10:42", "p": "99.0.0.4/32", "n": "192.168.2.2"}, ] bgpribRequireVpnRoutes("r4", "vrf->vpn routes", want) @@ -268,6 +288,8 @@ bgpribRequireVpnRoutes( want_r1_remote_cust1_routes = [ {"p": "5.1.0.0/24", "n": "3.3.3.3"}, {"p": "5.1.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.2.0/24", "n": "3.3.3.3"}, {"p": "99.0.0.2/32", "n": "3.3.3.3"}, {"p": "5.1.2.0/24", "n": "4.4.4.4"}, {"p": "5.1.3.0/24", "n": "4.4.4.4"}, @@ -275,24 +297,34 @@ want_r1_remote_cust1_routes = [ {"p": "5.4.2.0/24", "n": "4.4.4.4"}, {"p": "5.4.3.0/24", "n": "4.4.4.4"}, {"p": "99.0.0.3/32", "n": "4.4.4.4"}, + {"p": "6.0.1.0/24", "n": "4.4.4.4"}, + {"p": "6.0.2.0/24", "n": "4.4.4.4"}, + {"p": "6.0.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.2.0/24", "n": "99.0.0.1"}, ] bgpribRequireUnicastRoutes( - "r1", "ipv4", "r1-cust1", "Customer 1 routes in r1 vrf", want_r1_remote_cust1_routes + "r1", "ipv4", "r1-cust1", "Customer 1 routes in r1 vrf (2)", want_r1_remote_cust1_routes ) want_r3_remote_cust1_routes = [ {"p": "5.1.0.0/24", "n": "1.1.1.1"}, {"p": "5.1.1.0/24", "n": "1.1.1.1"}, {"p": "99.0.0.1/32", "n": "1.1.1.1"}, + {"p": "6.0.1.0/24", "n": "1.1.1.1"}, + {"p": "6.0.2.0/24", "n": "1.1.1.1"}, {"p": "5.1.2.0/24", "n": "4.4.4.4"}, {"p": "5.1.3.0/24", "n": "4.4.4.4"}, {"p": "99.0.0.3/32", "n": "4.4.4.4"}, {"p": "5.4.2.0/24", "n": "4.4.4.4"}, {"p": "5.4.3.0/24", "n": "4.4.4.4"}, {"p": "99.0.0.3/32", "n": "4.4.4.4"}, + {"p": "6.0.1.0/24", "n": "4.4.4.4"}, + {"p": "6.0.2.0/24", "n": "4.4.4.4"}, + {"p": "6.0.1.0/24", "n": "99.0.0.2"}, + {"p": "6.0.2.0/24", "n": "99.0.0.2"}, ] bgpribRequireUnicastRoutes( - "r3", "ipv4", "r3-cust1", "Customer 1 routes in r3 vrf", want_r3_remote_cust1_routes + "r3", "ipv4", "r3-cust1", "Customer 1 routes in r3 vrf (2)", want_r3_remote_cust1_routes ) want_r4_remote_cust1_routes = [ @@ -300,11 +332,19 @@ want_r4_remote_cust1_routes = [ {"p": "5.1.1.0/24", "n": "1.1.1.1"}, {"p": "5.1.0.0/24", "n": "3.3.3.3"}, {"p": "5.1.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.1.0/24", "n": "1.1.1.1"}, + {"p": "6.0.2.0/24", "n": "1.1.1.1"}, + {"p": "6.0.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.2.0/24", "n": "3.3.3.3"}, {"p": "99.0.0.1/32", "n": "1.1.1.1"}, {"p": "99.0.0.2/32", "n": "3.3.3.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.3"}, + {"p": "6.0.2.0/24", "n": "99.0.0.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.4"}, + {"p": "6.0.2.0/24", "n": "99.0.0.4"}, ] bgpribRequireUnicastRoutes( - "r4", "ipv4", "r4-cust1", "Customer 1 routes in r4 vrf", want_r4_remote_cust1_routes + "r4", "ipv4", "r4-cust1", "Customer 1 routes in r4 vrf (2)", want_r4_remote_cust1_routes ) want_r4_remote_cust2_routes = [ @@ -312,11 +352,19 @@ want_r4_remote_cust2_routes = [ {"p": "5.1.1.0/24", "n": "1.1.1.1"}, {"p": "5.1.0.0/24", "n": "3.3.3.3"}, {"p": "5.1.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.1.0/24", "n": "1.1.1.1"}, + {"p": "6.0.1.0/24", "n": "3.3.3.3"}, + {"p": "6.0.2.0/24", "n": "1.1.1.1"}, + {"p": "6.0.2.0/24", "n": "3.3.3.3"}, {"p": "99.0.0.1/32", "n": "1.1.1.1"}, {"p": "99.0.0.2/32", "n": "3.3.3.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.3"}, + {"p": "6.0.2.0/24", "n": "99.0.0.3"}, + {"p": "6.0.1.0/24", "n": "99.0.0.4"}, + {"p": "6.0.2.0/24", "n": "99.0.0.4"}, ] bgpribRequireUnicastRoutes( - "r4", "ipv4", "r4-cust2", "Customer 2 routes in r4 vrf", want_r4_remote_cust2_routes + "r4", "ipv4", "r4-cust2", "Customer 2 routes in r4 vrf (2)", want_r4_remote_cust2_routes ) @@ -330,7 +378,7 @@ bgpribRequireUnicastRoutes( luCommand( "ce1", 'vtysh -c "show bgp ipv4 uni"', - "10 routes and 10", + "12 routes and 12", "wait", "Local and remote routes", 10, @@ -340,13 +388,15 @@ want = [ {"p": "5.1.3.0/24", "n": "192.168.1.1"}, {"p": "5.4.2.0/24", "n": "192.168.1.1"}, {"p": "5.4.3.0/24", "n": "192.168.1.1"}, + {"p": "6.0.1.0/24", "n": "99.0.0.1"}, + {"p": "6.0.2.0/24", "n": "99.0.0.1"}, ] bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes from remote", want) luCommand( "ce2", 'vtysh -c "show bgp ipv4 uni"', - "10 routes and 12", + "12 routes and 16", "wait", "Local and remote routes", 10, @@ -358,6 +408,8 @@ want = [ {"p": "5.1.3.0/24", "n": "192.168.1.1"}, {"p": "5.4.2.0/24", "n": "192.168.1.1"}, {"p": "5.4.3.0/24", "n": "192.168.1.1"}, + {"p": "6.0.1.0/24", "n": "192.168.1.1"}, + {"p": "6.0.2.0/24", "n": "192.168.1.1"}, ] bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 1 routes from remote", want) @@ -371,7 +423,7 @@ luCommand("r4", 'vtysh -c "show ip route vrf r4-cust2"') luCommand( "ce3", 'vtysh -c "show bgp ipv4 uni"', - "10 routes and 10", + "12 routes and 14", "wait", "Local and remote routes", 10, @@ -382,13 +434,15 @@ want = [ {"p": "5.1.1.0/24", "n": "192.168.1.1"}, {"p": "5.4.2.0/24", "n": "192.168.1.1"}, {"p": "5.4.3.0/24", "n": "192.168.1.1"}, + {"p": "6.0.1.0/24", "n": "192.168.1.1"}, + {"p": "6.0.2.0/24", "n": "192.168.1.1"}, ] bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 1 routes from remote", want) luCommand( "ce4", 'vtysh -c "show bgp vrf ce4-cust2 ipv4 uni"', - "10 routes and 10", + "12 routes and 14", "wait", "Local and remote routes", 10, @@ -398,6 +452,8 @@ want = [ {"p": "5.1.1.0/24", "n": "192.168.2.1"}, {"p": "5.1.2.0/24", "n": "192.168.2.1"}, {"p": "5.1.3.0/24", "n": "192.168.2.1"}, + {"p": "6.0.1.0/24", "n": "192.168.2.1"}, + {"p": "6.0.2.0/24", "n": "192.168.2.1"}, ] bgpribRequireUnicastRoutes( "ce4", "ipv4", "ce4-cust2", "Cust 2 routes from remote", want diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py index b4fa240495..7990533f3a 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/scale_down.py @@ -49,7 +49,7 @@ if ret != False and found != None: luCommand( rtr, 'vtysh -c "show bgp ipv4 uni" | grep Display', - " 10 route", + " 12 route", "wait", "BGP routes removed", wait, From b4bfe0aa470288128e8c335434917b1c53544473 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 30 Sep 2020 00:09:04 -0400 Subject: [PATCH 3/6] tests: lib/bgprib.py - add bestpath checks and logging to lu log file Signed-off-by: Lou Berger --- tests/topotests/lib/bgprib.py | 44 ++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index 3d92718c78..8629ebd2ca 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -18,8 +18,8 @@ # # want_rd_routes = [ -# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'}, -# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'}, +# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1', 'bp': True}, +# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1', 'bp': False}, # # {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'}, # ] @@ -34,39 +34,47 @@ # ribRequireUnicastRoutes('r1','ipv4','','Customer routes in default',want_unicast_routes) # -from lutil import luCommand, luResult +from lutil import luCommand, luResult, LUtil import json import re # gpz: get rib in json form and compare against desired routes class BgpRib: + + def log(self, str): + LUtil.log ("BgpRib: "+ str) + def routes_include_wanted(self, pfxtbl, want, debug): # helper function to RequireVpnRoutes for pfx in pfxtbl.iterkeys(): if debug: - print "trying pfx " + pfx + self.log("trying pfx %s" % pfx) if pfx != want["p"]: if debug: - print "want pfx=" + want["p"] + ", not " + pfx + self.log("want pfx=" + want["p"] + ", not " + pfx) continue if debug: - print "have pfx=" + pfx + self.log("have pfx=%s" % pfx) for r in pfxtbl[pfx]: + bp = r.get("bestpath", False) if debug: - print "trying route" + self.log("trying route %s bp=%s" % (r, bp)) nexthops = r["nexthops"] for nh in nexthops: if debug: - print "trying nh " + nh["ip"] + self.log("trying nh %s" % nh["ip"]) if nh["ip"] == want["n"]: if debug: - print "found " + want["n"] - return 1 + self.log("found %s" % want["n"]) + if bp == want.get("bp", bp): + return 1 + elif debug: + self.log("bestpath mismatch %s != %s" % (bp, want["bp"])) else: if debug: - print "want nh=" + want["n"] + ", not " + nh["ip"] + self.log("want nh=" + want["n"] + ", not " + nh["ip"]) if debug: - print "missing route: pfx=" + want["p"] + ", nh=" + want["n"] + self.log("missing route: pfx=" + want["p"] + ", nh=" + want["n"]) return 0 def RequireVpnRoutes(self, target, title, wantroutes, debug=0): @@ -99,12 +107,12 @@ class BgpRib: for want in wantroutes: found = 0 if debug: - print "want rd " + want["rd"] + self.log("want rd %s" % want["rd"]) for rd in rds.iterkeys(): if rd != want["rd"]: continue if debug: - print "found rd " + rd + self.log("found rd %s" % rd) table = rds[rd] if self.routes_include_wanted(table, want, debug): found = 1 @@ -115,13 +123,13 @@ class BgpRib: luResult(target, True, title, logstr) def RequireUnicastRoutes(self, target, afi, vrf, title, wantroutes, debug=0): - logstr = "RequireVpnRoutes " + str(wantroutes) + logstr = "RequireVpnRoutes %s" % str(wantroutes) vrfstr = "" if vrf != "": vrfstr = "vrf %s" % (vrf) if (afi != "ipv4") and (afi != "ipv6"): - print "ERROR invalid afi" + self.log("ERROR invalid afi") cmdstr = "show bgp %s %s unicast" % (vrfstr, afi) # non json form for humans @@ -148,7 +156,11 @@ class BgpRib: errstr = "-script ERROR: check if vrf missing" luResult(target, False, title + errstr, logstr) return + #if debug: + # self.log("table=%s" % table) for want in wantroutes: + if debug: + self.log("want=%s" % want) if not self.routes_include_wanted(table, want, debug): luResult(target, False, title, logstr) return From 5df69602e7490c18dc687842c78f0e691ce6b683 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 30 Sep 2020 00:09:46 -0400 Subject: [PATCH 4/6] tests: bgp_l3vpn_to_bgp_vrf - add bestpath checks Signed-off-by: Lou Berger --- .../scripts/check_routes.py | 193 ++++++++++-------- 1 file changed, 106 insertions(+), 87 deletions(-) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py index a89cdc0b35..339838464a 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py @@ -286,86 +286,95 @@ bgpribRequireVpnRoutes( # PE routers: VRFs contain routes from remote customer nets ######################################################################## want_r1_remote_cust1_routes = [ - {"p": "5.1.0.0/24", "n": "3.3.3.3"}, - {"p": "5.1.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.2.0/24", "n": "3.3.3.3"}, - {"p": "99.0.0.2/32", "n": "3.3.3.3"}, + {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "5.1.0.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "5.1.1.0/24", "n": "99.0.0.1", "bp": True}, {"p": "5.1.2.0/24", "n": "4.4.4.4"}, {"p": "5.1.3.0/24", "n": "4.4.4.4"}, - {"p": "99.0.0.3/32", "n": "4.4.4.4"}, {"p": "5.4.2.0/24", "n": "4.4.4.4"}, {"p": "5.4.3.0/24", "n": "4.4.4.4"}, + {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "4.4.4.4", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "4.4.4.4", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "99.0.0.1/32", "n": "192.168.1.2", "bp": True}, + {"p": "99.0.0.2/32", "n": "3.3.3.3"}, {"p": "99.0.0.3/32", "n": "4.4.4.4"}, - {"p": "6.0.1.0/24", "n": "4.4.4.4"}, - {"p": "6.0.2.0/24", "n": "4.4.4.4"}, - {"p": "6.0.1.0/24", "n": "99.0.0.1"}, - {"p": "6.0.2.0/24", "n": "99.0.0.1"}, + {"p": "99.0.0.4/32", "n": "4.4.4.4"}, ] bgpribRequireUnicastRoutes( "r1", "ipv4", "r1-cust1", "Customer 1 routes in r1 vrf (2)", want_r1_remote_cust1_routes -) + , debug=False) want_r3_remote_cust1_routes = [ - {"p": "5.1.0.0/24", "n": "1.1.1.1"}, - {"p": "5.1.1.0/24", "n": "1.1.1.1"}, - {"p": "99.0.0.1/32", "n": "1.1.1.1"}, - {"p": "6.0.1.0/24", "n": "1.1.1.1"}, - {"p": "6.0.2.0/24", "n": "1.1.1.1"}, - {"p": "5.1.2.0/24", "n": "4.4.4.4"}, - {"p": "5.1.3.0/24", "n": "4.4.4.4"}, - {"p": "99.0.0.3/32", "n": "4.4.4.4"}, - {"p": "5.4.2.0/24", "n": "4.4.4.4"}, - {"p": "5.4.3.0/24", "n": "4.4.4.4"}, - {"p": "99.0.0.3/32", "n": "4.4.4.4"}, - {"p": "6.0.1.0/24", "n": "4.4.4.4"}, - {"p": "6.0.2.0/24", "n": "4.4.4.4"}, - {"p": "6.0.1.0/24", "n": "99.0.0.2"}, - {"p": "6.0.2.0/24", "n": "99.0.0.2"}, + {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.0.0/24", "n": "99.0.0.2", "bp": False}, + {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "99.0.0.2", "bp": False}, + {"p": "5.1.2.0/24", "n": "4.4.4.4", "bp": True}, + {"p": "5.1.3.0/24", "n": "4.4.4.4", "bp": True}, + {"p": "5.4.2.0/24", "n": "4.4.4.4", "bp": True}, + {"p": "5.4.3.0/24", "n": "4.4.4.4", "bp": True}, + {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "4.4.4.4", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": False}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "4.4.4.4", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": False}, + {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, + {"p": "99.0.0.3/32", "n": "4.4.4.4", "bp": True}, + {"p": "99.0.0.4/32", "n": "4.4.4.4", "bp": True}, ] bgpribRequireUnicastRoutes( "r3", "ipv4", "r3-cust1", "Customer 1 routes in r3 vrf (2)", want_r3_remote_cust1_routes -) + , debug=False) want_r4_remote_cust1_routes = [ - {"p": "5.1.0.0/24", "n": "1.1.1.1"}, - {"p": "5.1.1.0/24", "n": "1.1.1.1"}, - {"p": "5.1.0.0/24", "n": "3.3.3.3"}, - {"p": "5.1.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.1.0/24", "n": "1.1.1.1"}, - {"p": "6.0.2.0/24", "n": "1.1.1.1"}, - {"p": "6.0.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.2.0/24", "n": "3.3.3.3"}, - {"p": "99.0.0.1/32", "n": "1.1.1.1"}, - {"p": "99.0.0.2/32", "n": "3.3.3.3"}, - {"p": "6.0.1.0/24", "n": "99.0.0.3"}, - {"p": "6.0.2.0/24", "n": "99.0.0.3"}, - {"p": "6.0.1.0/24", "n": "99.0.0.4"}, - {"p": "6.0.2.0/24", "n": "99.0.0.4"}, + {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False}, + {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, + {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True}, + {"p": "99.0.0.3/32", "n": "192.168.1.2", "bp": True}, + {"p": "99.0.0.4/32", "n": "192.168.2.2", "bp": True}, ] bgpribRequireUnicastRoutes( "r4", "ipv4", "r4-cust1", "Customer 1 routes in r4 vrf (2)", want_r4_remote_cust1_routes -) + , debug=False) want_r4_remote_cust2_routes = [ - {"p": "5.1.0.0/24", "n": "1.1.1.1"}, - {"p": "5.1.1.0/24", "n": "1.1.1.1"}, - {"p": "5.1.0.0/24", "n": "3.3.3.3"}, - {"p": "5.1.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.1.0/24", "n": "1.1.1.1"}, - {"p": "6.0.1.0/24", "n": "3.3.3.3"}, - {"p": "6.0.2.0/24", "n": "1.1.1.1"}, - {"p": "6.0.2.0/24", "n": "3.3.3.3"}, - {"p": "99.0.0.1/32", "n": "1.1.1.1"}, - {"p": "99.0.0.2/32", "n": "3.3.3.3"}, - {"p": "6.0.1.0/24", "n": "99.0.0.3"}, - {"p": "6.0.2.0/24", "n": "99.0.0.3"}, - {"p": "6.0.1.0/24", "n": "99.0.0.4"}, - {"p": "6.0.2.0/24", "n": "99.0.0.4"}, + {"p": "5.1.0.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.0.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "5.1.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False}, + {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, + {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True}, + {"p": "99.0.0.3/32", "n": "192.168.1.2", "bp": True}, + {"p": "99.0.0.4/32", "n": "192.168.2.2", "bp": True}, ] bgpribRequireUnicastRoutes( "r4", "ipv4", "r4-cust2", "Customer 2 routes in r4 vrf (2)", want_r4_remote_cust2_routes -) + , debug=False) ######################################################################### @@ -384,14 +393,16 @@ luCommand( 10, ) want = [ - {"p": "5.1.2.0/24", "n": "192.168.1.1"}, - {"p": "5.1.3.0/24", "n": "192.168.1.1"}, - {"p": "5.4.2.0/24", "n": "192.168.1.1"}, - {"p": "5.4.3.0/24", "n": "192.168.1.1"}, - {"p": "6.0.1.0/24", "n": "99.0.0.1"}, - {"p": "6.0.2.0/24", "n": "99.0.0.1"}, + {"p": "5.1.0.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "5.1.2.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.1.3.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "99.0.0.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "99.0.0.1", "bp": True}, ] -bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes from remote", want) +bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes from remote", want, debug=False) luCommand( "ce2", @@ -402,16 +413,20 @@ luCommand( 10, ) want = [ - {"p": "5.1.0.0/24", "n": "192.168.1.1"}, - {"p": "5.1.1.0/24", "n": "192.168.1.1"}, - {"p": "5.1.2.0/24", "n": "192.168.1.1"}, - {"p": "5.1.3.0/24", "n": "192.168.1.1"}, - {"p": "5.4.2.0/24", "n": "192.168.1.1"}, - {"p": "5.4.3.0/24", "n": "192.168.1.1"}, - {"p": "6.0.1.0/24", "n": "192.168.1.1"}, - {"p": "6.0.2.0/24", "n": "192.168.1.1"}, + {"p": "5.1.0.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "5.1.0.0/24", "n": "99.0.0.2", "bp": True}, + {"p": "5.1.1.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "5.1.1.0/24", "n": "99.0.0.2", "bp": True}, + {"p": "5.1.2.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.1.3.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": True}, + {"p": "6.0.2.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": True}, ] -bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 1 routes from remote", want) +bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 1 routes from remote", want, debug=False) # human readable output for debugging luCommand("r4", 'vtysh -c "show bgp vrf r4-cust1 ipv4 uni"') @@ -430,14 +445,16 @@ luCommand( ) # Requires bvl-bug-degenerate-no-label fix (FRR PR #2053) want = [ - {"p": "5.1.0.0/24", "n": "192.168.1.1"}, - {"p": "5.1.1.0/24", "n": "192.168.1.1"}, - {"p": "5.4.2.0/24", "n": "192.168.1.1"}, - {"p": "5.4.3.0/24", "n": "192.168.1.1"}, - {"p": "6.0.1.0/24", "n": "192.168.1.1"}, - {"p": "6.0.2.0/24", "n": "192.168.1.1"}, + {"p": "5.1.0.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.2.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "6.0.2.0/24", "n": "192.168.1.1", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": True}, + {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": True}, ] -bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 1 routes from remote", want) +bgpribRequireUnicastRoutes("ce3", "ipv4", "", "Cust 1 routes from remote", want, debug=False) luCommand( "ce4", @@ -448,13 +465,15 @@ luCommand( 10, ) want = [ - {"p": "5.1.0.0/24", "n": "192.168.2.1"}, - {"p": "5.1.1.0/24", "n": "192.168.2.1"}, - {"p": "5.1.2.0/24", "n": "192.168.2.1"}, - {"p": "5.1.3.0/24", "n": "192.168.2.1"}, - {"p": "6.0.1.0/24", "n": "192.168.2.1"}, - {"p": "6.0.2.0/24", "n": "192.168.2.1"}, + {"p": "5.1.0.0/24", "n": "192.168.2.1", "bp": True}, + {"p": "5.1.1.0/24", "n": "192.168.2.1", "bp": True}, + {"p": "5.1.2.0/24", "n": "192.168.2.1", "bp": True}, + {"p": "5.1.3.0/24", "n": "192.168.2.1", "bp": True}, + {"p": "6.0.1.0/24", "n": "192.168.2.1", "bp": False}, + {"p": "6.0.2.0/24", "n": "192.168.2.1", "bp": False}, + {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": True}, + {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": True}, ] bgpribRequireUnicastRoutes( - "ce4", "ipv4", "ce4-cust2", "Cust 2 routes from remote", want + "ce4", "ipv4", "ce4-cust2", "Cust 2 routes from remote", want, debug=False ) From 7946452bfc5a2a7585cfaddcec18d7fd023fb314 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 30 Sep 2020 10:50:57 -0400 Subject: [PATCH 5/6] tests: bgp_l3vpn_to_bgp_vrf - change 1 route to have equal metrics Signed-off-by: Lou Berger --- .../topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf | 12 ++++++++++-- .../topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf | 12 ++++++++++-- .../topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf | 12 ++++++++++-- .../topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf | 12 ++++++++++-- .../bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py | 15 +++++++-------- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf index dbb1c2437c..ae574319b3 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce1/bgpd.conf @@ -19,7 +19,7 @@ router bgp 5227 network 5.1.1.0/24 route-map rm-nh redistribute sharp route-map sharp-nh network 6.0.1.0/24 route-map rm-nh - network 6.0.2.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh-same neighbor 192.168.1.1 activate exit-address-family ! @@ -43,5 +43,13 @@ route-map sharp-nh permit 10 set extcommunity rt 80:987 set community 0:65 ! - +route-map rm-nh-same permit 10 + match ip address al-any + set ip next-hop 99.0.0.1 + set local-preference 100 + set metric 100 + set large-community 12:34:11 + set extcommunity rt 89:123 + set community 0:67 +! end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf index b0e19e6645..599e2ddc1e 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce2/bgpd.conf @@ -19,7 +19,7 @@ router bgp 5227 network 5.1.1.0/24 route-map rm-nh redistribute sharp route-map sharp-nh network 6.0.1.0/24 route-map rm-nh - network 6.0.2.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh-same neighbor 192.168.1.1 activate exit-address-family ! @@ -43,5 +43,13 @@ route-map sharp-nh permit 10 set extcommunity rt 70:456 set community 0:66 ! - +route-map rm-nh-same permit 10 + match ip address al-any + set ip next-hop 99.0.0.2 + set local-preference 100 + set metric 100 + set large-community 12:34:12 + set extcommunity rt 89:123 + set community 0:67 +! end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf index ec93c5ba2f..e316de5690 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce3/bgpd.conf @@ -18,7 +18,7 @@ router bgp 5227 network 5.1.2.0/24 route-map rm-nh network 5.1.3.0/24 route-map rm-nh network 6.0.1.0/24 route-map rm-nh - network 6.0.2.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh-same neighbor 192.168.1.1 activate exit-address-family ! @@ -33,5 +33,13 @@ route-map rm-nh permit 10 set extcommunity rt 89:123 set community 0:67 ! - +route-map rm-nh-same permit 10 + match ip address al-any + set ip next-hop 99.0.0.3 + set local-preference 100 + set metric 100 + set large-community 12:34:13 + set extcommunity rt 89:123 + set community 0:67 +! end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf index e1cc9574e8..60d9e93108 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/ce4/bgpd.conf @@ -18,7 +18,7 @@ router bgp 5228 vrf ce4-cust2 network 5.4.2.0/24 route-map rm-nh network 5.4.3.0/24 route-map rm-nh network 6.0.1.0/24 route-map rm-nh - network 6.0.2.0/24 route-map rm-nh + network 6.0.2.0/24 route-map rm-nh-same neighbor 192.168.2.1 activate exit-address-family ! @@ -33,5 +33,13 @@ route-map rm-nh permit 10 set extcommunity rt 89:123 set community 0:67 ! - +route-map rm-nh-same permit 10 + match ip address al-any + set ip next-hop 99.0.0.4 + set local-preference 100 + set metric 100 + set large-community 12:34:14 + set extcommunity rt 89:123 + set community 0:67 +! end diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py index 339838464a..34f0505126 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py @@ -321,9 +321,9 @@ want_r3_remote_cust1_routes = [ {"p": "6.0.1.0/24", "n": "1.1.1.1", "bp": True}, {"p": "6.0.1.0/24", "n": "4.4.4.4", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": False}, - {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": False}, {"p": "6.0.2.0/24", "n": "4.4.4.4", "bp": False}, - {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": True}, {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, {"p": "99.0.0.3/32", "n": "4.4.4.4", "bp": True}, {"p": "99.0.0.4/32", "n": "4.4.4.4", "bp": True}, @@ -341,10 +341,10 @@ want_r4_remote_cust1_routes = [ {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False}, - {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": False}, {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False}, {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False}, - {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": True}, {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True}, {"p": "99.0.0.3/32", "n": "192.168.1.2", "bp": True}, @@ -363,9 +363,9 @@ want_r4_remote_cust2_routes = [ {"p": "6.0.1.0/24", "n": "3.3.3.3", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.3", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.4", "bp": False}, - {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": True}, + {"p": "6.0.2.0/24", "n": "1.1.1.1", "bp": False}, {"p": "6.0.2.0/24", "n": "3.3.3.3", "bp": False}, - {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": False}, + {"p": "6.0.2.0/24", "n": "99.0.0.3", "bp": True}, {"p": "6.0.2.0/24", "n": "99.0.0.4", "bp": False}, {"p": "99.0.0.1/32", "n": "1.1.1.1", "bp": True}, {"p": "99.0.0.2/32", "n": "3.3.3.3", "bp": True}, @@ -407,7 +407,7 @@ bgpribRequireUnicastRoutes("ce1", "ipv4", "", "Cust 1 routes from remote", want, luCommand( "ce2", 'vtysh -c "show bgp ipv4 uni"', - "12 routes and 16", + "12 routes and 15", "wait", "Local and remote routes", 10, @@ -423,7 +423,6 @@ want = [ {"p": "5.4.3.0/24", "n": "192.168.1.1", "bp": True}, {"p": "6.0.1.0/24", "n": "192.168.1.1", "bp": False}, {"p": "6.0.1.0/24", "n": "99.0.0.2", "bp": True}, - {"p": "6.0.2.0/24", "n": "192.168.1.1", "bp": False}, {"p": "6.0.2.0/24", "n": "99.0.0.2", "bp": True}, ] bgpribRequireUnicastRoutes("ce2", "ipv4", "", "Cust 1 routes from remote", want, debug=False) From a69e5dd7efa129db59ee6795a5f7281da1badc62 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Thu, 1 Oct 2020 08:55:32 -0400 Subject: [PATCH 6/6] tests: bgp_l3vpn_to_bgp_vrf - verify details of exported/imported routes Signed-off-by: Lou Berger --- .../scripts/check_routes.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py index 34f0505126..f553513b9c 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py @@ -476,3 +476,59 @@ want = [ bgpribRequireUnicastRoutes( "ce4", "ipv4", "ce4-cust2", "Cust 2 routes from remote", want, debug=False ) + +#verify details of exported/imported routes +luCommand("ce1",'vtysh -c "show bgp ipv4 uni 6.0.1.0"', + "1 available.*192.168.1.1.*99.0.0.1.*Community: 0:67.*Extended Community: RT:89:123.*Large Community: 12:34:56", + "pass", "Redundant route 1 details") +luCommand("ce2",'vtysh -c "show bgp ipv4 uni 6.0.1.0"', + "2 available, best .*192.168.1.1.* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1" + + ".* Origin IGP, metric 98, localpref 123, valid, internal" + + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:56", + ".* Local.* 99.0.0.2 from 0.0.0.0 .99.0.0.2" + + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:56", + "pass", "Redundant route 1 details") +luCommand("ce3",'vtysh -c "show bgp ipv4 uni 6.0.1.0"', + "2 available, best .*192.168.1.1.* Local.* 99.0.0.3 from 0.0.0.0 .99.0.0.3" + + ".* Origin IGP, metric 200, localpref 50, weight 32768, valid, sourced, local, best .Weight" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:56" + + ".* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1" + + ".* Origin IGP, metric 98, localpref 123, valid, internal" + + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:56", + "pass", "Redundant route 1 details") +luCommand("ce4",'vtysh -c "show bgp vrf ce4-cust2 ipv4 6.0.1.0"', + "2 available, best .*192.168.2.1.* Local.* 192.168.2.1 from 192.168.2.1 .192.168.2.1" + + ".* Origin IGP, metric 98, localpref 123, valid, internal" + + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:56" + + ".* Local.* 99.0.0.4 from 0.0.0.0 .99.0.0.4" + + ".* Origin IGP, metric 200, localpref 50, weight 32768, valid, sourced, local, best .Weight" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:56", + "pass", "Redundant route 1 details") + +luCommand("ce1",'vtysh -c "show bgp ipv4 uni 6.0.2.0"', + "1 available, best .*192.168.1.1.* Local.* 99.0.0.1 from 0.0.0.0 .99.0.0.1" + + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .First path received" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:11", + "pass", "Redundant route 2 details") +luCommand("ce2",'vtysh -c "show bgp ipv4 uni 6.0.2.0"', "1 available, best .*192.168.1.1.* Local.* 99.0.0.2 from 0.0.0.0 .99.0.0.2" + + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .First path received" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:12", + "pass", "Redundant route 2 details") +luCommand("ce3",'vtysh -c "show bgp ipv4 uni 6.0.2.0"', + "2 available, best .*192.168.1.1.* Local.* 99.0.0.3 from 0.0.0.0 .99.0.0.3" + + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:13" + + ".* Local.* 192.168.1.1 from 192.168.1.1 .192.168.1.1" + + ".* Origin IGP, metric 100, localpref 100, valid, internal" + + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:14", + "pass", "Redundant route 2 details") +luCommand("ce4",'vtysh -c "show bgp vrf ce4-cust2 ipv4 6.0.2.0"', + "2 available, best .*192.168.2.1.* Local.* 192.168.2.1 from 192.168.2.1 .192.168.2.1" + + ".* Origin IGP, metric 100, localpref 100, valid, internal" + + ".* Community: 0:67.* Extended Community: RT:52:100 RT:89:123.* Large Community: 12:34:13" + + ".* Local.* 99.0.0.4 from 0.0.0.0 .99.0.0.4" + + ".* Origin IGP, metric 100, localpref 100, weight 32768, valid, sourced, local, best .Weight" + + ".* Community: 0:67.* Extended Community: RT:89:123.* Large Community: 12:34:14", + "pass", "Redundant route 2 details") +#done