From e44392a302d0c06e9fc9556bba5f9acda83983df Mon Sep 17 00:00:00 2001 From: Tapash Das Date: Thu, 9 Feb 2023 01:01:28 -0800 Subject: [PATCH 1/3] Added vni field in VRF Yang for VxLAN L3 VNI Support #13456 --- src/sonic-yang-models/yang-models/sonic-vrf.yang | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-vrf.yang b/src/sonic-yang-models/yang-models/sonic-vrf.yang index ff9fc5b5a4cc..069685144e8d 100644 --- a/src/sonic-yang-models/yang-models/sonic-vrf.yang +++ b/src/sonic-yang-models/yang-models/sonic-vrf.yang @@ -43,6 +43,17 @@ module sonic-vrf { "Enable/disable fallback feature which is useful for specified VRF user to access internet through global/main route."; } + leaf vni { + type uint32 { + range "0..16777215" { + error-message "VNI ID out of range"; + error-app-tag vnid-invalid; + } + } + default 0; + description + "VNI mapped to VRF"; + } } /* end of list VRF_LISt */ } /* end of container VRf */ } /* end of container sonic-vrf */ From 74e911d9ea5af4ddf95036a69b14a00c0919a6e8 Mon Sep 17 00:00:00 2001 From: Tapash Das Date: Mon, 20 Feb 2023 23:12:05 -0800 Subject: [PATCH 2/3] Added Test Case --- src/sonic-yang-models/doc/Configuration.md | 4 +++- .../tests/files/sample_config_db.json | 1 + .../tests/yang_model_tests/tests/vrf.json | 3 +++ .../tests/yang_model_tests/tests_config/vrf.json | 11 +++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 6fd6bbd1125c..7674790c1959 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -1882,6 +1882,7 @@ table allow to change properties of a virtual router. Attributes: packets with IP options - 'l3_mc_action' contains packet action. Defines the action for unknown L3 multicast packets +- 'vni' contains L3 VNI value. VNI associated Virtual router instance. The packet action could be: @@ -1903,7 +1904,8 @@ The packet action could be: 'src_mac': '02:04:05:06:07:08', 'ttl_action': 'copy', 'ip_opt_action': 'deny', - 'l3_mc_action': 'drop' + 'l3_mc_action': 'drop', + 'vni': '100' } ``` 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 f9945175cf48..4a7f5b7ba3d4 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2,6 +2,7 @@ "SAMPLE_CONFIG_DB_JSON": { "VRF": { "Vrf_blue": { + "vni" : "100" } }, "DHCP_SERVER": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json index a9d9bb0f9d9c..daeede36df2a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json @@ -8,5 +8,8 @@ }, "VRF_TEST_WITH_FALLBACK": { "desc": "Configure VRF with fallback in VRF table." + }, + "VRF_TEST_WITH_VNI": { + "desc": "Configure VRF with VNI in VRF table." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json index f34d3fbdd52d..89b1804caeb6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json @@ -28,5 +28,16 @@ }] } } + }, + + "VRF_TEST_WITH_VNI": { + "sonic-vrf:sonic-vrf": { + "sonic-vrf:VRF": { + "VRF_LIST": [{ + "name": "Vrf_blue", + "vni": "100" + }] + } + } } } From d6cac8cb845020db8d1999224607c9c6107462e2 Mon Sep 17 00:00:00 2001 From: Tapash Das Date: Tue, 21 Feb 2023 22:24:38 -0800 Subject: [PATCH 3/3] Added Out of Range Test Case --- .../tests/yang_model_tests/tests/vrf.json | 4 ++++ .../tests/yang_model_tests/tests_config/vrf.json | 11 +++++++++++ src/sonic-yang-models/yang-models/sonic-vrf.yang | 5 +---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json index daeede36df2a..73e31ee109cc 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vrf.json @@ -11,5 +11,9 @@ }, "VRF_TEST_WITH_VNI": { "desc": "Configure VRF with VNI in VRF table." + }, + "VRF_TEST_WITH_VNI_OOR": { + "desc": "Configure VRF with out of range VNI in VRF table.", + "eStrKey": "Range" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json index 89b1804caeb6..082ec022f81b 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vrf.json @@ -39,5 +39,16 @@ }] } } + }, + + "VRF_TEST_WITH_VNI_OOR": { + "sonic-vrf:sonic-vrf": { + "sonic-vrf:VRF": { + "VRF_LIST": [{ + "name": "Vrf_blue", + "vni": "16777216" + }] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-vrf.yang b/src/sonic-yang-models/yang-models/sonic-vrf.yang index 069685144e8d..5387aad2cc80 100644 --- a/src/sonic-yang-models/yang-models/sonic-vrf.yang +++ b/src/sonic-yang-models/yang-models/sonic-vrf.yang @@ -45,10 +45,7 @@ module sonic-vrf { leaf vni { type uint32 { - range "0..16777215" { - error-message "VNI ID out of range"; - error-app-tag vnid-invalid; - } + range "0..16777215"; } default 0; description