Skip to content

Commit abaa145

Browse files
authored
[YANG] Add yang model to SUBNET_DECAP table (#21118)
* [YANG] Add yang model to `SUBNET_DECAP` table Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
1 parent 6d876a4 commit abaa145

File tree

6 files changed

+222
-0
lines changed

6 files changed

+222
-0
lines changed

src/sonic-yang-models/doc/Configuration.md

+15
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
* [XCVRD_LOG](#xcvrd_log)
8888
* [PASSWORD_HARDENING](#password_hardening)
8989
* [SSH_SERVER](#ssh_server)
90+
* [SUBNET_DECAP](#subnet_decap)
9091
* [SYSTEM_DEFAULTS table](#systemdefaults-table)
9192
* [RADIUS](#radius)
9293
* [Static DNS](#static-dns)
@@ -2810,6 +2811,20 @@ The method could be:
28102811
}
28112812
```
28122813
2814+
### SUBNET_DECAP
2815+
2816+
The **SUBNET_DECAP** table is used for subnet decap configuration.
2817+
2818+
```
2819+
"SUBNET_DECAP": {
2820+
"AZURE": {
2821+
"status": "enable",
2822+
"src_ip": "10.10.10.0/24",
2823+
"src_ip_v6": "20c1:ba8::/64"
2824+
}
2825+
}
2826+
```
2827+
28132828
### SYSTEM_DEFAULTS table
28142829
To have a better management of the features in SONiC, a new table `SYSTEM_DEFAULTS` is introduced.
28152830

src/sonic-yang-models/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def run(self):
167167
'./yang-models/sonic-system-tacacs.yang',
168168
'./yang-models/sonic-system-radius.yang',
169169
'./yang-models/sonic-system-ldap.yang',
170+
'./yang-models/sonic-subnet-decap.yang',
170171
'./yang-models/sonic-telemetry.yang',
171172
'./yang-models/sonic-telemetry_client.yang',
172173
'./yang-models/sonic-gnmi.yang',

src/sonic-yang-models/tests/files/sample_config_db.json

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
"vni" : "100"
66
}
77
},
8+
"SUBNET_DECAP": {
9+
"AZURE": {
10+
"status": "enable",
11+
"src_ip": "10.10.10.0/24",
12+
"src_ip_v6": "20c1:ba8::/64"
13+
}
14+
},
815
"DHCP_SERVER": {
916
"192.0.0.8": {},
1017
"192.0.0.8": {},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"SUBNET_DECAP_DEFAULT_TEST": {
3+
"desc": "Configure SUBNET_DECAP table."
4+
},
5+
"SUBNET_DECAP_ENABLE_TEST": {
6+
"desc": "Configure SUBNET_DECAP table with status as enable."
7+
},
8+
"SUBNET_DECAP_DISABLE_TEST": {
9+
"desc": "Configure SUBNET_DECAP table with status as disable."
10+
},
11+
"SUBNET_DECAP_INVALID_STATUS_TEST": {
12+
"desc": "Configure SUBNET_DECAP table with invalid status.",
13+
"eStrKey": "InvalidValue"
14+
},
15+
"SUBNET_DECAP_INVALID_IPV4": {
16+
"desc": "Configure SUBNET_DECAP table with invalid src ipv4 prefix.",
17+
"eStrKey": "Pattern"
18+
},
19+
"SUBNET_DECAP_INVALID_IPV6": {
20+
"desc": "Configure SUBNET_DECAP table with invalid src ipv6 prefix.",
21+
"eStrKey": "Pattern"
22+
},
23+
"SUBNET_DECAP_NO_IPV4": {
24+
"desc": "Configure SUBNET_DECAP table without src ipv4 prefix.",
25+
"eStrKey": "Mandatory"
26+
},
27+
"SUBNET_DECAP_NO_IPV6": {
28+
"desc": "Configure SUBNET_DECAP table without src ipv6 prefix.",
29+
"eStrKey": "Mandatory"
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"SUBNET_DECAP_DEFAULT_TEST": {
3+
"sonic-subnet-decap:sonic-subnet-decap": {
4+
"sonic-subnet-decap:SUBNET_DECAP": {
5+
"SUBNET_DECAP_LIST": [
6+
{
7+
"name": "AZURE",
8+
"src_ip": "10.10.10.0/24",
9+
"src_ip_v6": "20c1:ba8::/64"
10+
}
11+
]
12+
}
13+
}
14+
},
15+
"SUBNET_DECAP_ENABLE_TEST": {
16+
"sonic-subnet-decap:sonic-subnet-decap": {
17+
"sonic-subnet-decap:SUBNET_DECAP": {
18+
"SUBNET_DECAP_LIST": [
19+
{
20+
"name": "AZURE",
21+
"status": "enable",
22+
"src_ip": "10.10.10.0/24",
23+
"src_ip_v6": "20c1:ba8::/64"
24+
}
25+
]
26+
}
27+
}
28+
},
29+
"SUBNET_DECAP_DISABLE_TEST": {
30+
"sonic-subnet-decap:sonic-subnet-decap": {
31+
"sonic-subnet-decap:SUBNET_DECAP": {
32+
"SUBNET_DECAP_LIST": [
33+
{
34+
"name": "AZURE",
35+
"status": "disable",
36+
"src_ip": "10.10.10.0/24",
37+
"src_ip_v6": "20c1:ba8::/64"
38+
}
39+
]
40+
}
41+
}
42+
},
43+
"SUBNET_DECAP_INVALID_STATUS_TEST": {
44+
"sonic-subnet-decap:sonic-subnet-decap": {
45+
"sonic-subnet-decap:SUBNET_DECAP": {
46+
"SUBNET_DECAP_LIST": [
47+
{
48+
"name": "AZURE",
49+
"status": "enabled",
50+
"src_ip": "10.10.10.0/24",
51+
"src_ip_v6": "20c1:ba8::/64"
52+
}
53+
]
54+
}
55+
}
56+
},
57+
"SUBNET_DECAP_INVALID_IPV4": {
58+
"sonic-subnet-decap:sonic-subnet-decap": {
59+
"sonic-subnet-decap:SUBNET_DECAP": {
60+
"SUBNET_DECAP_LIST": [
61+
{
62+
"name": "AZURE",
63+
"status": "enable",
64+
"src_ip": "10.10.10.01111/24",
65+
"src_ip_v6": "20c1:ba8::/64"
66+
}
67+
]
68+
}
69+
}
70+
},
71+
"SUBNET_DECAP_INVALID_IPV6": {
72+
"sonic-subnet-decap:sonic-subnet-decap": {
73+
"sonic-subnet-decap:SUBNET_DECAP": {
74+
"SUBNET_DECAP_LIST": [
75+
{
76+
"name": "AZURE",
77+
"status": "enable",
78+
"src_ip": "10.10.10.0/24",
79+
"src_ip_v6": "20c1:ba8::01111/64"
80+
}
81+
]
82+
}
83+
}
84+
},
85+
"SUBNET_DECAP_NO_IPV4": {
86+
"sonic-subnet-decap:sonic-subnet-decap": {
87+
"sonic-subnet-decap:SUBNET_DECAP": {
88+
"SUBNET_DECAP_LIST": [
89+
{
90+
"name": "AZURE",
91+
"status": "enable",
92+
"src_ip_v6": "20c1:ba8::/64"
93+
}
94+
]
95+
}
96+
}
97+
},
98+
"SUBNET_DECAP_NO_IPV6": {
99+
"sonic-subnet-decap:sonic-subnet-decap": {
100+
"sonic-subnet-decap:SUBNET_DECAP": {
101+
"SUBNET_DECAP_LIST": [
102+
{
103+
"name": "AZURE",
104+
"status": "enable",
105+
"src_ip": "10.10.10.0/24"
106+
}
107+
]
108+
}
109+
}
110+
}
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
module sonic-subnet-decap {
2+
3+
yang-version 1.1;
4+
5+
namespace "http://github.com/sonic-net/sonic-subnet-decap";
6+
7+
prefix subnet-decap;
8+
9+
import ietf-inet-types {
10+
prefix inet;
11+
}
12+
13+
import sonic-types {
14+
prefix stypes;
15+
}
16+
17+
description "Subnet decap configuration for SONiC OS.";
18+
19+
revision 2024-12-19 {
20+
description "Initial version";
21+
}
22+
23+
container sonic-subnet-decap {
24+
container SUBNET_DECAP {
25+
26+
description "CONFIG_DB subnet decap configuration.";
27+
28+
list SUBNET_DECAP_LIST {
29+
30+
key "name";
31+
32+
leaf name {
33+
type string;
34+
description "Subnet Decap config name.";
35+
}
36+
37+
leaf status {
38+
type stypes:mode-status;
39+
default disable;
40+
description "Subnet Decap status.";
41+
}
42+
43+
leaf src_ip {
44+
type inet:ipv4-prefix;
45+
description "Subnet decap term source IPv4 prefix.";
46+
mandatory true;
47+
}
48+
49+
leaf src_ip_v6 {
50+
type inet:ipv6-prefix;
51+
description "Subnet decap term source IPv6 prefix.";
52+
mandatory true;
53+
}
54+
}
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)