From 96099c732282dfd95f0689f58890731d68a8f4c4 Mon Sep 17 00:00:00 2001 From: Tejaswini Chadaga Date: Thu, 14 Mar 2024 21:05:07 +0000 Subject: [PATCH 1/4] Merged PR 9686034: Yang model changes for Sequential IDF isolation --- files/build_templates/init_cfg.json.j2 | 3 +- src/sonic-yang-models/doc/Configuration.md | 12 +++-- .../tests/files/sample_config_db.json | 3 +- .../tests/bgp_device_global.json | 18 ++++++- .../tests_config/bgp_device_global.json | 54 +++++++++++++++++-- .../yang-models/sonic-bgp-device-global.yang | 16 +++++- 6 files changed, 91 insertions(+), 15 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 9c02de602076..92ebfe4de94e 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -30,7 +30,8 @@ }, "BGP_DEVICE_GLOBAL": { "STATE": { - "tsa_enabled": "false" + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" } }, {%- set features = [("bgp", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}disabled{% else %}enabled{% endif %}", false, "enabled"), diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 886277d26f7c..d0c42ee32b46 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -384,16 +384,18 @@ The **BGP_BBR** table contains device-level BBR state. ``` ### BGP Device Global -The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. -It has a STATE object containing device state like **tsa_enabled** -which is set to true if device is currently isolated using -traffic-shift-away (TSA) route-maps in BGP +The **BGP_DEVICE_GLOBAL** table contains device-level BGP global state. +It has a STATE object containing device state like **tsa_enabled** +which is set to true if device is currently isolated using +traffic-shift-away (TSA) route-maps in BGP. It also holds IDF isolation state +which could be one of isolated_no_export, isolated_withdraw_all or unisolated ``` { "BGP_DEVICE_GLOBAL": { "STATE": { - "tsa_enabled": "true" + "tsa_enabled": "true", + "idf_isolation_state": "isolated_no_export" } } ``` diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 050f4433bac6..bcbebad0bc12 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1675,7 +1675,8 @@ }, "BGP_DEVICE_GLOBAL": { "STATE": { - "tsa_enabled": "false" + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" } }, "BGP_PEER_RANGE": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json index 233f23f3d62a..3c3a8559b3e6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_device_global.json @@ -8,9 +8,23 @@ "BGP_DEVICE_GLOBAL_WITH_TSB_TEST": { "desc": "Load bgp device global table with tsa_enabled set to false" }, - "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE": { + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_1": { + "desc": "Load bgp device global table with idf_isolation_state set to isolated_no_export" + }, + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_2": { + "desc": "Load bgp device global table with idf_isolation_state set to isolated_withdraw_all" + }, + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_3": { + "desc": "Load bgp device global table with idf_isolation_state set to unisolated" + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE_1": { "desc": "Load bgp device global table with invalid value", "eStrKey": "InvalidValue", "eStr": ["tsa_enabled"] + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE_2": { + "desc": "Load bgp device global table with invalid value", + "eStrKey": "InvalidValue", + "eStr": ["idf_isolation_state"] } -} +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json index f96de59df390..b9bb4fe007c0 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_device_global.json @@ -3,7 +3,8 @@ "sonic-bgp-device-global:sonic-bgp-device-global": { "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { "STATE":{ - "tsa_enabled": "false" + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" } } } @@ -12,7 +13,8 @@ "sonic-bgp-device-global:sonic-bgp-device-global": { "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { "STATE":{ - "tsa_enabled": "true" + "tsa_enabled": "true", + "idf_isolation_state": "unisolated" } } } @@ -21,16 +23,58 @@ "sonic-bgp-device-global:sonic-bgp-device-global": { "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { "STATE":{ - "tsa_enabled": "false" + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" } } } }, - "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE": { + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_1": { "sonic-bgp-device-global:sonic-bgp-device-global": { "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { "STATE":{ - "tsa_enabled": "FALSE" + "tsa_enabled": "true", + "idf_isolation_state": "isolated_no_export" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_2": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "false", + "idf_isolation_state": "isolated_withdraw_all" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_IDF_ISOLATION_TEST_3": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE_1": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "FALSE", + "idf_isolation_state": "unisolated" + } + } + } + }, + "BGP_DEVICE_GLOBAL_WITH_INVALID_VALUE_2": { + "sonic-bgp-device-global:sonic-bgp-device-global": { + "sonic-bgp-device-global:BGP_DEVICE_GLOBAL": { + "STATE":{ + "tsa_enabled": "false", + "idf_isolation_state": "isolated" } } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang index 277be6870922..1a2cd777cb9b 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang @@ -21,12 +21,26 @@ module sonic-bgp-device-global { container BGP_DEVICE_GLOBAL { container STATE { description "BGP device-specific global data"; - leaf tsa_enabled { + leaf tsa_enabled { type boolean; default "false"; description "When set to true, Traffic is shifted away (TSA), i.e, BGP routes are not advertised to neighboring routers"; } + leaf idf_isolation_state { + type enumeration { + enum isolated_no_export { + description "IDF isolated using no-export community tag"; + } + enum isolated_withdraw_all { + description "IDF isolated by withdrawing routes"; + } + enum unisolated { + description "IDF un-isolated"; + } + } + default unisolated; + } } /* end of STATE container */ } /* end of BGP_DEVICE_GLOBAL container */ From 66d2358376db0efedd65302d789c50fca892dbbf Mon Sep 17 00:00:00 2001 From: tjchadaga <85581939+tjchadaga@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:36:02 -0700 Subject: [PATCH 2/4] Add T2 check for idf_isolation_state init --- files/build_templates/init_cfg.json.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 92ebfe4de94e..bac16081d727 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -30,8 +30,8 @@ }, "BGP_DEVICE_GLOBAL": { "STATE": { - "tsa_enabled": "false", - "idf_isolation_state": "unisolated" + "tsa_enabled": "false" +{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' %} ,"idf_isolation_state": "unisolated"{% endif %} } }, {%- set features = [("bgp", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}disabled{% else %}enabled{% endif %}", false, "enabled"), From 7f9c7aea609c88f283fe1c8345ba7511b1ea513b Mon Sep 17 00:00:00 2001 From: tjchadaga <85581939+tjchadaga@users.noreply.github.com> Date: Wed, 17 Apr 2024 11:04:23 -0700 Subject: [PATCH 3/4] Remove spinerouter check --- files/build_templates/init_cfg.json.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index bac16081d727..92ebfe4de94e 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -30,8 +30,8 @@ }, "BGP_DEVICE_GLOBAL": { "STATE": { - "tsa_enabled": "false" -{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' %} ,"idf_isolation_state": "unisolated"{% endif %} + "tsa_enabled": "false", + "idf_isolation_state": "unisolated" } }, {%- set features = [("bgp", "{% if not DEVICE_RUNTIME_METADATA['ETHERNET_PORTS_PRESENT'] or ('CHASSIS_METADATA' in DEVICE_RUNTIME_METADATA and DEVICE_RUNTIME_METADATA['CHASSIS_METADATA']['module_type'] in ['supervisor']) %}disabled{% else %}enabled{% endif %}", false, "enabled"), From 15481e58bb52f1e95927f21f25accc1f151afc24 Mon Sep 17 00:00:00 2001 From: tjchadaga <85581939+tjchadaga@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:53:48 -0700 Subject: [PATCH 4/4] Remove additional white spaces --- .../yang-models/sonic-bgp-device-global.yang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang index 1a2cd777cb9b..07e763735f8f 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-device-global.yang @@ -21,13 +21,13 @@ module sonic-bgp-device-global { container BGP_DEVICE_GLOBAL { container STATE { description "BGP device-specific global data"; - leaf tsa_enabled { + leaf tsa_enabled { type boolean; default "false"; description "When set to true, Traffic is shifted away (TSA), i.e, BGP routes are not advertised to neighboring routers"; } - leaf idf_isolation_state { + leaf idf_isolation_state { type enumeration { enum isolated_no_export { description "IDF isolated using no-export community tag";