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

[multi-ASIC] BGP internal neighbor table support #5520

Merged
merged 5 commits into from
Oct 28, 2020
Merged
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
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
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'] }}
!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, should add the lines to add the timer configuration if they are not default.
These configuration
https://github.com/Azure/sonic-buildimage/blob/09d5a62fad22313b29afe1419d329abe45fbef6d/dockers/docker-fpm-frr/frr/bgpd/templates/general/instance.conf.j2#L6-L10

Copy link
Contributor Author

@judyjoseph judyjoseph Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will update. As discussed will raise a follow up PR for adding this change.

{% 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is route-map configuration line repeated? The same line present in the peer_group.conf.j2 configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at both .. they are not same.
Here we set it per neighbor_ip_address, while in the peer_group.conf.j2 it is set on the peer group -- similar to how it was done before as well.

{% 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