-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[evpn]: Change frr template to support evpn #2838
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,62 @@ route-map FROM_BGP_SPEAKER_V4 permit 10 | |
! | ||
route-map TO_BGP_SPEAKER_V4 deny 10 | ||
! | ||
{% block vnet_bgp_instance %} | ||
{% if VNET is defined %} | ||
! 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 | ||
{% for (name, prefix) in LOOPBACK_INTERFACE %} | ||
{% if prefix | ipv4 and name == 'Loopback0' %} | ||
bgp router-id {{ prefix | ip }} | ||
{% endif %} | ||
{% endfor %} | ||
{# got interfaces that belong this vnet #} | ||
{% set interfaces_in_vnet = [] %} | ||
{% for ((name, prefix), metadata) in INTERFACE.iteritems() %} | ||
{% if metadata.has_key("vnet_name") and metadata["vnet_name"] == vnet_name %} | ||
{% do interfaces_in_vnet.append( prefix | ip ) %} | ||
{% endif %} | ||
{% endfor %} | ||
{% 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 | ||
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} | ||
neighbor {{ neighbor_addr }} allowas-in 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you describe the circumstances, setup and requirements that need the allowas-in so that I can better understand? Especially under address-family ipv4, allowas-in shouldn't be needed but I'm looking forward to your explanation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is needed as the tor asn is re-used for different clusters. |
||
{% endif %} | ||
neighbor {{ neighbor_addr }} activate | ||
neighbor {{ neighbor_addr }} soft-reconfiguration inbound | ||
{% if bgp_session['rrclient'] | int != 0 %} | ||
neighbor {{ neighbor_addr }} route-reflector-client | ||
{% endif %} | ||
{% if bgp_session['nhopself'] | int != 0 %} | ||
neighbor {{ neighbor_addr }} next-hop-self | ||
{% endif %} | ||
maximum-paths 64 | ||
exit-address-family | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
address-family l2vpn evpn | ||
advertise ipv4 unicast | ||
exit-address-family | ||
{% endfor %} | ||
{% endif %} | ||
{% endblock vnet_bgp_instance %} | ||
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | ||
bgp log-neighbor-changes | ||
bgp bestpath as-path multipath-relax | ||
|
@@ -116,7 +172,15 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | |
{% endfor %} | ||
{% endblock vlan_advertisement %} | ||
{% block bgp_sessions %} | ||
{# got interfaces that belong vnet #} | ||
{% set interfaces_in_vnet = [] %} | ||
{% for ((name, prefix), metadata) in INTERFACE.iteritems() %} | ||
{% if metadata.has_key("vnet_name") %} | ||
{% do interfaces_in_vnet.append( prefix | ip ) %} | ||
{% endif %} | ||
{% endfor %} | ||
{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %} | ||
{% if not bgp_session.has_key("local_addr") or bgp_session["local_addr"] not 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'] }} | ||
|
@@ -128,10 +192,13 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | |
{% 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 not bgp_session.has_key("address-family") or bgp_session["address-family"] == "ip" %} | ||
{% if neighbor_addr | ipv4 %} | ||
address-family ipv4 | ||
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} | ||
neighbor {{ neighbor_addr }} allowas-in 1 | ||
{% elif bgp_session.has_key("allowas-in") %} | ||
neighbor {{ neighbor_addr }} allowas-in {{ bgp_session["allowas-in"] }} | ||
{% endif %} | ||
neighbor {{ neighbor_addr }} activate | ||
neighbor {{ neighbor_addr }} soft-reconfiguration inbound | ||
|
@@ -148,6 +215,8 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | |
address-family ipv6 | ||
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} | ||
neighbor {{ neighbor_addr }} allowas-in 1 | ||
{% elif bgp_session.has_key("allowas-in") %} | ||
neighbor {{ neighbor_addr }} allowas-in {{ bgp_session["allowas-in"] }} | ||
{% endif %} | ||
neighbor {{ neighbor_addr }} activate | ||
neighbor {{ neighbor_addr }} soft-reconfiguration inbound | ||
|
@@ -163,6 +232,13 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | |
maximum-paths 64 | ||
exit-address-family | ||
{% endif %} | ||
{% elif bgp_session["address-family"] == "evpn" %} | ||
address-family l2vpn evpn | ||
neighbor {{ neighbor_addr }} activate | ||
advertise-all-vni | ||
exit-address-family | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock bgp_sessions %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,7 +229,7 @@ def main(): | |
paths = ['/', '/usr/share/sonic/templates', os.path.dirname(template_file)] | ||
loader = jinja2.FileSystemLoader(paths) | ||
|
||
env = jinja2.Environment(loader=loader, trim_blocks=True) | ||
env = jinja2.Environment(loader=loader, trim_blocks=True, extensions=['jinja2.ext.do']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need this jinja2.ext.do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a temp variable to store the interfaces that belong to the specified vnet. In this situation, the "do" action will be needed. |
||
env.filters['sort_by_port_index'] = sort_by_port_index | ||
env.filters['ipv4'] = is_ipv4 | ||
env.filters['ipv6'] = is_ipv6 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does this VNET comes from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/Azure/SONiC/blob/master/doc/vxlan/Vxlan_hld.md#212-vnetinterface-table
VNET comes from the ConfigDB