diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index d9d761a5546e..110a5b9ee7be 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -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) @@ -2809,6 +2810,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. diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 60dba6c410aa..ab5b7b360dac 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -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', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 6f7e90c229ff..cb67858256d4 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -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": {}, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/subnet_decap.json b/src/sonic-yang-models/tests/yang_model_tests/tests/subnet_decap.json new file mode 100644 index 000000000000..d3ce0b721361 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/subnet_decap.json @@ -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" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/subnet_decap.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/subnet_decap.json new file mode 100644 index 000000000000..6b8373d7ad35 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/subnet_decap.json @@ -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" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-subnet-decap.yang b/src/sonic-yang-models/yang-models/sonic-subnet-decap.yang new file mode 100644 index 000000000000..c14c6b218465 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-subnet-decap.yang @@ -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; + } + } + } + } +}