9dc285ab05
1. Made the command next-hop-self force only applicable on back-end asic bgp. This is done so that BGPL iBGP session running on backend can send e-BGP learn nexthop. Back end asic FRR is able to recursively resolve the eBGP nexthop in its routing table since it knows about all the connected routes advertise from front end asic. 2. Made all front-end asic bgp use global loopback ip (Loopback0) as router id and back end asic bgp use Loopbacl4096 as ruter-id and originator id for Route-Reflector. This is done so that routes learnt by external peer do not see Loopback4096 as router id in show ip bgp <route-prerfix> output. 3. To handle above change need to pass Loopback4096 from BGP manager for jinja2 template generation. This was missing and this change/fix is needed for this also https://github.com/Azure/sonic-buildimage/blob/master/dockers/docker-fpm-frr/frr/bgpd/templates/dynamic/instance.conf.j2#L27 4. Enhancement to add mult_asic specific bgpd template generation unit test cases.
118 lines
3.9 KiB
Django/Jinja
118 lines
3.9 KiB
Django/Jinja
{% from "common/functions.conf.j2" import get_ipv4_loopback_address, get_ipv6_loopback_address, get_vnet_interfaces %}
|
|
!
|
|
! template: bgpd/bgpd.main.conf.j2
|
|
!
|
|
! bgp multiple-instance
|
|
!
|
|
! BGP configuration
|
|
!
|
|
! TSA configuration
|
|
!
|
|
ip prefix-list PL_LoopbackV4 permit {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32
|
|
!
|
|
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
|
|
ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | replace('/128', '/64') | ip_network }}/64
|
|
{% endif %}
|
|
!
|
|
{% if VLAN_INTERFACE is defined %}
|
|
{% set vnet_intfs = get_vnet_interfaces(VLAN_INTERFACE) %}
|
|
{% endif %}
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv4 and name not in vnet_intfs %}
|
|
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq {{ loop.index * 5 }} permit {{ prefix }}
|
|
!
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv6 and name not in vnet_intfs %}
|
|
ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq {{ loop.index * 5 }} permit {{ prefix }}
|
|
!
|
|
{% endif %}
|
|
{% endfor %}
|
|
!
|
|
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
route-map HIDE_INTERNAL permit 10
|
|
set community local-AS
|
|
{% set multi_asic = True %}
|
|
!
|
|
{% endif %}
|
|
!
|
|
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
|
!
|
|
{% block bgp_init %}
|
|
bgp log-neighbor-changes
|
|
no bgp default ipv4-unicast
|
|
!
|
|
{% if constants.bgp.multipath_relax.enabled is defined and constants.bgp.multipath_relax.enabled %}
|
|
bgp bestpath as-path multipath-relax
|
|
{% endif %}
|
|
!
|
|
{% if constants.bgp.graceful_restart.enabled is defined and constants.bgp.graceful_restart.enabled %}
|
|
bgp graceful-restart restart-time {{ constants.bgp.graceful_restart.restart_time | default(240) }}
|
|
bgp graceful-restart
|
|
bgp graceful-restart preserve-fw-state
|
|
{% endif %}
|
|
!
|
|
{# set router-id #}
|
|
{% if DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
|
|
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}
|
|
{% else %}
|
|
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}
|
|
{% endif %}
|
|
!
|
|
{# advertise loopback #}
|
|
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32
|
|
{% if multi_asic is defined %}
|
|
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/32 route-map HIDE_INTERNAL
|
|
{% endif %}
|
|
!
|
|
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
|
|
address-family ipv6
|
|
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64
|
|
exit-address-family
|
|
{% endif %}
|
|
{% if multi_asic is defined %}
|
|
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") != 'None' %}
|
|
address-family ipv6
|
|
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/64 route-map HIDE_INTERNAL
|
|
exit-address-family
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endblock bgp_init %}
|
|
!
|
|
{% block vlan_advertisement %}
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv4 and name not in vnet_intfs %}
|
|
network {{ prefix }}
|
|
{% elif prefix | ipv6 and name not in vnet_intfs %}
|
|
address-family ipv6
|
|
network {{ prefix }}
|
|
exit-address-family
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endblock vlan_advertisement %}
|
|
!
|
|
!
|
|
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' %}
|
|
address-family ipv4
|
|
redistribute connected route-map HIDE_INTERNAL
|
|
exit-address-family
|
|
address-family ipv6
|
|
redistribute connected route-map HIDE_INTERNAL
|
|
exit-address-family
|
|
{% endif %}
|
|
!
|
|
{% if constants.bgp.maximum_paths.enabled is defined and constants.bgp.maximum_paths.enabled %}
|
|
{% block maximum_paths %}
|
|
address-family ipv4
|
|
maximum-paths {{ constants.bgp.maximum_paths.ipv4 | default(64) }}
|
|
exit-address-family
|
|
address-family ipv6
|
|
maximum-paths {{ constants.bgp.maximum_paths.ipv6 | default(64) }}
|
|
exit-address-family
|
|
{% endblock maximum_paths %}
|
|
{% endif %}
|
|
!
|
|
! end of template: bgpd/bgpd.main.conf.j2
|
|
!
|