sonic-buildimage/dockers/docker-fpm-frr/frr/bgpd/bgpd.spine_chassis_frontend_router.conf.j2

64 lines
2.6 KiB
Plaintext
Raw Normal View History

!
{# VNET BGP Instance #}
! Vnet BGP instance
{% set interfaces_in_vnets = [] %}
{% block vnet_bgp_instance %}
{% for vnet_name, vnet_metadata in VNET.iteritems() %}
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} vrf {{ vnet_name }}
no bgp default ipv4-unicast
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
bgp graceful-restart restart-time 240
bgp graceful-restart
{# Router ID #}
{% for (name, prefix) in LOOPBACK_INTERFACE | pfx_filter %}
{% if prefix | ipv4 and name == 'Loopback0' %}
bgp router-id {{ prefix | ip }}
{% endif %}
{% endfor %}
{# Got interfaces that belong this vnet #}
{% set interfaces_in_vnet = [] %}
{% for (key, metadata) in INTERFACE.iteritems() %}
{% if metadata.has_key("vnet_name") and metadata["vnet_name"] == vnet_name %}
{% for (name_prefix_pair, metadata) in INTERFACE.iteritems() %}
{% if key == name_prefix_pair[0] %}
{% if interfaces_in_vnet.append( name_prefix_pair[1] | ip ) %}
{% endif %}
{% if interfaces_in_vnets.append( name_prefix_pair[1] | ip ) %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{# Each bgp neighbors #}
{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %}
{% if bgp_session.has_key("local_addr") and bgp_session["local_addr"] in interfaces_in_vnet %}
{% if bgp_session['asn'] | int != 0 %}
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
{# set the bgp neighbor timers if they have not default values #}
{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60)
or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %}
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }}
{% endif %}
{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and DEVICE_METADATA['localhost'].has_key('default_bgp_status') and DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %}
neighbor {{ neighbor_addr }} shutdown
{% endif %}
{% if neighbor_addr | ipv4 %}
address-family ipv4 unicast
neighbor {{ neighbor_addr }} activate
neighbor {{ neighbor_addr }} soft-reconfiguration inbound
maximum-paths 64
exit-address-family
{% endif %}
address-family l2vpn evpn
advertise ipv4 unicast
exit-address-family
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% endblock vnet_bgp_instance %}
!