From e34c2e4a226bfe2be38850d457eef0981f6c9ea1 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:36:24 -0800 Subject: [PATCH] Updated BGP Template for Chassis/Multi-asic (#9291) Updated BGP Template for the case: 1. For Packet Chassis do not advertise Loopback4096 address into BGP as there is Static Route for same. Having this route in BGP causes two level of recursion in Zebra and cause assert in Zebra when there are many nexthop involved 2. Advertise only P2P Connected IP's into BGP (External Peers). For Packet chassis we have backend IP Interface subnet and if they get advertised into BGP then it also causes recursion --- .../docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 | 20 +++++++++++++++---- .../data/sonic-cfggen/bgpd.conf.j2/all.conf | 16 +++++++++++++-- .../sonic-cfggen/bgpd.main.conf.j2/all.conf | 16 +++++++++++++-- .../bgpd.main.conf.j2/defaults.conf | 16 +++++++++++++-- .../bgpd.main.conf.j2/packet_chassis.conf | 20 +++++++++++++------ .../bgpd.main.conf.j2/voq_chassis.conf | 16 +++++++++++++-- .../data/sonic-cfggen/frr.conf.j2/all.conf | 16 +++++++++++++-- .../py2/bgpd_frr_backend_asic.conf | 12 +++++++++++ .../py2/bgpd_frr_frontend_asic.conf | 16 +++++++++++++-- .../py3/bgpd_frr_backend_asic.conf | 12 +++++++++++ .../py3/bgpd_frr_frontend_asic.conf | 16 +++++++++++++-- 11 files changed, 152 insertions(+), 24 deletions(-) diff --git a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 index 1453d6fc80..c1616c043f 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -34,6 +34,18 @@ ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq {{ loop.index * 5 }} permit {{ prefi {% set multi_asic = True %} {% endif %} {% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export {% if constants.bgp.peers is defined and constants.bgp.peers.internal is defined and constants.bgp.peers.internal.community is defined %} @@ -71,7 +83,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} ! {# advertise loopback #} network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32 -{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} +{% if ((multi_asic is defined and DEVICE_METADATA['localhost']['switch_type'] != 'chassis-packet') or (DEVICE_METADATA['localhost']['switch_type'] == 'voq')) %} network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/32 route-map HIDE_INTERNAL {% endif %} ! @@ -80,7 +92,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64 exit-address-family {% endif %} -{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} +{% if ((multi_asic is defined and DEVICE_METADATA['localhost']['switch_type'] != 'chassis-packet') or (DEVICE_METADATA['localhost']['switch_type'] == 'voq')) %} {% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") != 'None' %} address-family ipv6 network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/128 route-map HIDE_INTERNAL @@ -104,10 +116,10 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} ! {% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family {% endif %} ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.conf index b6f7a668bc..c39115706d 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.conf @@ -33,6 +33,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export on-match next @@ -71,10 +83,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.conf index 5d09db5965..c5ba79d343 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.conf @@ -15,6 +15,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -50,10 +62,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.conf index 14aa080efb..00b09bd40d 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.conf @@ -15,6 +15,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -50,10 +62,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf index b48617a6d8..2852ce1502 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf @@ -15,6 +15,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -35,14 +47,10 @@ router bgp 55555 bgp router-id 55.55.55.56 ! network 55.55.55.55/32 - network 55.55.55.56/32 route-map HIDE_INTERNAL ! address-family ipv6 network fc00::1/64 exit-address-family - address-family ipv6 - network fc00::2/128 route-map HIDE_INTERNAL - exit-address-family ! network 10.10.10.1/24 address-family ipv6 @@ -50,10 +58,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf index b48617a6d8..26f06d843a 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf @@ -15,6 +15,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -50,10 +62,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.conf index 1996dced81..606788cba9 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.conf @@ -52,6 +52,18 @@ ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 ! ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -86,10 +98,10 @@ router bgp 55555 exit-address-family ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf index a4ad1c677a..0def8a6be3 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf @@ -34,6 +34,18 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf index b49d3ddd4d..ecdb3818ff 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf @@ -34,6 +34,18 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -66,10 +78,10 @@ router bgp 65100 ! ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4 diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf index a4ad1c677a..0def8a6be3 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf @@ -34,6 +34,18 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf index b49d3ddd4d..ecdb3818ff 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf @@ -34,6 +34,18 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ! +ip prefix-list V4_P2P_IP permit 0.0.0.0/0 ge 31 le 31 +! +ipv6 prefix-list V6_P2P_IP permit ::/0 ge 126 le 126 +! +route-map V4_CONNECTED_ROUTES permit 10 + match ip address prefix-list V4_P2P_IP + call HIDE_INTERNAL +! +route-map V6_CONNECTED_ROUTES permit 10 + match ipv6 address prefix-list V6_P2P_IP + call HIDE_INTERNAL +! route-map HIDE_INTERNAL permit 10 set community no-export ! @@ -66,10 +78,10 @@ router bgp 65100 ! ! address-family ipv4 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V4_CONNECTED_ROUTES exit-address-family address-family ipv6 - redistribute connected route-map HIDE_INTERNAL + redistribute connected route-map V6_CONNECTED_ROUTES exit-address-family ! address-family ipv4