From 6c0da4bcf09666b99df879834dc0d662b129daea Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Mon, 13 Dec 2021 10:14:50 -0800 Subject: [PATCH] [bgp] Enable BGP Graceful Restart based on device role (#9486) What I did: Updated Jinja Template to enable BGP Graceful Restart based on device role. By default it will be enable only if the device role type is TorRouter. Why I did:- By default FRR is configured in Graceful Helper mode. Graceful Restart is needed on T0/TorRouter only since the device can go for warm-reboot. For T1/LeafRouter it need to be in Helper mode only --- dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 | 2 +- .../tests/data/sonic-cfggen/bgpd.conf.j2/all.json | 3 ++- .../tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json | 3 ++- .../tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json | 3 ++- .../data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf | 4 ---- .../data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json | 3 ++- .../data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf | 4 ---- .../data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json | 3 ++- .../tests/data/sonic-cfggen/frr.conf.j2/all.json | 3 ++- .../tests/sample_output/py2/bgpd_frr_backend_asic.conf | 4 ---- .../tests/sample_output/py2/bgpd_frr_frontend_asic.conf | 4 ---- .../tests/sample_output/py2/t2-chassis-fe-bgpd.conf | 4 ---- .../tests/sample_output/py3/bgpd_frr_backend_asic.conf | 4 ---- .../tests/sample_output/py3/bgpd_frr_frontend_asic.conf | 4 ---- .../tests/sample_output/py3/t2-chassis-fe-bgpd.conf | 4 ---- 15 files changed, 13 insertions(+), 39 deletions(-) diff --git a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 index c1616c043f..c6643f1857 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -67,7 +67,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp bestpath as-path multipath-relax {% endif %} ! -{% if constants.bgp.graceful_restart.enabled is defined and constants.bgp.graceful_restart.enabled %} +{% if constants.bgp.graceful_restart.enabled is defined and constants.bgp.graceful_restart.enabled and DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} bgp graceful-restart restart-time {{ constants.bgp.graceful_restart.restart_time | default(240) }} bgp graceful-restart bgp graceful-restart preserve-fw-state diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json index 34fdbe7244..fc5016d853 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json @@ -3,7 +3,8 @@ "localhost": { "hostname": "new_hostname", "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json index c8f0141ec4..47508bb3c0 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json @@ -2,7 +2,8 @@ "DEVICE_METADATA": { "localhost": { "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json index 5b30406668..c1b5ae8dc4 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json @@ -2,7 +2,8 @@ "DEVICE_METADATA": { "localhost": { "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf index 2852ce1502..37ac8827dc 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf @@ -39,10 +39,6 @@ router bgp 55555 ! 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 55.55.55.56 ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json index 418a62266d..41fc9351be 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "sub_role": "FrontEnd", - "switch_type": "chassis-packet" + "switch_type": "chassis-packet", + "type": "SpineRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf index 26f06d843a..d8ee10ada1 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf @@ -39,10 +39,6 @@ router bgp 55555 ! 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 55.55.55.56 ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json index 4cbb4c0048..00c913981a 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "sub_role": "", - "switch_type": "voq" + "switch_type": "voq", + "type": "SpineRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json index 92143a2a9d..9c8a34fb41 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "hostname": "test_hostname", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "INTERFACE": { diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf index 0def8a6be3..d793dfa39a 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! 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 8.0.0.5 ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf index ecdb3818ff..94bd37e3b9 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! 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 ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf b/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf index d3b9b472c5..20744efaa4 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf @@ -63,10 +63,6 @@ router bgp 4000 ! 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 4.0.0.0 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf index 0def8a6be3..d793dfa39a 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! 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 8.0.0.5 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf index ecdb3818ff..94bd37e3b9 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! 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 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf b/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf index d3b9b472c5..20744efaa4 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf @@ -63,10 +63,6 @@ router bgp 4000 ! 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 4.0.0.0 !