Skip to content
Open
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
25 changes: 24 additions & 1 deletion partition/roles/sonic-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ sonic_config_frr_syslog_level: informational
sonic_config_interconnects:
# The name is only a reference within the deployment. It will not be reflected on the switch.
interconnect-name:
# BGP announcements to the connecting parties.
# BGP announcements to the connecting parties. Ipv4 addressfamily only.
announcements:
- network 10.1.2.0/24

# BGP announcements to the connecting parties for the Ipv6 addressfamily.
announcements_ipv6family:
- redistribute connected

# BFD configuration to apply to this connection.
# An empty string is a valid parameter and will tell FRR to listen for BFD events
# from this neighbor.
Expand All @@ -300,11 +304,22 @@ sonic_config_interconnects:
# Use specific BGP timer values for the BGP session with the remote party.
bgp_timers: 1 3

# Whether to disable default membership of peers in the ipv4 unicast addressfamily.
# To control addressfamily memberships in dual-stack scenarios.
# Only valid for external interconnects (that is, with vrf).
# You need to explicitly set the addressfamily of each peer if you use this!
no_default_ipv4family: true

# Connect to these BGP neighbors - supports multiple neighbors with individual routemaps.
# Only valid for external interconnects (that is, with vrf).
extended_neighbors:
# The IP of this extended neighbor.
- ip: 10.1.1.1

# Choose the addressfamily membership of this neighbor. v4 or v6.
families:
- v4

# Apply an incoming routemap to this neighbor.
routemap_in:
# Name of the routemap.
Expand Down Expand Up @@ -354,6 +369,10 @@ sonic_config_interconnects:
# Name of the routemap.
name: ALLOW-STATIC-IN

# Addressfamily / families to apply this routemap to. Default: ipv4 unicast
families:
- ipv4

# List of routemap entries.
entries:
- match ip address prefix-list STATIC_PREFIX_IN
Expand All @@ -363,6 +382,10 @@ sonic_config_interconnects:
# Name of the routemap.
name: ALLOW-MPLS-OUT

# Addressfamily / families to apply this routemap to. Default: ipv4 unicast
families:
- ipv4

# List of routemap entries.
entries:
- "match ip address prefix-list MPLS_PREFIX_OUT"
Expand Down
45 changes: 45 additions & 0 deletions partition/roles/sonic-config/templates/frr.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ router bgp {{ sonic_config_asn }}
router bgp {{ sonic_config_asn }} vrf {{ i.vrf }}
bgp router-id {{ sonic_config_loopback_address }}
bgp bestpath as-path multipath-relax
{% if i.no_default_ipv4family is defined and i.no_default_ipv4family %}
no bgp default ipv4-unicast
{% endif %}
neighbor {{ i.peer_group | default("EXTERNAL") }} peer-group
neighbor {{ i.peer_group | default("EXTERNAL") }} remote-as {{ i.remote_as | default("external") }}
neighbor {{ i.peer_group | default("EXTERNAL") }} timers {{ i.bgp_timers | default("1 3") }}
Expand Down Expand Up @@ -157,25 +160,67 @@ router bgp {{ sonic_config_asn }} vrf {{ i.vrf }}
neighbor {{ i.peer_group | default("EXTERNAL") }} remove-private-AS all
{% endif %}
{% if i.routemap_in is defined %}
{% if i.routemap_in.families is not defined or "v4" in i.routemap_in.families %}
neighbor {{ i.peer_group | default("EXTERNAL") }} route-map {{ i.routemap_in.name }} in
{% endif %}
{% endif %}
{% if i.routemap_out is defined %}
{% if i.routemap_out.families is not defined or "v4" in i.routemap_out.families %}
neighbor {{ i.peer_group | default("EXTERNAL") }} route-map {{ i.routemap_out.name }} out
{% endif %}
{% endif %}
{% if i.extended_neighbors is defined %}
{% for ext in i.extended_neighbors %}
{% if i.no_default_ipv4family is not defined or not i.no_default_ipv4family or ext.families is defined and "v4" in ext.families %}
{% if i.no_default_ipv4family is defined and i.no_default_ipv4family %}
neighbor {{ ext.ip }} activate
{% endif %}
{% if ext.routemap_in is defined %}
neighbor {{ ext.ip }} route-map {{ ext.routemap_in.name }} in
{% endif %}
{% if ext.routemap_out is defined %}
neighbor {{ ext.ip }} route-map {{ ext.routemap_out.name }} out
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
exit-address-family
!
address-family ipv6 unicast
{% for a in i.announcements_ipv6family|default([]) %}
{{ a }}
{% endfor %}
{% if not i.keep_private_as|default(false) %}
neighbor {{ i.peer_group | default("EXTERNAL") }} remove-private-AS all
{% endif %}
{% if i.routemap_in is defined %}
{% if i.routemap_in.families is defined and "v6" in i.routemap_in.families %}
neighbor {{ i.peer_group | default("EXTERNAL") }} route-map {{ i.routemap_in.name }} in
{% endif %}
{% endif %}
{% if i.routemap_out is defined %}
{% if i.routemap_out.families is defined and "v6" in i.routemap_out.families %}
neighbor {{ i.peer_group | default("EXTERNAL") }} route-map {{ i.routemap_out.name }} out
{% endif %}
{% endif %}
{% if i.extended_neighbors is defined %}
{% for ext in i.extended_neighbors %}
{% if ext.families is defined and "v6" in ext.families %}
neighbor {{ ext.ip }} activate
{% if ext.routemap_in is defined %}
neighbor {{ ext.ip }} route-map {{ ext.routemap_in.name }} in
{% endif %}
{% if ext.routemap_out is defined %}
neighbor {{ ext.ip }} route-map {{ ext.routemap_out.name }} out
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
{% endif %}
Expand Down
32 changes: 32 additions & 0 deletions partition/roles/sonic-config/test/data/exit/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,46 @@ router bgp 4200000000 vrf VrfMpls
neighbor MPLS route-map ALLOW-MPLS-OUT out
exit-address-family
!
address-family ipv6 unicast
neighbor MPLS remove-private-AS all
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
router bgp 4200000000 vrf VrfInternet
bgp router-id 10.0.0.1
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
neighbor INTERNET peer-group
neighbor INTERNET remote-as external
neighbor INTERNET timers 1 3
neighbor 172.17.146.177 peer-group INTERNET
neighbor 172.17.146.161 peer-group INTERNET
neighbor 2a02:c00:ff0:102::1 peer-group INTERNET
!
address-family ipv4 unicast
neighbor INTERNET remove-private-AS all
neighbor 172.17.146.177 activate
neighbor 172.17.146.177 route-map ALLOW-INTERNET-2-IN in
neighbor 172.17.146.177 route-map ALLOW-INTERNET-2-OUT out
neighbor 172.17.146.161 activate
neighbor 172.17.146.161 route-map ALLOW-INTERNET-4-IN in
neighbor 172.17.146.161 route-map ALLOW-INTERNET-4-OUT out
exit-address-family
!
address-family ipv6 unicast
neighbor INTERNET remove-private-AS all
neighbor 2a02:c00:ff0:102::1 activate
neighbor 2a02:c00:ff0:102::1 route-map ALLOW-V6INTERNET-2-IN in
neighbor 2a02:c00:ff0:102::1 route-map ALLOW-V6INTERNET-2-OUT out
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
router bgp 4200000000 vrf Vrf1560
Expand All @@ -127,8 +144,13 @@ router bgp 4200000000 vrf Vrf1560
neighbor EXTERNAL remove-private-AS all
exit-address-family
!
address-family ipv6 unicast
neighbor EXTERNAL remove-private-AS all
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
ip prefix-list MPLS_PREFIX_IN seq 10 permit 10.0.0.0/8
Expand All @@ -144,6 +166,8 @@ ip prefix-list INTERNET_PREFIX_IN seq 10 permit 0.0.0.0/0
ip prefix-list INTERNET_PREFIX_OUT seq 10 permit 185.153.67.0/24 ge 32
ip prefix-list INTERNET_PREFIX_OUT seq 11 permit 212.34.85.0/24 ge 32
ip prefix-list INTERNET_PREFIX_OUT seq 12 permit 212.34.89.0/24 ge 32
ipv6 prefix-list V6INTERNET_PREFIX_IN seq 10 permit ::0/0
ipv6 prefix-list V6INTERNET_PREFIX_OUT seq 10 permit 2a02:c00:2f:ff00::/56 ge 128
!
route-map ALLOW-INTERNET-2-IN permit 10
match ip address prefix-list INTERNET_PREFIX_IN
Expand All @@ -161,6 +185,14 @@ route-map ALLOW-INTERNET-4-OUT permit 20
match ip address prefix-list INTERNET_PREFIX_OUT
set as-path prepend 4200000000 4200000000 4200000000 4200000000
!
route-map ALLOW-V6INTERNET-2-IN permit 10
match ipv6 address prefix-list V6INTERNET_PREFIX_IN
set as-path prepend last-as 2
!
route-map ALLOW-V6INTERNET-2-OUT permit 20
match ipv6 address prefix-list V6INTERNET_PREFIX_OUT
set as-path prepend 4200000000 4200000000
!
ip prefix-list Vrf1560-IN seq 10 permit 10.0.0.0/16
!
route-map IMPORT-INTO-Vrf1560 permit 10
Expand Down
21 changes: 21 additions & 0 deletions partition/roles/sonic-config/test/data/exit/input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,19 @@ sonic_config_interconnects:
vrf: VrfInternet
vlan: 4009
vni: 104009
no_default_ipv4family: true
announcements: []
prefixlists:
- "ip prefix-list INTERNET_PREFIX_IN seq 10 permit 0.0.0.0/0"
- "ip prefix-list INTERNET_PREFIX_OUT seq 10 permit 185.153.67.0/24 ge 32"
- "ip prefix-list INTERNET_PREFIX_OUT seq 11 permit 212.34.85.0/24 ge 32"
- "ip prefix-list INTERNET_PREFIX_OUT seq 12 permit 212.34.89.0/24 ge 32"
- "ipv6 prefix-list V6INTERNET_PREFIX_IN seq 10 permit ::0/0"
- "ipv6 prefix-list V6INTERNET_PREFIX_OUT seq 10 permit 2a02:c00:2f:ff00::/56 ge 128"
extended_neighbors:
- ip: "172.17.146.177"
families:
- v4
routemap_in:
name: "ALLOW-INTERNET-2-IN"
entries:
Expand All @@ -69,6 +74,8 @@ sonic_config_interconnects:
- "match ip address prefix-list INTERNET_PREFIX_OUT"
- "set as-path prepend {{ sonic_config_asn }} {{ sonic_config_asn }}"
- ip: "172.17.146.161"
families:
- v4
routemap_in:
name: "ALLOW-INTERNET-4-IN"
entries:
Expand All @@ -79,6 +86,20 @@ sonic_config_interconnects:
entries:
- "match ip address prefix-list INTERNET_PREFIX_OUT"
- "set as-path prepend {{ sonic_config_asn }} {{ sonic_config_asn }} {{ sonic_config_asn }} {{ sonic_config_asn }}"
- ip: "2a02:c00:ff0:102::1"
families:
- v6
routemap_in:
name: "ALLOW-V6INTERNET-2-IN"
entries:
- "match ipv6 address prefix-list V6INTERNET_PREFIX_IN"
- "set as-path prepend last-as 2"
routemap_out:
name: "ALLOW-V6INTERNET-2-OUT"
entries:
- "match ipv6 address prefix-list V6INTERNET_PREFIX_OUT"
- "set as-path prepend {{ sonic_config_asn }} {{ sonic_config_asn }}"

croit:
vrf: Vrf1560
vni: 1560
Expand Down
13 changes: 13 additions & 0 deletions partition/roles/sonic-config/test/data/leaf/frr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ router bgp 4200000000 vrf Vrf46
neighbor EXTERNAL remove-private-AS all
exit-address-family
!
address-family ipv6 unicast
neighbor EXTERNAL remove-private-AS all
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
router bgp 4200000000 vrf Vrf64
Expand All @@ -100,8 +105,12 @@ router bgp 4200000000 vrf Vrf64
neighbor STATIC route-map ALLOW-STATIC-IN in
exit-address-family
!
address-family ipv6 unicast
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
router bgp 4200000000 vrf Vrf65
Expand All @@ -119,8 +128,12 @@ router bgp 4200000000 vrf Vrf65
neighbor STATICN route-map ALLOW-STATICN-IN in
exit-address-family
!
address-family ipv6 unicast
exit-address-family
!
address-family l2vpn evpn
advertise ipv4 unicast
advertise ipv6 unicast
exit-address-family
!
ip prefix-list STATIC_PREFIX_IN seq 10 permit 10.64.64.0/22 ge 32
Expand Down
Loading