Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YANG] Add srv6 yang model and unit tests #21175

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
19 changes: 19 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SONiC Configuration Database Manual


**Table of Contents**

* [Introduction](#introduction)
Expand Down Expand Up @@ -90,6 +91,7 @@
* [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)
Expand Down Expand Up @@ -2868,6 +2870,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.
Expand Down
25 changes: 25 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/srv6.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
}
96 changes: 96 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-srv6.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
module sonic-srv6 {
namespace "http://github.com/sonic-net/sonic-srv6";
prefix srv6;
yang-version 1.1;

import ietf-yang-types {
prefix yang;
}

import ietf-inet-types {
prefix inet;
}

import sonic-vrf {
prefix vrf;
}

revision 2024-12-05 {
description
"Initial revision.";
}

container sonic-srv6 {

container SRV6_MY_SID_TABLE {
list SRV6_MY_SID_TABLE_LIST {
key "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 "0..128";
}

default 0;
}

leaf action {
type enumeration {
enum uN;
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 = 'uDT46'";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have default define here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

}

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";
}
}
}

}
}
Loading