Skip to content

Commit

Permalink
[dualtor] Let T0 delay 10 seconds before sending BGP updates (#13701)
Browse files Browse the repository at this point in the history
Cherry-pick PR #12996 into 202012 branch.

Signed-off-by: Longxiang Lyu <[email protected]>
  • Loading branch information
lolyu authored Feb 8, 2023
1 parent abbcda6 commit 6b4a278
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 4 deletions.
3 changes: 3 additions & 0 deletions dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
bgp log-neighbor-changes
no bgp default ipv4-unicast
no bgp ebgp-requires-policy
{% if (DEVICE_METADATA is defined) and ('localhost' in DEVICE_METADATA) and ('subtype' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['subtype'].lower() == 'dualtor') %}
coalesce-time 10000
{% endif %}
!
{% if constants.bgp.multipath_relax.enabled is defined and constants.bgp.multipath_relax.enabled %}
bgp bestpath as-path multipath-relax
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
!
! template: bgpd/bgpd.conf.j2
!
!
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 with config DB data
! file: bgpd.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname switch-t0
password zebra
enable password zebra
!
log syslog informational
log facility local4
!
! end of template: common/daemons.common.conf.j2!
agentx
!
!
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
!
! BGP configuration
!
! TSA configuration
!
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.200.0/27
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.0.0/27
!
!
!
router bgp 65100
!
bgp log-neighbor-changes
no bgp default ipv4-unicast
no bgp ebgp-requires-policy
coalesce-time 10000
!
bgp bestpath as-path multipath-relax
!
bgp graceful-restart restart-time 240
bgp graceful-restart
bgp graceful-restart preserve-fw-state
bgp graceful-restart select-defer-time 45
!
bgp router-id 10.1.0.32
!
network 10.1.0.32/32
!
address-family ipv6
network fc00:1::32/64
exit-address-family
!
network 192.168.200.1/27
network 192.168.0.1/27
!
!
!
address-family ipv4
maximum-paths 64
exit-address-family
address-family ipv6
maximum-paths 64
exit-address-family
!
! end of template: bgpd/bgpd.main.conf.j2
!!
! end of template: bgpd/bgpd.conf.j2
!
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
!
! template: bgpd/bgpd.conf.j2
!
!
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 with config DB data
! file: bgpd.conf
!
!
! template: common/daemons.common.conf.j2
!
hostname switch-t0
password zebra
enable password zebra
!
log syslog informational
log facility local4
!
! end of template: common/daemons.common.conf.j2!
agentx
!
!
!
! template: bgpd/bgpd.main.conf.j2
!
! bgp multiple-instance
!
! BGP configuration
!
! TSA configuration
!
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
!
ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27
!
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.200.0/27
!
!
!
router bgp 65100
!
bgp log-neighbor-changes
no bgp default ipv4-unicast
no bgp ebgp-requires-policy
coalesce-time 10000
!
bgp bestpath as-path multipath-relax
!
bgp graceful-restart restart-time 240
bgp graceful-restart
bgp graceful-restart preserve-fw-state
bgp graceful-restart select-defer-time 45
!
bgp router-id 10.1.0.32
!
network 10.1.0.32/32
!
address-family ipv6
network fc00:1::32/64
exit-address-family
!
network 192.168.0.1/27
network 192.168.200.1/27
!
!
!
address-family ipv4
maximum-paths 64
exit-address-family
address-family ipv6
maximum-paths 64
exit-address-family
!
! end of template: bgpd/bgpd.main.conf.j2
!!
! end of template: bgpd/bgpd.conf.j2
!
15 changes: 11 additions & 4 deletions src/sonic-config-engine/tests/test_frr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import filecmp
import json
import os
import subprocess

Expand Down Expand Up @@ -46,12 +47,16 @@ def run_diff(self, file1, file2):

return output

def run_case(self, template, target):
def run_case(self, template, target, extra_data=None):
template_dir = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', "frr")
conf_template = os.path.join(template_dir, template)
constants = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'constants', 'constants.yml')
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, self.output_file
cmd = "-m %s -p %s -y %s -t %s -T %s > %s" % cmd_args
if extra_data:
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, json.dumps(extra_data), self.output_file
cmd = "-m %s -p %s -y %s -t %s -T %s -a '%s' > %s" % cmd_args
else:
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, self.output_file
cmd = "-m %s -p %s -y %s -t %s -T %s > %s" % cmd_args
self.run_script(cmd)

original_filename = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, target)
Expand All @@ -69,4 +74,6 @@ def test_bgpd_frr(self):
def test_zebra_frr(self):
self.assertTrue(*self.run_case('zebra/zebra.conf.j2', 'zebra_frr.conf'))


def test_bgpd_frr_dualtor(self):
extra_data = {"DEVICE_METADATA": {"localhost": {"subtype": "DualToR"}}}
self.assertTrue(*self.run_case('bgpd/bgpd.conf.j2', 'bgpd_frr_dualtor.conf', extra_data=extra_data))

0 comments on commit 6b4a278

Please sign in to comment.