Skip to content

Commit

Permalink
[multi-ASIC] BGP internal neighbor table support (#5520)
Browse files Browse the repository at this point in the history
* Initial commit for BGP internal neighbor table support.
  > Add new template named "internal" for the internal BGP sessions
  > Add a new table in database "BGP_INTERNAL_NEIGHBOR"
  > The internal BGP sessions will be stored in this new table "BGP_INTERNAL_NEIGHBOR"

* Changes in template generation tests with the introduction of internal neighbor template files.
  • Loading branch information
judyjoseph authored Oct 28, 2020
1 parent 09d5a62 commit 6088bd5
Show file tree
Hide file tree
Showing 40 changed files with 404 additions and 173 deletions.
19 changes: 0 additions & 19 deletions dockers/docker-fpm-frr/frr/bgpd/templates/general/instance.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,12 @@
!
{% if neighbor_addr | ipv4 %}
address-family ipv4
{% if 'ASIC' in bgp_session['name'] %}
neighbor {{ neighbor_addr }} peer-group PEER_V4_INT
{% else %}
neighbor {{ neighbor_addr }} peer-group PEER_V4
{% endif %}
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V4_INT in
{% endif %}
!
{% elif neighbor_addr | ipv6 %}
address-family ipv6
{% if 'ASIC' in bgp_session['name'] %}
neighbor {{ neighbor_addr }} peer-group PEER_V6_INT
{% else %}
neighbor {{ neighbor_addr }} peer-group PEER_V6
{% endif %}
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} route-map FROM_BGP_PEER_V6_INT in
{% endif %}
{% endif %}
!
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
Expand All @@ -45,10 +30,6 @@
{% if bgp_session.has_key('nhopself') and bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
{% endif %}
!
{% if 'ASIC' in bgp_session['name'] %}
neighbor {{ neighbor_addr }} next-hop-self force
{% endif %}
!
neighbor {{ neighbor_addr }} activate
exit-address-family
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,30 @@
! template: bgpd/templates/general/peer-group.conf.j2
!
neighbor PEER_V4 peer-group
neighbor PEER_V4_INT peer-group
neighbor PEER_V6 peer-group
neighbor PEER_V6_INT peer-group
address-family ipv4
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
neighbor PEER_V4 allowas-in 1
neighbor PEER_V4_INT allowas-in 1
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
neighbor PEER_V4 allowas-in 1
{% endif %}
{% endif %}
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor PEER_V4_INT route-reflector-client
{% endif %}
neighbor PEER_V4 soft-reconfiguration inbound
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
neighbor PEER_V4_INT soft-reconfiguration inbound
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
exit-address-family
address-family ipv6
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
neighbor PEER_V6 allowas-in 1
neighbor PEER_V6_INT allowas-in 1
{% elif CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'LeafRouter' %}
{% if CONFIG_DB__BGP_BBR['status'] == 'enabled' %}
neighbor PEER_V6 allowas-in 1
{% endif %}
{% endif %}
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor PEER_V6_INT route-reflector-client
{% endif %}
neighbor PEER_V6 soft-reconfiguration inbound
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
neighbor PEER_V6_INT soft-reconfiguration inbound
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/general/peer-group.conf.j2
Expand Down
11 changes: 0 additions & 11 deletions dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,5 @@ route-map FROM_BGP_PEER_V6 permit 100
!
route-map TO_BGP_PEER_V6 permit 100
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
route-map FROM_BGP_PEER_V4_INT permit 2
set originator-id {{ loopback0_ipv4 | ip }}
!
route-map FROM_BGP_PEER_V6_INT permit 1
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6_INT permit 2
set originator-id {{ loopback0_ipv4 | ip }}
{% endif %}
!
! end of template: bgpd/templates/general/policies.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
!
! template: bgpd/templates/internal/instance.conf.j2
!
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
!
{% if neighbor_addr | ipv4 %}
address-family ipv4
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V4
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V4 in
{% endif %}
!
{% elif neighbor_addr | ipv6 %}
address-family ipv6
neighbor {{ neighbor_addr }} peer-group INTERNAL_PEER_V6
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor {{ neighbor_addr }} route-map FROM_BGP_INTERNAL_PEER_V6 in
{% endif %}
{% endif %}
!
{% if bgp_session.has_key('rrclient') and bgp_session['rrclient'] | int != 0 %}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
!
neighbor {{ neighbor_addr }} next-hop-self force
!
neighbor {{ neighbor_addr }} activate
exit-address-family
!
! end of template: bgpd/templates/internal/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
!
! template: bgpd/templates/internal/peer-group.conf.j2
!
neighbor INTERNAL_PEER_V4 peer-group
neighbor INTERNAL_PEER_V6 peer-group
address-family ipv4
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor INTERNAL_PEER_V4 route-reflector-client
{% endif %}
neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound
neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in
neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out
exit-address-family
address-family ipv6
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
neighbor INTERNAL_PEER_V6 route-reflector-client
{% endif %}
neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound
neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in
neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/internal/peer-group.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
!
! template: bgpd/templates/internal/policies.conf.j2
!
!
!
route-map FROM_BGP_INTERNAL_PEER_V4 permit 100
!
route-map TO_BGP_INTERNAL_PEER_V4 permit 100
!
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 1
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 100
!
route-map TO_BGP_INTERNAL_PEER_V6 permit 100
!
{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %}
route-map FROM_BGP_INTERNAL_PEER_V4 permit 2
set originator-id {{ loopback0_ipv4 | ip }}
!
route-map FROM_BGP_INTERNAL_PEER_V6 permit 2
set originator-id {{ loopback0_ipv4 | ip }}
{% endif %}
!
! end of template: bgpd/templates/internal/policies.conf.j2
!
3 changes: 3 additions & 0 deletions files/image_config/constants/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ constants:
- ipv4
PEER_V6:
- ipv6
internal: # peer_type
db_table: "BGP_INTERNAL_NEIGHBOR"
template_dir: "internal"
monitors: # peer_type
enabled: true
db_table: "BGP_MONITORS"
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-bgpcfgd/bgpcfgd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def do_work():
ZebraSetSrc(common_objs, "STATE_DB", swsscommon.STATE_INTERFACE_TABLE_NAME),
# Peer Managers
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True),
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_INTERNAL_NEIGHBOR_TABLE_NAME, "internal", False),
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_MONITORS", "monitors", False),
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_PEER_RANGE", "dynamic", False),
# AllowList Managers
Expand Down Expand Up @@ -81,4 +82,4 @@ def main():
try:
sys.exit(rc)
except SystemExit:
os._exit(rc)
os._exit(rc)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "BackEnd"
}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "BackEnd"
}
},
"neighbor_addr": "fc::10",
"bgp_session": {
"asn": "555",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
neighbor 10.10.10.10 shutdown
address-family ipv4
neighbor 10.10.10.10 peer-group PEER_V4
neighbor 10.10.10.10 route-map FROM_BGP_PEER_V4_INT in
neighbor 10.10.10.10 route-reflector-client
neighbor 10.10.10.10 next-hop-self
neighbor 10.10.10.10 activate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
neighbor fc::10 shutdown
address-family ipv6
neighbor fc::10 peer-group PEER_V6
neighbor fc::10 route-map FROM_BGP_PEER_V6_INT in
neighbor fc::10 route-reflector-client
neighbor fc::10 next-hop-self
neighbor fc::10 activate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"type": "LeafRouter",
"sub_role": "BackEnd"
"type": "LeafRouter"
}
},
"CONFIG_DB__BGP_BBR": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@
! template: bgpd/templates/general/peer-group.conf.j2
!
neighbor PEER_V4 peer-group
neighbor PEER_V4_INT peer-group
neighbor PEER_V6 peer-group
neighbor PEER_V6_INT peer-group
address-family ipv4
neighbor PEER_V4 allowas-in 1
neighbor PEER_V4_INT allowas-in 1
neighbor PEER_V4 soft-reconfiguration inbound
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
neighbor PEER_V4_INT soft-reconfiguration inbound
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
exit-address-family
address-family ipv6
neighbor PEER_V6 allowas-in 1
neighbor PEER_V6_INT allowas-in 1
neighbor PEER_V6 soft-reconfiguration inbound
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
neighbor PEER_V6_INT soft-reconfiguration inbound
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/general/peer-group.conf.j2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@
! template: bgpd/templates/general/peer-group.conf.j2
!
neighbor PEER_V4 peer-group
neighbor PEER_V4_INT peer-group
neighbor PEER_V6 peer-group
neighbor PEER_V6_INT peer-group
address-family ipv4
neighbor PEER_V4_INT route-reflector-client
neighbor PEER_V4 soft-reconfiguration inbound
neighbor PEER_V4 route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
neighbor PEER_V4_INT soft-reconfiguration inbound
neighbor PEER_V4_INT route-map FROM_BGP_PEER_V4 in
neighbor PEER_V4_INT route-map TO_BGP_PEER_V4 out
exit-address-family
address-family ipv6
neighbor PEER_V6_INT route-reflector-client
neighbor PEER_V6 soft-reconfiguration inbound
neighbor PEER_V6 route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
neighbor PEER_V6_INT soft-reconfiguration inbound
neighbor PEER_V6_INT route-map FROM_BGP_PEER_V6 in
neighbor PEER_V6_INT route-map TO_BGP_PEER_V6 out
exit-address-family
!
! end of template: bgpd/templates/general/peer-group.conf.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "BackEnd"
}
},
"loopback0_ipv4": "10.10.10.10/32",
"constants": {
"bgp": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "NotBackEnd"
}
},
"loopback0_ipv4": "10.10.10.10/32",
"constants": {
"bgp": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "BackEnd"
}
},
"loopback0_ipv4": "10.10.10.10/32",
"constants": {
"bgp": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,5 @@ route-map FROM_BGP_PEER_V6 permit 100
!
route-map TO_BGP_PEER_V6 permit 100
!
route-map FROM_BGP_PEER_V4_INT permit 2
set originator-id 10.10.10.10
!
route-map FROM_BGP_PEER_V6_INT permit 1
set ipv6 next-hop prefer-global
!
route-map FROM_BGP_PEER_V6_INT permit 2
set originator-id 10.10.10.10
!
! end of template: bgpd/templates/general/policies.conf.j2
!
Loading

0 comments on commit 6088bd5

Please sign in to comment.