From 54a1ad10f95f15eac5434b4579e7dfb169acbff9 Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Mon, 12 Jun 2023 21:59:34 -0700 Subject: [PATCH] [yang] Change asn to start from 0 for bgp monitor (#15350) #### Why I did it The asn 0 in BGP_MONITOR is invalid by YANG definition. However, the asn 0 in BGP_MONITOR is found in many devices. It was introduced by minigraph where its value is set to 0. To unblock Config Updater test, the short term fix is to accept the asn 0 in BGP_MONITOR. We can revert this after NGS team make all the ASN change in minigraph. ##### Work item tracking - Microsoft ADO **(24186140)**: #### How I did it Change the range #### How to verify it Unit test. --- src/sonic-yang-models/tests/files/sample_config_db.json | 2 +- src/sonic-yang-models/yang-models/sonic-bgp-common.yang | 2 +- .../yang-models/sonic-bgp-internal-neighbor.yang | 3 +++ src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang | 8 +++++++- .../yang-models/sonic-bgp-voq-chassis-neighbor.yang | 3 +++ 5 files changed, 15 insertions(+), 3 deletions(-) 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 059da13fb7..9d4c291cb0 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1598,7 +1598,7 @@ "BGP_MONITORS": { "5.6.7.8": { "admin_status": "up", - "asn": "65000", + "asn": "0", "holdtime": "180", "keepalive": "60", "local_addr": "10.0.0.11", diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 9e3d1638b2..e035c1be26 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -534,7 +534,7 @@ module sonic-bgp-common { grouping sonic-bgp-cmn-neigh { leaf asn { type uint32 { - range "1..4294967295"; + range "0..4294967295"; } description "Peer AS number"; } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang index a58f404cb6..163a6aaed3 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang @@ -43,6 +43,9 @@ module sonic-bgp-internal-neighbor { must "(current() = /dm:sonic-device_metadata/dm:DEVICE_METADATA/dm:localhost/dm:bgp_asn)" { error-message "Internal iBGP neighbors should have same ASN as defined in device metadata"; } + must ". >= 1" { + error-message "ASN must be greater than 0"; + } } refine local_addr { mandatory true; diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index a48b422863..c8ce6ec4ad 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -61,7 +61,13 @@ module sonic-bgp-neighbor { description "BGP Neighbor address"; } - uses bgpcmn:sonic-bgp-cmn-neigh; + uses bgpcmn:sonic-bgp-cmn-neigh { + refine asn { + must ". >= 1" { + error-message "ASN must be greater than 0"; + } + } + } } list BGP_NEIGHBOR_LIST { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang index ad4d227ee0..db7088ecc3 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang @@ -45,6 +45,9 @@ module sonic-bgp-voq-chassis-neighbor { must "(current() = /dm:sonic-device_metadata/dm:DEVICE_METADATA/dm:localhost/dm:bgp_asn)" { error-message "Voq chassis BGP neighbors should have same ASN as defined in device metadata"; } + must ". >= 1" { + error-message "ASN must be greater than 0"; + } } refine local_addr { mandatory true;