From 778d1ac58cbd79531c1bf7b56d9c25f77f89cbda Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Fri, 13 Dec 2024 22:59:25 +0000 Subject: [PATCH 01/16] add srv6 yang model and unit tests --- src/sonic-yang-models/doc/Configuration.md | 18 ++++ .../tests/yang_model_tests/tests/srv6.json | 25 ++++++ .../yang_model_tests/tests_config/srv6.json | 89 +++++++++++++++++++ .../yang-models/sonic-srv6.yang | 89 +++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json create mode 100644 src/sonic-yang-models/yang-models/sonic-srv6.yang diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 1f45b32a3e83..2a2e4340462f 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -93,6 +93,7 @@ Table of Contents * [SYSTEM_DEFAULTS table](#systemdefaults-table) * [RADIUS](#radius) * [Static DNS](#static-dns) + * [SRv6](#srv6) * [For Developers](#for-developers) * [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template) * [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb) @@ -2853,6 +2854,23 @@ The DNS_NAMESERVER table introduces static DNS nameservers configuration. } ``` +### SRv6 + +The **SRV6_MY_SID_TABLE** introduces Segment Routing over IPv6 configuration. +An example is as follows: +``` +{ + "SRV6_MY_SID_TABLE" : { + "FCBB:BBBB:20::" : { + "action": "uN" + }, + "FCBB:BBBB:20:F1::" : { + "action": "uDT46" + } + } +} +``` + ### FIPS The FIPS table introduces FIPS configuration. diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json new file mode 100644 index 000000000000..62520fd8f7e0 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -0,0 +1,25 @@ +{ + "SRV6_MY_SID_VALID": { + "desc": "Valid config" + }, + "SRV6_MY_SID_INVALID_IP_ADDR": { + "desc": "SID configured with invalid IPv6 address", + "eStrKey" : "InvalidValue", + "eStr": ["ip_address"] + }, + "SRV6_MY_SID_INVALID_ACTION": { + "desc": "SID configured with invalid action", + "eStrKey" : "InvalidValue", + "eStr": ["action"] + }, + "SRV6_MY_SID_DSCP_MODE_WITH_UN": { + "desc": "SID configured with dscp_mode and uN action", + "eStrKey" : "When", + "eStr": ["action"] + }, + "SRV6_MY_SID_INVALID_FUNC_LEN": { + "desc": "SID configured with invalid func_len", + "eStrKey" : "Must", + "eStr": ["func_len"] + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json new file mode 100644 index 000000000000..028ce0fe5799 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -0,0 +1,89 @@ +{ + "SRV6_MY_SID_VALID": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_SID_TABLE": { + "SRV6_MY_SID_TABLE_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1:", + "action": "uDT46" + }, + { + "ip_address": "FCBB:BBBB:20:F2:", + "action": "uDT6", + "dscp_mode": "pipe" + } + ] + } + } + }, + "SRV6_MY_SID_INVALID_IP_ADDR": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_SID_TABLE": { + "SRV6_MY_SID_TABLE_LIST": [ + { + "ip_address": "FCBB:BBBB:200001::", + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1:", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_SID_INVALID_ACTION": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_SID_TABLE": { + "SRV6_MY_SID_TABLE_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "action": "End.A" + }, + { + "ip_address": "FCBB:BBBB:20:F1:", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_SID_DSCP_MODE_WITH_UN": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_SID_TABLE": { + "SRV6_MY_SID_TABLE_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "action": "uN", + "dscp_mode": "uniform" + }, + { + "ip_address": "FCBB:BBBB:20:F1:", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_SID_INVALID_FUNC_LEN": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_SID_TABLE": { + "SRV6_MY_SID_TABLE_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "func_len": 127, + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1:", + "action": "uDT46" + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang new file mode 100644 index 000000000000..b6845a6b40be --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -0,0 +1,89 @@ +module sonic-srv6 { + revision 2024-12-05 { + description + "Initial revision."; + } + namespace "http://github.com/sonic-net/sonic-srv6"; + yang-version 1.1; + + import ietf-yang-types { + prefix yang; + } + + import ietf-inet-types { + prefix inet; + } + + import sonic-common { + prefix scommon; + } + + container sonic-srv6 { + scommon:db-name "CONFIG_DB"; + + container SRV6_MY_SID_TABLE { + list SRV6_MY_SID_TABLE_LIST { + key "ip_address"; + scommon:key-delim "|"; + scommon:key-pattern "SRV6_MY_SID_TABLE|{ip_address}"; + + leaf ip_address { + type inet:ipv6-address; + } + + leaf block_len { + type uint8 { + range "1..128"; + } + + default 32; + } + + leaf node_len { + type uint8 { + range "1..128"; + } + + default 16; + } + + leaf func_len { + type uint8 { + range "1..128"; + } + + default 16; + } + + leaf arg_len { + type uint8 { + range "1..128"; + } + + default 0; + } + + leaf action { + type enumeration { + enum uN; + enum uDT6; + enum uDT46; + } + } + + leaf dscp_mode { + type enumeration { + enum uniform; + enum pipe; + } + when "../action = uDT6 or ../action = uDT46"; + } + + must 'block_len + node_len + func_len + arg_len <= 128' { + error-message "The sum of all fields' length must be less than or equal to 128"; + } + } + } + + } +} \ No newline at end of file From 9e7c88b8be5af0d15317f9b42970cb95f92259fa Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Mon, 16 Dec 2024 23:10:33 +0000 Subject: [PATCH 02/16] add vrf back to srv6 yang model and fix syntax error --- .../yang-models/sonic-srv6.yang | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index b6845a6b40be..5062090e1e0b 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -1,9 +1,6 @@ module sonic-srv6 { - revision 2024-12-05 { - description - "Initial revision."; - } namespace "http://github.com/sonic-net/sonic-srv6"; + prefix srv6; yang-version 1.1; import ietf-yang-types { @@ -14,18 +11,20 @@ module sonic-srv6 { prefix inet; } - import sonic-common { - prefix scommon; + import sonic-vrf { + prefix vrf; + } + + revision 2024-12-05 { + description + "Initial revision."; } container sonic-srv6 { - scommon:db-name "CONFIG_DB"; container SRV6_MY_SID_TABLE { list SRV6_MY_SID_TABLE_LIST { key "ip_address"; - scommon:key-delim "|"; - scommon:key-pattern "SRV6_MY_SID_TABLE|{ip_address}"; leaf ip_address { type inet:ipv6-address; @@ -57,7 +56,7 @@ module sonic-srv6 { leaf arg_len { type uint8 { - range "1..128"; + range "0..128"; } default 0; @@ -66,17 +65,25 @@ module sonic-srv6 { leaf action { type enumeration { enum uN; - enum uDT6; enum uDT46; } } + leaf vrf { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + description "VRF name"; + + default "default"; + } + leaf dscp_mode { type enumeration { enum uniform; enum pipe; } - when "../action = uDT6 or ../action = uDT46"; + when "../action = 'uDT46'"; } must 'block_len + node_len + func_len + arg_len <= 128' { From 59ff34d678db739c50a75fc872ad443f0d1550f4 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Tue, 17 Dec 2024 20:18:05 +0000 Subject: [PATCH 03/16] add default val for dscp_mode and change vrf to be union type --- src/sonic-yang-models/yang-models/sonic-srv6.yang | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 5062090e1e0b..91a9a31ee855 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -70,8 +70,13 @@ module sonic-srv6 { } leaf vrf { - type leafref { - path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + type union { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + type string { + pattern 'default'; + } } description "VRF name"; @@ -84,6 +89,8 @@ module sonic-srv6 { enum pipe; } when "../action = 'uDT46'"; + + default "uniform"; } must 'block_len + node_len + func_len + arg_len <= 128' { From ac80f3af9f5b35a1ebdb4066cba350fb3e5ac317 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Wed, 18 Dec 2024 00:48:41 +0000 Subject: [PATCH 04/16] fix unintentional invalid ip strings --- .../tests/yang_model_tests/tests_config/srv6.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index 028ce0fe5799..f076e60d1213 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -8,11 +8,11 @@ "action": "uN" }, { - "ip_address": "FCBB:BBBB:20:F1:", + "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" }, { - "ip_address": "FCBB:BBBB:20:F2:", + "ip_address": "FCBB:BBBB:20:F2::", "action": "uDT6", "dscp_mode": "pipe" } @@ -29,7 +29,7 @@ "action": "uN" }, { - "ip_address": "FCBB:BBBB:20:F1:", + "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" } ] @@ -45,7 +45,7 @@ "action": "End.A" }, { - "ip_address": "FCBB:BBBB:20:F1:", + "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" } ] @@ -62,7 +62,7 @@ "dscp_mode": "uniform" }, { - "ip_address": "FCBB:BBBB:20:F1:", + "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" } ] @@ -79,7 +79,7 @@ "action": "uN" }, { - "ip_address": "FCBB:BBBB:20:F1:", + "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" } ] From 84f909364fffbfbabb13de189f6962c108b0e9f5 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Wed, 18 Dec 2024 04:58:03 +0000 Subject: [PATCH 05/16] fix messy UT cases --- .../tests/yang_model_tests/tests/srv6.json | 6 ++---- .../tests/yang_model_tests/tests_config/srv6.json | 5 ----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json index 62520fd8f7e0..a19c18147c59 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -4,8 +4,7 @@ }, "SRV6_MY_SID_INVALID_IP_ADDR": { "desc": "SID configured with invalid IPv6 address", - "eStrKey" : "InvalidValue", - "eStr": ["ip_address"] + "eStrKey" : "Pattern" }, "SRV6_MY_SID_INVALID_ACTION": { "desc": "SID configured with invalid action", @@ -19,7 +18,6 @@ }, "SRV6_MY_SID_INVALID_FUNC_LEN": { "desc": "SID configured with invalid func_len", - "eStrKey" : "Must", - "eStr": ["func_len"] + "eStrKey" : "Must" } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index f076e60d1213..6797af7ff910 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -10,11 +10,6 @@ { "ip_address": "FCBB:BBBB:20:F1::", "action": "uDT46" - }, - { - "ip_address": "FCBB:BBBB:20:F2::", - "action": "uDT6", - "dscp_mode": "pipe" } ] } From 1c8fbbb43d0e93b7666f77e3d414713d15ace9e4 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Wed, 18 Dec 2024 18:51:52 +0000 Subject: [PATCH 06/16] remove unncessary error-message --- src/sonic-yang-models/yang-models/sonic-srv6.yang | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 91a9a31ee855..798ce1775913 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -93,9 +93,7 @@ module sonic-srv6 { default "uniform"; } - must 'block_len + node_len + func_len + arg_len <= 128' { - error-message "The sum of all fields' length must be less than or equal to 128"; - } + must 'block_len + node_len + func_len + arg_len <= 128'; } } From f8ea98f846905eff87bcb0d1999bb8ff438d09b2 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Fri, 27 Dec 2024 00:51:38 +0000 Subject: [PATCH 07/16] Update YANG model to use the new two table schemas and add additional test cases --- .../tests/yang_model_tests/tests/srv6.json | 28 ++- .../yang_model_tests/tests_config/srv6.json | 169 +++++++++++++++--- .../yang-models/sonic-srv6.yang | 47 ++++- 3 files changed, 211 insertions(+), 33 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json index a19c18147c59..e964ab392e93 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -1,23 +1,35 @@ { - "SRV6_MY_SID_VALID": { + "SRV6_VALID": { "desc": "Valid config" }, + "SRV6_MY_LOCATOR_INVALID_FUNC_LEN": { + "desc": "A locator configured with invalid func_len", + "eStrKey" : "Must" + }, + "SRV6_MY_LOCATOR_INVALID_VRF": { + "desc": "A locator configured with an invalid VRF name", + "eStrKey" : "LeafRef" + }, + "SRV6_MY_SID_INVALID_LOCATOR": { + "desc": "A SID configured with invalid locator identifier", + "eStrKey" : "LeafRef" + }, "SRV6_MY_SID_INVALID_IP_ADDR": { - "desc": "SID configured with invalid IPv6 address", + "desc": "A SID configured with invalid IPv6 address", "eStrKey" : "Pattern" }, + "SRV6_MY_SID_UNMATCHED_IP_ADDR": { + "desc": "A SID configured with an IPv6 Address that does not match with the prefix of the locator", + "eStrKey" : "Must" + }, "SRV6_MY_SID_INVALID_ACTION": { - "desc": "SID configured with invalid action", + "desc": "A SID configured with invalid action", "eStrKey" : "InvalidValue", "eStr": ["action"] }, "SRV6_MY_SID_DSCP_MODE_WITH_UN": { - "desc": "SID configured with dscp_mode and uN action", + "desc": "A SID configured with dscp_mode and uN action", "eStrKey" : "When", "eStr": ["action"] - }, - "SRV6_MY_SID_INVALID_FUNC_LEN": { - "desc": "SID configured with invalid func_len", - "eStrKey" : "Must" } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index 6797af7ff910..00ceafe1150c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -1,14 +1,104 @@ { - "SRV6_MY_SID_VALID": { + "SRV6_VALID": { "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_SID_TABLE": { - "SRV6_MY_SID_TABLE_LIST": [ + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "locator": "MAIN", + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_LOCATOR_INVALID_FUNC_LEN": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::", + "func_len": 127 + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ { "ip_address": "FCBB:BBBB:20::", + "locator": "MAIN", "action": "uN" }, { "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_LOCATOR_INVALID_VRF": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::", + "vrf": "Vrf1" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ + { + "ip_address": "FCBB:BBBB:20::", + "locator": "MAIN", + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", + "action": "uDT46" + } + ] + } + } + }, + "SRV6_MY_SID_INVALID_LOCATOR": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ + { + "ip_address": "FCBB:BBBB:21::", + "locator": "None", + "action": "uN" + }, + { + "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", "action": "uDT46" } ] @@ -17,64 +107,103 @@ }, "SRV6_MY_SID_INVALID_IP_ADDR": { "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_SID_TABLE": { - "SRV6_MY_SID_TABLE_LIST": [ + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ { "ip_address": "FCBB:BBBB:200001::", + "locator": "MAIN", "action": "uN" }, { "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", "action": "uDT46" } ] } } }, - "SRV6_MY_SID_INVALID_ACTION": { + "SRV6_MY_SID_UNMATCHED_IP_ADDR": { "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_SID_TABLE": { - "SRV6_MY_SID_TABLE_LIST": [ + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ { - "ip_address": "FCBB:BBBB:20::", - "action": "End.A" + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ + { + "ip_address": "FCBB:BBBB:21::", + "locator": "MAIN", + "action": "uN" }, { "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", "action": "uDT46" } ] } } }, - "SRV6_MY_SID_DSCP_MODE_WITH_UN": { + "SRV6_MY_SID_INVALID_ACTION": { "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_SID_TABLE": { - "SRV6_MY_SID_TABLE_LIST": [ + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ { "ip_address": "FCBB:BBBB:20::", - "action": "uN", - "dscp_mode": "uniform" + "locator": "MAIN", + "action": "uA" }, { "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", "action": "uDT46" } ] } } }, - "SRV6_MY_SID_INVALID_FUNC_LEN": { + "SRV6_MY_SID_DSCP_MODE_WITH_UN": { "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_SID_TABLE": { - "SRV6_MY_SID_TABLE_LIST": [ + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ { "ip_address": "FCBB:BBBB:20::", - "func_len": 127, - "action": "uN" + "locator": "MAIN", + "action": "uN", + "dscp_mode": "uniform" }, { "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", "action": "uDT46" } ] diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 798ce1775913..041e8f4c67bd 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -22,11 +22,15 @@ module sonic-srv6 { container sonic-srv6 { - container SRV6_MY_SID_TABLE { - list SRV6_MY_SID_TABLE_LIST { - key "ip_address"; + container SRV6_MY_LOCATORS { + list SRV6_MY_LOCATORS_LIST { + key "locator_name"; - leaf ip_address { + leaf locator_name { + type string; + } + + leaf prefix { type inet:ipv6-address; } @@ -62,6 +66,38 @@ module sonic-srv6 { default 0; } + must 'block_len + node_len + func_len + arg_len <= 128'; + + leaf vrf { + type union { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + type string { + pattern 'default'; + } + } + description "VRF name"; + + default "default"; + } + } + } + + container SRV6_MY_SIDS { + list SRV6_MY_SIDS_LIST { + key "ip_address"; + + leaf ip_address { + type inet:ipv6-address; + } + + leaf locator { + type leafref { + path "/srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST/srv6:locator_name"; + } + } + leaf action { type enumeration { enum uN; @@ -93,7 +129,8 @@ module sonic-srv6 { default "uniform"; } - must 'block_len + node_len + func_len + arg_len <= 128'; + must "starts-with(./ip_address, + /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[./locator]/srv6:prefix)"; } } From c27a49b23eec54053a7977a7d41ae1979a85cfb8 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Fri, 27 Dec 2024 03:11:44 +0000 Subject: [PATCH 08/16] fix mismatched field name --- .../yang_model_tests/tests_config/srv6.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index 00ceafe1150c..3ab192e4feda 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -4,7 +4,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] @@ -30,7 +30,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::", "func_len": 127 } @@ -57,7 +57,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::", "vrf": "Vrf1" } @@ -84,7 +84,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] @@ -110,7 +110,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] @@ -136,7 +136,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] @@ -162,7 +162,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] @@ -188,7 +188,7 @@ "sonic-srv6:SRV6_MY_LOCATORS": { "SRV6_MY_LOCATORS_LIST": [ { - "name": "MAIN", + "locator_name": "MAIN", "prefix": "FCBB:BBBB:20::" } ] From 7e498e142543edddd714664fd6270c24ef85e2a8 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Fri, 27 Dec 2024 06:31:51 +0000 Subject: [PATCH 09/16] fix broken test case and fix broken must condition --- src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json | 3 ++- src/sonic-yang-models/yang-models/sonic-srv6.yang | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json index e964ab392e93..d65d1c1cb7f3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -8,7 +8,8 @@ }, "SRV6_MY_LOCATOR_INVALID_VRF": { "desc": "A locator configured with an invalid VRF name", - "eStrKey" : "LeafRef" + "eStrKey" : "InvalidValue", + "eStr": ["vrf"] }, "SRV6_MY_SID_INVALID_LOCATOR": { "desc": "A SID configured with invalid locator identifier", diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 041e8f4c67bd..e173bfed4d0d 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -130,7 +130,7 @@ module sonic-srv6 { } must "starts-with(./ip_address, - /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[./locator]/srv6:prefix)"; + /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[current()/srv6:locator]/srv6:prefix)"; } } From 32157bb9f07f444bc388a338c1bf91b1ac067fbf Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Fri, 27 Dec 2024 18:52:28 +0000 Subject: [PATCH 10/16] check the impact of ordering must condition --- .../tests/yang_model_tests/tests_config/srv6.json | 2 +- src/sonic-yang-models/yang-models/sonic-srv6.yang | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index 3ab192e4feda..faaf30e60115 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -92,7 +92,7 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "ip_address": "FCBB:BBBB:21::", + "ip_address": "FCBB:BBBB:20::", "locator": "None", "action": "uN" }, diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index e173bfed4d0d..611df1fcb015 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -88,6 +88,9 @@ module sonic-srv6 { list SRV6_MY_SIDS_LIST { key "ip_address"; + must "starts-with(./ip_address, + /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[current()/srv6:locator]/srv6:prefix)"; + leaf ip_address { type inet:ipv6-address; } @@ -129,8 +132,6 @@ module sonic-srv6 { default "uniform"; } - must "starts-with(./ip_address, - /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[current()/srv6:locator]/srv6:prefix)"; } } From 7c811a6b79a3f38cd4d4db7415e9760828d9615e Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Sat, 28 Dec 2024 00:23:55 +0000 Subject: [PATCH 11/16] adjust the XPath expression for prefix matching --- src/sonic-yang-models/yang-models/sonic-srv6.yang | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 611df1fcb015..3012ee5e1dae 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -88,9 +88,6 @@ module sonic-srv6 { list SRV6_MY_SIDS_LIST { key "ip_address"; - must "starts-with(./ip_address, - /srv6:sonic-srv6/srv6:SRV6_MY_LOCATORS/srv6:SRV6_MY_LOCATORS_LIST[current()/srv6:locator]/srv6:prefix)"; - leaf ip_address { type inet:ipv6-address; } @@ -132,6 +129,8 @@ module sonic-srv6 { default "uniform"; } + must 'starts-with(./ip_address, + substring-before(/srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))'; } } From a2d2c50135a37a86118669e97b848b0ca384696c Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Thu, 2 Jan 2025 22:49:22 +0000 Subject: [PATCH 12/16] update the YANG model to use the vrf as key for SRV6_MY_SIDS table --- .../tests/yang_model_tests/tests/srv6.json | 4 ++ .../yang_model_tests/tests_config/srv6.json | 53 +++++++++++++++++++ .../yang-models/sonic-srv6.yang | 19 +++++-- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json index d65d1c1cb7f3..cd3aeeb312eb 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -23,6 +23,10 @@ "desc": "A SID configured with an IPv6 Address that does not match with the prefix of the locator", "eStrKey" : "Must" }, + "SRV6_MY_SID_UNMATCHED_VRF": { + "desc": "A SID configured with a VRF that does not match with the VRF of the locator", + "eStrKey" : "Must" + }, "SRV6_MY_SID_INVALID_ACTION": { "desc": "A SID configured with invalid action", "eStrKey" : "InvalidValue", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index faaf30e60115..2623a729ce1e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -12,11 +12,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -39,11 +41,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -66,11 +70,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -92,11 +98,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "None", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -118,11 +126,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:200001::", "locator": "MAIN", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -144,11 +154,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:21::", "locator": "MAIN", "action": "uN" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -157,6 +169,43 @@ } } }, + "SRV6_MY_SID_UNMATCHED_VRF": { + "sonic-srv6:sonic-srv6": { + "sonic-srv6:SRV6_MY_LOCATORS": { + "SRV6_MY_LOCATORS_LIST": [ + { + "locator_name": "MAIN", + "prefix": "FCBB:BBBB:20::" + } + ] + }, + "sonic-srv6:SRV6_MY_SIDS": { + "SRV6_MY_SIDS_LIST": [ + { + "vrf": "Vrf1", + "ip_address": "FCBB:BBBB:20::", + "locator": "MAIN", + "action": "uN" + }, + { + "vrf": "default", + "ip_address": "FCBB:BBBB:20:F1::", + "locator": "MAIN", + "action": "uDT46" + } + ] + } + }, + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "name":"Vrf1" + } + ] + } + } + }, "SRV6_MY_SID_INVALID_ACTION": { "sonic-srv6:sonic-srv6": { "sonic-srv6:SRV6_MY_LOCATORS": { @@ -170,11 +219,13 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uA" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -196,12 +247,14 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { + "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN", "dscp_mode": "uniform" }, { + "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 3012ee5e1dae..d1ab73e98628 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -86,7 +86,19 @@ module sonic-srv6 { container SRV6_MY_SIDS { list SRV6_MY_SIDS_LIST { - key "ip_address"; + key "vrf ip_address"; + + leaf vrf { + type union { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + type string { + pattern 'default'; + } + } + description "VRF name"; + } leaf ip_address { type inet:ipv6-address; @@ -105,7 +117,7 @@ module sonic-srv6 { } } - leaf vrf { + leaf decap_vrf { type union { type leafref { path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; @@ -114,7 +126,7 @@ module sonic-srv6 { pattern 'default'; } } - description "VRF name"; + description "VRF name used for decapsulation"; default "default"; } @@ -131,6 +143,7 @@ module sonic-srv6 { must 'starts-with(./ip_address, substring-before(/srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))'; + must './vrf = /srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/vrf'; } } From 7fe7f6a60ce3fc4e52835ee9fcff2d474ac0468e Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Sat, 4 Jan 2025 00:18:07 +0000 Subject: [PATCH 13/16] replace vrf with locator in the key combo of SRV6_MY_SIDS --- .../tests/yang_model_tests/tests/srv6.json | 4 -- .../yang_model_tests/tests_config/srv6.json | 53 ------------------- .../yang-models/sonic-srv6.yang | 15 +----- 3 files changed, 1 insertion(+), 71 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json index cd3aeeb312eb..d65d1c1cb7f3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json @@ -23,10 +23,6 @@ "desc": "A SID configured with an IPv6 Address that does not match with the prefix of the locator", "eStrKey" : "Must" }, - "SRV6_MY_SID_UNMATCHED_VRF": { - "desc": "A SID configured with a VRF that does not match with the VRF of the locator", - "eStrKey" : "Must" - }, "SRV6_MY_SID_INVALID_ACTION": { "desc": "A SID configured with invalid action", "eStrKey" : "InvalidValue", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index 2623a729ce1e..faaf30e60115 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -12,13 +12,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -41,13 +39,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -70,13 +66,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -98,13 +92,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "None", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -126,13 +118,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:200001::", "locator": "MAIN", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -154,13 +144,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:21::", "locator": "MAIN", "action": "uN" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -169,43 +157,6 @@ } } }, - "SRV6_MY_SID_UNMATCHED_VRF": { - "sonic-srv6:sonic-srv6": { - "sonic-srv6:SRV6_MY_LOCATORS": { - "SRV6_MY_LOCATORS_LIST": [ - { - "locator_name": "MAIN", - "prefix": "FCBB:BBBB:20::" - } - ] - }, - "sonic-srv6:SRV6_MY_SIDS": { - "SRV6_MY_SIDS_LIST": [ - { - "vrf": "Vrf1", - "ip_address": "FCBB:BBBB:20::", - "locator": "MAIN", - "action": "uN" - }, - { - "vrf": "default", - "ip_address": "FCBB:BBBB:20:F1::", - "locator": "MAIN", - "action": "uDT46" - } - ] - } - }, - "sonic-vrf:sonic-vrf":{ - "sonic-vrf:VRF": { - "VRF_LIST": [ - { - "name":"Vrf1" - } - ] - } - } - }, "SRV6_MY_SID_INVALID_ACTION": { "sonic-srv6:sonic-srv6": { "sonic-srv6:SRV6_MY_LOCATORS": { @@ -219,13 +170,11 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uA" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" @@ -247,14 +196,12 @@ "sonic-srv6:SRV6_MY_SIDS": { "SRV6_MY_SIDS_LIST": [ { - "vrf": "default", "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN", "dscp_mode": "uniform" }, { - "vrf": "default", "ip_address": "FCBB:BBBB:20:F1::", "locator": "MAIN", "action": "uDT46" diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index d1ab73e98628..1877deebe8da 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -86,19 +86,7 @@ module sonic-srv6 { container SRV6_MY_SIDS { list SRV6_MY_SIDS_LIST { - key "vrf ip_address"; - - leaf vrf { - type union { - type leafref { - path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; - } - type string { - pattern 'default'; - } - } - description "VRF name"; - } + key "locator ip_address"; leaf ip_address { type inet:ipv6-address; @@ -143,7 +131,6 @@ module sonic-srv6 { must 'starts-with(./ip_address, substring-before(/srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))'; - must './vrf = /srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/vrf'; } } From e9b505d52323a452eddad4481c509b5603fcfd3a Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Mon, 6 Jan 2025 23:41:14 +0000 Subject: [PATCH 14/16] update srv6 yang model to stay consistent with HLD --- src/sonic-yang-models/yang-models/sonic-srv6.yang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-srv6.yang b/src/sonic-yang-models/yang-models/sonic-srv6.yang index 1877deebe8da..2ef9c3ac6df4 100644 --- a/src/sonic-yang-models/yang-models/sonic-srv6.yang +++ b/src/sonic-yang-models/yang-models/sonic-srv6.yang @@ -32,6 +32,7 @@ module sonic-srv6 { leaf prefix { type inet:ipv6-address; + mandatory true; } leaf block_len { @@ -119,7 +120,7 @@ module sonic-srv6 { default "default"; } - leaf dscp_mode { + leaf decap_dscp_mode { type enumeration { enum uniform; enum pipe; From 3e1f62cea693e91eb3e2b63e654cb9fbb06da193 Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Tue, 7 Jan 2025 01:10:39 +0000 Subject: [PATCH 15/16] fix unmatched field name in test_config/srv6 .json --- .../tests/yang_model_tests/tests_config/srv6.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json index faaf30e60115..5185d41007ca 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json @@ -199,7 +199,7 @@ "ip_address": "FCBB:BBBB:20::", "locator": "MAIN", "action": "uN", - "dscp_mode": "uniform" + "decap_dscp_mode": "uniform" }, { "ip_address": "FCBB:BBBB:20:F1::", From df7cd2715a5ae5bba5694884ccb5475dca2ed49a Mon Sep 17 00:00:00 2001 From: BYGX-wcr Date: Wed, 8 Jan 2025 11:07:05 -0800 Subject: [PATCH 16/16] sonic-yang-models: update the srv6 example in configuration.md --- src/sonic-yang-models/doc/Configuration.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index a484e11136e2..0a721774e3c4 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -2888,16 +2888,23 @@ The DNS_NAMESERVER table introduces static DNS nameservers configuration. ### SRv6 -The **SRV6_MY_SID_TABLE** introduces Segment Routing over IPv6 configuration. +The **SRV6_MY_SIDS** and **SRV6_MY_LOCATORS** tables introduce Segment Routing over IPv6 configuration. An example is as follows: ``` { - "SRV6_MY_SID_TABLE" : { - "FCBB:BBBB:20::" : { + "SRV6_MY_LOCATORS" : { + "loc1" : { + "prefix" : "FCBB:BBBB:20::" + } + } + "SRV6_MY_SIDS" : { + "loc1|FCBB:BBBB:20::" : { "action": "uN" }, - "FCBB:BBBB:20:F1::" : { - "action": "uDT46" + "loc1|FCBB:BBBB:20:F1::" : { + "action": "uDT46", + "decap_vrf": "default", + "decap_dscp_mode": "pipe" } } }