From 5239344f9f3b6f62f894de308f407b2a2f6ca139 Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Fri, 22 Nov 2024 07:43:30 +0000 Subject: [PATCH] Add bmp dynamic feature switch in frr side config. --- .../docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 | 13 +++ .../frr/supervisord/supervisord.conf.j2 | 4 + .../tests/sample_output/py2/bgpd_frr_bmp.conf | 89 +++++++++++++++++++ .../tests/sample_output/py3/bgpd_frr_bmp.conf | 89 +++++++++++++++++++ src/sonic-config-engine/tests/test_frr.py | 4 + 5 files changed, 199 insertions(+) create mode 100644 src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_bmp.conf create mode 100644 src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_bmp.conf 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 da6358a00ca6..db11d662a3af 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -88,6 +88,19 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp graceful-restart select-defer-time {{ constants.bgp.graceful_restart.select_defer_time | default(45) }} {% endif %} ! +{# set bmp info #} +{% if (FEATURE is defined) and ('bmp' in FEATURE) and ('state' in FEATURE['bmp']) and (FEATURE['bmp']['state'] == 'enabled') %} +! + bmp mirror buffer-limit 4294967214 +! + bmp targets sonic-bmp + bmp stats interval 1000 + bmp monitor ipv4 unicast pre-policy + bmp monitor ipv6 unicast pre-policy + bmp connect 127.0.0.1 port 5000 min-retry 1000 max-retry 2000 +! +! +{% endif %} {# set router-id #} {% if DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} {% if 'bgp_router_id' in DEVICE_METADATA['localhost'] %} diff --git a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 index 15aa2ed55110..f4baf43aa771 100644 --- a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 +++ b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 @@ -77,7 +77,11 @@ dependent_startup_wait_for=zebra:running {% endif %} [program:bgpd] +{% if FEATURE.bmp is defined and FEATURE.bmp.state is defined and FEATURE.bmp.state == "enabled" %} +command=/usr/lib/frr/bgpd -A 127.0.0.1 -M snmp -M bmp +{% else %} command=/usr/lib/frr/bgpd -A 127.0.0.1 -M snmp +{% endif %} priority=5 stopsignal=KILL autostart=false diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_bmp.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_bmp.conf new file mode 100644 index 000000000000..8a6ceb39e6ba --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_bmp.conf @@ -0,0 +1,89 @@ +! +! 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 + bgp suppress-fib-pending + no bgp default ipv4-unicast + no bgp ebgp-requires-policy +! + 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 +! +! + bmp mirror buffer-limit 4294967214 +! + bmp targets sonic-bmp + bmp stats interval 1000 + bmp monitor ipv4 unicast pre-policy + bmp monitor ipv6 unicast pre-policy + bmp connect 127.0.0.1 port 5000 min-retry 1000 max-retry 2000 +! +! + 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 +! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_bmp.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_bmp.conf new file mode 100644 index 000000000000..8a6ceb39e6ba --- /dev/null +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_bmp.conf @@ -0,0 +1,89 @@ +! +! 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 + bgp suppress-fib-pending + no bgp default ipv4-unicast + no bgp ebgp-requires-policy +! + 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 +! +! + bmp mirror buffer-limit 4294967214 +! + bmp targets sonic-bmp + bmp stats interval 1000 + bmp monitor ipv4 unicast pre-policy + bmp monitor ipv6 unicast pre-policy + bmp connect 127.0.0.1 port 5000 min-retry 1000 max-retry 2000 +! +! + 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 +! diff --git a/src/sonic-config-engine/tests/test_frr.py b/src/sonic-config-engine/tests/test_frr.py index 92deef922752..5a7ca109b30f 100644 --- a/src/sonic-config-engine/tests/test_frr.py +++ b/src/sonic-config-engine/tests/test_frr.py @@ -78,3 +78,7 @@ def test_bgpd_frr_dualtor(self): def test_zebra_frr_dualtor(self): extra_data = {"DEVICE_METADATA": {"localhost": {"subtype": "DualToR"}}} self.assertTrue(*self.run_case('zebra/zebra.conf.j2', 'zebra_frr_dualtor.conf', extra_data=extra_data)) + + def test_bgpd_frr_bmp(self): + extra_data = {"FEATURE": {"bmp": {"state": "enabled"}}} + self.assertTrue(*self.run_case('bgpd/bgpd.conf.j2', 'bgpd_frr_bmp.conf', extra_data=extra_data)) \ No newline at end of file