Skip to content
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

Optional bgp on sonic #223

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions partition/roles/sonic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ It depends on the `switch_facts` module from `ansible-common`, so make sure modu
| sonic_mgmt_vrf | yes | Boolean flag to enable / disable the management vrf on the switch. |
| sonic_ntpservers | yes | The time servers to use on the switch. |
| sonic_nameservers | yes | The name servers to use on the switch. |
| sonic_loopback_address | yes | The loopback address use for this router. Is used to identify routers with bgp unnumbered. |
| sonic_asn | yes | The autonomous system number of the router. |
| sonic_loopback_address | | The loopback address use for this router. Is used to identify routers with bgp unnumbered. |
| sonic_asn | | The autonomous system number of the router. |
| sonic_mgmtif_ip | | The fixed IP address of the management interface in `IP/netmask` format. If not given, defaults to DHCP. |
| sonic_mgmtif_gateway | | If using a fixed management IP, the default gateway for the management interface. |
| sonic_ip_masquerade | | Enable ip masquerading on eth0. |
Expand Down
4 changes: 1 addition & 3 deletions partition/roles/sonic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
quiet: yes
that:
- sonic_mgmt_vrf is defined
- sonic_loopback_address is defined
- sonic_asn is defined
- sonic_config_action in ['load', 'reload']
- sonic_ntpservers is defined
- sonic_nameservers is defined
Expand Down Expand Up @@ -116,7 +114,7 @@

- name: Render frr config
template:
src: frr.conf.j2
src: frr/base.j2
dest: /etc/sonic/frr/frr.conf
when: sonic_frr_render
notify:
Expand Down
192 changes: 0 additions & 192 deletions partition/roles/sonic/templates/frr.conf.j2

This file was deleted.

45 changes: 45 additions & 0 deletions partition/roles/sonic/templates/frr/base.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
frr defaults datacenter
hostname {{ inventory_hostname }}
!
service integrated-vtysh-config
!
log syslog {{ sonic_frr_syslog_level }}
{% if sonic_frr_debug_options is defined %}
{% for option in sonic_frr_debug_options %}
{{ option }}
{% endfor %}
{% endif %}
{% include 'frr/interfaces.j2' %}
{% if sonic_asn and sonic_loopback_address %}
!
{% include 'frr/bgp.j2' %}
{% include 'frr/vrf.j2' %}
{% if sonic_frr_route_map is defined %}
!
route-map {{ sonic_frr_route_map.name }} permit 10
match {{ sonic_frr_route_map.match }}
{% else %}
!
route-map DENY_MGMT deny 10
match interface eth0
route-map DENY_MGMT permit 20
{% endif %}
{% endif %}
{% if sonic_frr_static_routes_mgmt is defined and sonic_frr_static_routes_mgmt|length > 0 %}
!
vrf mgmt
{% for route in sonic_frr_static_routes_mgmt %}
ip route {{ route }}
{% endfor %}
exit-vrf
{% endif %}
{% if sonic_frr_static_routes|length > 0 %}
!
{% for route in sonic_frr_static_routes %}
ip route {{ route }}
{% endfor %}
{% endif %}
!
line vty
!
63 changes: 63 additions & 0 deletions partition/roles/sonic/templates/frr/bgp.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
router bgp {{ sonic_asn }}
bgp router-id {{ sonic_loopback_address }}
bgp bestpath as-path multipath-relax
neighbor FABRIC peer-group
neighbor FABRIC remote-as external
neighbor FABRIC timers 1 3
{% for port in sonic_bgp_ports %}
neighbor {{ port }} interface peer-group FABRIC
{% endfor %}
{% for k, i in sonic_interconnects.items() %}
{% if i.vrf is not defined %}
neighbor {{ i.peer_group | default(sonic_interconnects_default_peer_group) }} peer-group
neighbor {{ i.peer_group | default(sonic_interconnects_default_peer_group) }} remote-as external
neighbor {{ i.peer_group | default(sonic_interconnects_default_peer_group) }} timers {{ i.bgp_timers | default(sonic_interconnects_default_bgp_timers) }}
{% if i.bfd_parameters is defined %}
neighbor {{ i.peer_group }} bfd {{ i.bfd_parameters }}
{% endif %}
{% if i.neighbor_ip is defined %}
neighbor {{ i.neighbor_ip }} peer-group {{ i.peer_group | default(sonic_interconnects_default_peer_group) }}
{% if i.bgp_md5_password is defined %}
neighbor {{ i.neighbor_ip }} password {{ i.bgp_md5_password }}
{% endif %}
{% endif %}
{% for n in i.neighbors|default([]) %}
neighbor {{ n }} peer-group {{ i.peer_group | default(sonic_interconnects_default_peer_group) }}
{% endfor %}
{% for n in i.unnumbered_interfaces|default([]) %}
neighbor {{ n }} interface peer-group {{ i.peer_group | default(sonic_interconnects_default_peer_group) }}
{% endfor %}
{% endif %}
{% endfor %}
!
address-family ipv4 unicast
redistribute connected route-map {{ sonic_frr_route_map.name | default("DENY_MGMT") }}
{% if sonic_frr_static_routes|length > 0 %}
redistribute static
{% endif %}
{% for k, i in sonic_interconnects.items() %}
{% if i.vrf is not defined %}
{% if i.announcements is defined %}
{% for a in i.announcements %}
{{ a }}
{% endfor %}
{% endif %}
{% if i.routemap_in is defined %}
neighbor {{ i.peer_group | default(sonic_interconnects_default_peer_group) }} route-map {{ i.routemap_in.name }} in
{% endif %}
{% if i.routemap_out is defined %}
neighbor {{ i.peer_group | default(sonic_interconnects_default_peer_group) }} route-map {{ i.routemap_out.name }} out
{% endif %}
{% endif %}
{% endfor %}
exit-address-family
{% if sonic_frr_l2vpn_evpn %}
!
address-family l2vpn evpn
{% if sonic_vteps is defined and sonic_vteps|length > 0 %}
advertise-all-vni
{% endif %}
neighbor FABRIC activate
neighbor FABRIC allowas-in 2
exit-address-family
{% endif %}
22 changes: 22 additions & 0 deletions partition/roles/sonic/templates/frr/interfaces.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% for k, i in sonic_interconnects.items() %}
{% if i.vrf is defined %}
!
vrf {{ i.vrf }}
vni {{ i.vni }}
exit-vrf
{% endif %}
{% endfor %}
{% for port in sonic_bgp_ports %}
!
interface {{ port }}
ipv6 nd ra-interval 6
no ipv6 nd suppress-ra
{% endfor %}
{% for k, i in sonic_interconnects.items() %}
{% for n in i.unnumbered_interfaces|default([]) %}
!
interface {{ n }}
ipv6 nd ra-interval 6
no ipv6 nd suppress-ra
{% endfor %}
{% endfor %}
Loading