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

Add templates and code to support VoQ chassis iBGP peers #5622

Merged
merged 6 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -0,0 +1,35 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor {{ neighbor_addr }} peer-group VOQ_CHASSIS_PEER
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'] | default("60") }} {{ bgp_session['holdtime'] | default("180") }}
{% endif %}
!
jmmikkel marked this conversation as resolved.
Show resolved Hide resolved
{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and CONFIG_DB__DEVICE_METADATA['localhost'].has_key('default_bgp_status') and CONFIG_DB__DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %}
neighbor {{ neighbor_addr }} shutdown
{% endif %}
!
address-family ipv4
{% if constants.bgp.maximum_paths.enabled is defined and constants.bgp.maximum_paths.enabled %}
maximum-paths ibgp {{ constants.bgp.maximum_paths.ipv4 | default(64) }}
{% endif %}
!
exit-address-family
!
address-family ipv6
{% if constants.bgp.maximum_paths.enabled is defined and constants.bgp.maximum_paths.enabled %}
maximum-paths ibgp {{ constants.bgp.maximum_paths.ipv6 | default(64) }}
{% endif %}
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
!
! template: bgpd/templates/voq_chassis/peer-group.conf.j2
!
neighbor VOQ_CHASSIS_PEER peer-group
address-family ipv4
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
neighbor VOQ_CHASSIS_PEER allowas-in 1
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
neighbor VOQ_CHASSIS_PEER activate
neighbor VOQ_CHASSIS_PEER addpath-tx-all-paths
neighbor VOQ_CHASSIS_PEER soft-reconfiguration inbound
exit-address-family
address-family ipv6
{% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
arlakshm marked this conversation as resolved.
Show resolved Hide resolved
neighbor VOQ_CHASSIS_PEER allowas-in 1
{% endif %}
neighbor VOQ_CHASSIS_PEER activate
neighbor VOQ_CHASSIS_PEER addpath-tx-all-paths
neighbor VOQ_CHASSIS_PEER soft-reconfiguration inbound
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!
! template: bgpd/templates/voq_chassis/policies.conf.j2
!
!
!
! end of template: bgpd/templates/voq_chassis/policies.conf.j2
!
4 changes: 4 additions & 0 deletions files/image_config/constants/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ constants:
db_table: "BGP_PEER_RANGE"
peer_group: "BGP_SPEAKER"
template_dir: "dynamic"
voq_chassis: # peer_type
enabled: true
db_table: "BGP_VOQ_CHASSIS_NEIGHBOR"
template_dir: "voq_chassis"
1 change: 1 addition & 0 deletions src/sonic-bgpcfgd/bgpcfgd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def do_work():
BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True),
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_MONITORS", "monitors", False),
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_PEER_RANGE", "dynamic", False),
BGPPeerMgrBase(common_objs, "CONFIG_DB", "BGP_VOQ_CHASSIS_NEIGHBOR", "voq_chassis", False, require_intf_in_config_db=False),
# AllowList Managers
BGPAllowListMgr(common_objs, "CONFIG_DB", "BGP_ALLOWED_PREFIXES"),
]
Expand Down
8 changes: 7 additions & 1 deletion src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ def update_entity(self, cmd, txt):

class BGPPeerMgrBase(Manager):
""" Manager of BGP peers """
def __init__(self, common_objs, db_name, table_name, peer_type, check_neig_meta):
def __init__(self, common_objs, db_name, table_name, peer_type, check_neig_meta, require_intf_in_config_db=True):
"""
Initialize the object
:param common_objs: common objects
:param table_name: name of the table with peers
:param peer_type: type of the peers. It is used to find right templates
:param require_intf_in_config_db: when True, an interface with the local address is required in CONFIG_DB before a peer is added to bgpd. Set it to False when an interface is not required in CONFIG_DB, such as for VoQ chassis internal peers
"""
self.common_objs = common_objs
self.constants = self.common_objs["constants"]
self.fabric = common_objs['tf']
self.peer_type = peer_type
self.require_intf_in_config_db = require_intf_in_config_db

base_template = "bgpd/templates/" + self.constants["bgp"]["peers"][peer_type]["template_dir"] + "/"
self.templates = {
Expand Down Expand Up @@ -170,6 +172,10 @@ def add_peer(self, vrf, nbr, data):
#
if "local_addr" not in data:
log_warn("Peer %s. Missing attribute 'local_addr'" % nbr)
elif not self.require_intf_in_config_db:
jmmikkel marked this conversation as resolved.
Show resolved Hide resolved
# This is the usual case for VoQ chassis peers, which will not
# have the local vlan interface in CONFIG_DB.
pass
else:
# The bgp session that belongs to a vnet cannot be advertised as the default BGP session.
# So we need to check whether this bgp session belongs to a vnet.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"sub_role": "BackEnd"
jmmikkel marked this conversation as resolved.
Show resolved Hide resolved
}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1",
"keepalive": "5",
"holdtime": "30",
"admin_status": "down"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true",
"ipv4": "32",
"ipv6": "24"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"default_bgp_status": "down"
}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"default_bgp_status": "up"
}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1",
"keepalive": "5"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {}
},
"neighbor_addr": "10.10.10.10",
"bgp_session": {
"asn": "555",
"name": "internal1",
"holdtime": "240"
},
"constants": {
"bgp": {
"maximum_paths": {
"enabled": "true"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
neighbor 10.10.10.10 timers 5 30
neighbor 10.10.10.10 shutdown
address-family ipv4
maximum-paths ibgp 32
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 24
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
address-family ipv4
maximum-paths ibgp 64
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 64
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
neighbor 10.10.10.10 shutdown
address-family ipv4
maximum-paths ibgp 64
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 64
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
address-family ipv4
maximum-paths ibgp 64
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 64
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
neighbor 10.10.10.10 timers 5 180
address-family ipv4
maximum-paths ibgp 64
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 64
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!
! template: bgpd/templates/voq_chassis/instance.conf.j2
!
bgp bestpath as-path multipath-relax
bgp bestpath peer-type multipath-relax
!
neighbor 10.10.10.10 peer-group VOQ_CHASSIS_PEER
neighbor 10.10.10.10 remote-as 555
neighbor 10.10.10.10 description internal1
neighbor 10.10.10.10 timers 60 240
address-family ipv4
maximum-paths ibgp 64
!
exit-address-family
!
address-family ipv6
maximum-paths ibgp 64
!
exit-address-family
!
! end of template: bgpd/templates/voq_chassis/instance.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {
"type": "ToRRouter"
jmmikkel marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"CONFIG_DB__DEVICE_METADATA": {
"localhost": {}
}
}
Loading