Skip to content

Commit 6b4a278

Browse files
authored
[dualtor] Let T0 delay 10 seconds before sending BGP updates (#13701)
Cherry-pick PR #12996 into 202012 branch. Signed-off-by: Longxiang Lyu <[email protected]>
1 parent abbcda6 commit 6b4a278

File tree

4 files changed

+172
-4
lines changed

4 files changed

+172
-4
lines changed

dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
4848
bgp log-neighbor-changes
4949
no bgp default ipv4-unicast
5050
no bgp ebgp-requires-policy
51+
{% if (DEVICE_METADATA is defined) and ('localhost' in DEVICE_METADATA) and ('subtype' in DEVICE_METADATA['localhost']) and (DEVICE_METADATA['localhost']['subtype'].lower() == 'dualtor') %}
52+
coalesce-time 10000
53+
{% endif %}
5154
!
5255
{% if constants.bgp.multipath_relax.enabled is defined and constants.bgp.multipath_relax.enabled %}
5356
bgp bestpath as-path multipath-relax
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
!
2+
! template: bgpd/bgpd.conf.j2
3+
!
4+
!
5+
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
6+
! generated by templates/quagga/bgpd.conf.j2 with config DB data
7+
! file: bgpd.conf
8+
!
9+
!
10+
! template: common/daemons.common.conf.j2
11+
!
12+
hostname switch-t0
13+
password zebra
14+
enable password zebra
15+
!
16+
log syslog informational
17+
log facility local4
18+
!
19+
! end of template: common/daemons.common.conf.j2!
20+
agentx
21+
!
22+
!
23+
!
24+
! template: bgpd/bgpd.main.conf.j2
25+
!
26+
! bgp multiple-instance
27+
!
28+
! BGP configuration
29+
!
30+
! TSA configuration
31+
!
32+
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
33+
!
34+
ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64
35+
!
36+
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.200.0/27
37+
!
38+
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.0.0/27
39+
!
40+
!
41+
!
42+
router bgp 65100
43+
!
44+
bgp log-neighbor-changes
45+
no bgp default ipv4-unicast
46+
no bgp ebgp-requires-policy
47+
coalesce-time 10000
48+
!
49+
bgp bestpath as-path multipath-relax
50+
!
51+
bgp graceful-restart restart-time 240
52+
bgp graceful-restart
53+
bgp graceful-restart preserve-fw-state
54+
bgp graceful-restart select-defer-time 45
55+
!
56+
bgp router-id 10.1.0.32
57+
!
58+
network 10.1.0.32/32
59+
!
60+
address-family ipv6
61+
network fc00:1::32/64
62+
exit-address-family
63+
!
64+
network 192.168.200.1/27
65+
network 192.168.0.1/27
66+
!
67+
!
68+
!
69+
address-family ipv4
70+
maximum-paths 64
71+
exit-address-family
72+
address-family ipv6
73+
maximum-paths 64
74+
exit-address-family
75+
!
76+
! end of template: bgpd/bgpd.main.conf.j2
77+
!!
78+
! end of template: bgpd/bgpd.conf.j2
79+
!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
!
2+
! template: bgpd/bgpd.conf.j2
3+
!
4+
!
5+
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
6+
! generated by templates/quagga/bgpd.conf.j2 with config DB data
7+
! file: bgpd.conf
8+
!
9+
!
10+
! template: common/daemons.common.conf.j2
11+
!
12+
hostname switch-t0
13+
password zebra
14+
enable password zebra
15+
!
16+
log syslog informational
17+
log facility local4
18+
!
19+
! end of template: common/daemons.common.conf.j2!
20+
agentx
21+
!
22+
!
23+
!
24+
! template: bgpd/bgpd.main.conf.j2
25+
!
26+
! bgp multiple-instance
27+
!
28+
! BGP configuration
29+
!
30+
! TSA configuration
31+
!
32+
ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32
33+
!
34+
ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64
35+
!
36+
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27
37+
!
38+
ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.200.0/27
39+
!
40+
!
41+
!
42+
router bgp 65100
43+
!
44+
bgp log-neighbor-changes
45+
no bgp default ipv4-unicast
46+
no bgp ebgp-requires-policy
47+
coalesce-time 10000
48+
!
49+
bgp bestpath as-path multipath-relax
50+
!
51+
bgp graceful-restart restart-time 240
52+
bgp graceful-restart
53+
bgp graceful-restart preserve-fw-state
54+
bgp graceful-restart select-defer-time 45
55+
!
56+
bgp router-id 10.1.0.32
57+
!
58+
network 10.1.0.32/32
59+
!
60+
address-family ipv6
61+
network fc00:1::32/64
62+
exit-address-family
63+
!
64+
network 192.168.0.1/27
65+
network 192.168.200.1/27
66+
!
67+
!
68+
!
69+
address-family ipv4
70+
maximum-paths 64
71+
exit-address-family
72+
address-family ipv6
73+
maximum-paths 64
74+
exit-address-family
75+
!
76+
! end of template: bgpd/bgpd.main.conf.j2
77+
!!
78+
! end of template: bgpd/bgpd.conf.j2
79+
!

src/sonic-config-engine/tests/test_frr.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import filecmp
2+
import json
23
import os
34
import subprocess
45

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

4748
return output
4849

49-
def run_case(self, template, target):
50+
def run_case(self, template, target, extra_data=None):
5051
template_dir = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-fpm-frr', "frr")
5152
conf_template = os.path.join(template_dir, template)
5253
constants = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'constants', 'constants.yml')
53-
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, self.output_file
54-
cmd = "-m %s -p %s -y %s -t %s -T %s > %s" % cmd_args
54+
if extra_data:
55+
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, json.dumps(extra_data), self.output_file
56+
cmd = "-m %s -p %s -y %s -t %s -T %s -a '%s' > %s" % cmd_args
57+
else:
58+
cmd_args = self.t0_minigraph, self.t0_port_config, constants, conf_template, template_dir, self.output_file
59+
cmd = "-m %s -p %s -y %s -t %s -T %s > %s" % cmd_args
5560
self.run_script(cmd)
5661

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

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

0 commit comments

Comments
 (0)