Skip to content

Commit

Permalink
[YANG] Add yang model to SUBNET_DECAP table (#21118)
Browse files Browse the repository at this point in the history
* [YANG] Add yang model to `SUBNET_DECAP` table

Signed-off-by: Longxiang Lyu <[email protected]>
  • Loading branch information
lolyu authored Dec 20, 2024
1 parent 6d876a4 commit abaa145
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
* [XCVRD_LOG](#xcvrd_log)
* [PASSWORD_HARDENING](#password_hardening)
* [SSH_SERVER](#ssh_server)
* [SUBNET_DECAP](#subnet_decap)
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
* [RADIUS](#radius)
* [Static DNS](#static-dns)
Expand Down Expand Up @@ -2810,6 +2811,20 @@ The method could be:
}
```
### SUBNET_DECAP
The **SUBNET_DECAP** table is used for subnet decap configuration.
```
"SUBNET_DECAP": {
"AZURE": {
"status": "enable",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
}
```
### SYSTEM_DEFAULTS table
To have a better management of the features in SONiC, a new table `SYSTEM_DEFAULTS` is introduced.
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def run(self):
'./yang-models/sonic-system-tacacs.yang',
'./yang-models/sonic-system-radius.yang',
'./yang-models/sonic-system-ldap.yang',
'./yang-models/sonic-subnet-decap.yang',
'./yang-models/sonic-telemetry.yang',
'./yang-models/sonic-telemetry_client.yang',
'./yang-models/sonic-gnmi.yang',
Expand Down
7 changes: 7 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"vni" : "100"
}
},
"SUBNET_DECAP": {
"AZURE": {
"status": "enable",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
},
"DHCP_SERVER": {
"192.0.0.8": {},
"192.0.0.8": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"SUBNET_DECAP_DEFAULT_TEST": {
"desc": "Configure SUBNET_DECAP table."
},
"SUBNET_DECAP_ENABLE_TEST": {
"desc": "Configure SUBNET_DECAP table with status as enable."
},
"SUBNET_DECAP_DISABLE_TEST": {
"desc": "Configure SUBNET_DECAP table with status as disable."
},
"SUBNET_DECAP_INVALID_STATUS_TEST": {
"desc": "Configure SUBNET_DECAP table with invalid status.",
"eStrKey": "InvalidValue"
},
"SUBNET_DECAP_INVALID_IPV4": {
"desc": "Configure SUBNET_DECAP table with invalid src ipv4 prefix.",
"eStrKey": "Pattern"
},
"SUBNET_DECAP_INVALID_IPV6": {
"desc": "Configure SUBNET_DECAP table with invalid src ipv6 prefix.",
"eStrKey": "Pattern"
},
"SUBNET_DECAP_NO_IPV4": {
"desc": "Configure SUBNET_DECAP table without src ipv4 prefix.",
"eStrKey": "Mandatory"
},
"SUBNET_DECAP_NO_IPV6": {
"desc": "Configure SUBNET_DECAP table without src ipv6 prefix.",
"eStrKey": "Mandatory"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"SUBNET_DECAP_DEFAULT_TEST": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_ENABLE_TEST": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enable",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_DISABLE_TEST": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "disable",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_INVALID_STATUS_TEST": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enabled",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_INVALID_IPV4": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enable",
"src_ip": "10.10.10.01111/24",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_INVALID_IPV6": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enable",
"src_ip": "10.10.10.0/24",
"src_ip_v6": "20c1:ba8::01111/64"
}
]
}
}
},
"SUBNET_DECAP_NO_IPV4": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enable",
"src_ip_v6": "20c1:ba8::/64"
}
]
}
}
},
"SUBNET_DECAP_NO_IPV6": {
"sonic-subnet-decap:sonic-subnet-decap": {
"sonic-subnet-decap:SUBNET_DECAP": {
"SUBNET_DECAP_LIST": [
{
"name": "AZURE",
"status": "enable",
"src_ip": "10.10.10.0/24"
}
]
}
}
}
}
57 changes: 57 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-subnet-decap.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module sonic-subnet-decap {

yang-version 1.1;

namespace "http://github.com/sonic-net/sonic-subnet-decap";

prefix subnet-decap;

import ietf-inet-types {
prefix inet;
}

import sonic-types {
prefix stypes;
}

description "Subnet decap configuration for SONiC OS.";

revision 2024-12-19 {
description "Initial version";
}

container sonic-subnet-decap {
container SUBNET_DECAP {

description "CONFIG_DB subnet decap configuration.";

list SUBNET_DECAP_LIST {

key "name";

leaf name {
type string;
description "Subnet Decap config name.";
}

leaf status {
type stypes:mode-status;
default disable;
description "Subnet Decap status.";
}

leaf src_ip {
type inet:ipv4-prefix;
description "Subnet decap term source IPv4 prefix.";
mandatory true;
}

leaf src_ip_v6 {
type inet:ipv6-prefix;
description "Subnet decap term source IPv6 prefix.";
mandatory true;
}
}
}
}
}

0 comments on commit abaa145

Please sign in to comment.