Skip to content

Commit

Permalink
Merge pull request sonic-net#543 from mssonicbld/cherry/msft-202412/2…
Browse files Browse the repository at this point in the history
…1466

[action] [PR:21466] [YANG] SRv6 yang model followup fix
  • Loading branch information
r12f authored Jan 23, 2025
2 parents 0196e0d + b1d6bf9 commit 48aad69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 61 deletions.
9 changes: 2 additions & 7 deletions src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@
"desc": "A SID configured with invalid locator identifier",
"eStrKey" : "LeafRef"
},
"SRV6_MY_SID_INVALID_IP_ADDR": {
"SRV6_MY_SID_INVALID_IP_PREFIX": {
"desc": "A SID configured with invalid IPv6 address",
"eStrKey" : "Pattern"
},
"SRV6_MY_SID_UNMATCHED_IP_ADDR": {
"SRV6_MY_SID_UNMATCHED_IP_PREFIX": {
"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": "A SID configured with invalid action",
"eStrKey" : "InvalidValue",
"eStr": ["action"]
},
"SRV6_MY_SID_DSCP_MODE_WITH_UN": {
"desc": "A SID configured with dscp_mode and uN action",
"eStrKey" : "When",
"eStr": ["action"]
}
}
59 changes: 16 additions & 43 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/srv6.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:20::",
"ip_prefix": "FCBB:BBBB:20::/48",
"locator": "MAIN",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
Expand All @@ -39,12 +39,12 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:20::",
"ip_prefix": "FCBB:BBBB:20::/48",
"locator": "MAIN",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
Expand All @@ -66,12 +66,12 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:20::",
"ip_prefix": "FCBB:BBBB:20::/48",
"locator": "MAIN",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
Expand All @@ -92,20 +92,20 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:20::",
"ip_prefix": "FCBB:BBBB:20::/48",
"locator": "None",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
]
}
}
},
"SRV6_MY_SID_INVALID_IP_ADDR": {
"SRV6_MY_SID_INVALID_IP_PREFIX": {
"sonic-srv6:sonic-srv6": {
"sonic-srv6:SRV6_MY_LOCATORS": {
"SRV6_MY_LOCATORS_LIST": [
Expand All @@ -118,20 +118,20 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:200001::",
"ip_prefix": "FCBB:BBBB:21::",
"locator": "MAIN",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
]
}
}
},
"SRV6_MY_SID_UNMATCHED_IP_ADDR": {
"SRV6_MY_SID_UNMATCHED_IP_PREFIX": {
"sonic-srv6:sonic-srv6": {
"sonic-srv6:SRV6_MY_LOCATORS": {
"SRV6_MY_LOCATORS_LIST": [
Expand All @@ -144,12 +144,12 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:21::",
"ip_prefix": "FCBB:BBBB:21::/48",
"locator": "MAIN",
"action": "uN"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
Expand All @@ -170,39 +170,12 @@
"sonic-srv6:SRV6_MY_SIDS": {
"SRV6_MY_SIDS_LIST": [
{
"ip_address": "FCBB:BBBB:20::",
"ip_prefix": "FCBB:BBBB:20::/48",
"locator": "MAIN",
"action": "uA"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"locator": "MAIN",
"action": "uDT46"
}
]
}
}
},
"SRV6_MY_SID_DSCP_MODE_WITH_UN": {
"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": [
{
"ip_address": "FCBB:BBBB:20::",
"locator": "MAIN",
"action": "uN",
"decap_dscp_mode": "uniform"
},
{
"ip_address": "FCBB:BBBB:20:F1::",
"ip_prefix": "FCBB:BBBB:20:F1::/64",
"locator": "MAIN",
"action": "uDT46"
}
Expand Down
15 changes: 4 additions & 11 deletions src/sonic-yang-models/yang-models/sonic-srv6.yang
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ module sonic-srv6 {
prefix srv6;
yang-version 1.1;

import ietf-yang-types {
prefix yang;
}

import ietf-inet-types {
prefix inet;
}
Expand Down Expand Up @@ -87,10 +83,10 @@ module sonic-srv6 {

container SRV6_MY_SIDS {
list SRV6_MY_SIDS_LIST {
key "locator ip_address";
key "locator ip_prefix";

leaf ip_address {
type inet:ipv6-address;
leaf ip_prefix {
type inet:ipv6-prefix;
}

leaf locator {
Expand Down Expand Up @@ -125,12 +121,9 @@ module sonic-srv6 {
enum uniform;
enum pipe;
}
when "../action = 'uDT46'";

default "uniform";
}

must 'starts-with(./ip_address,
must 'starts-with(substring-before(./ip_prefix, "::"),
substring-before(/srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))';
}
}
Expand Down

0 comments on commit 48aad69

Please sign in to comment.