diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index c0bec1558f..9bc32e2799 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -43,7 +43,8 @@ Table of Contents * [Management port](#management-port) * [Management VRF](#management-vrf) * [MAP_PFC_PRIORITY_TO_QUEUE](#map_pfc_priority_to_queue) - * [MUX_CABLE](#muxcable) + * [MUX_CABLE](#mux_cable) + * [NEIGH](#neigh) * [NTP Global Configuration](#ntp-global-configuration) * [NTP and SYSLOG servers](#ntp-and-syslog-servers) * [Peer Switch](#peer-switch) @@ -1293,6 +1294,32 @@ The **MUX_CABLE** table is used for dualtor interface configuration. The `cable_ } ``` +### NEIGH + +The **NEIGH** table is used to keep track of resolved and static neighbors. + +Resolve case: +``` +{ + "NEIGH": { + "Vlan100|100.1.1.3": { + "family": "IPv4" + } + } +} +``` +Static Nbr: +``` +{ + "NEIGH": { + "Vlan100|100.1.1.5": { + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + } + } +} +``` + ### NTP Global Configuration These configuration options are used to modify the way that diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 0416794925..e4e4fe0ac1 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -132,6 +132,7 @@ setup( './yang-models/sonic-mirror-session.yang', './yang-models/sonic-mpls-tc-map.yang', './yang-models/sonic-mux-cable.yang', + './yang-models/sonic-neigh.yang', './yang-models/sonic-ntp.yang', './yang-models/sonic-nat.yang', './yang-models/sonic-nvgre-tunnel.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 021bac8b30..933867da3c 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2097,6 +2097,15 @@ } }, + "NEIGH": { + "Vlan100|100.1.1.3": { + "family": "IPv4" + }, + "Vlan100|100.1.1.5": { + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + } + }, "POLICER": { "everflow_static_policer": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json new file mode 100644 index 0000000000..33f87167d6 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json @@ -0,0 +1,15 @@ +{ + "VALID_NEIGH": { + "desc": "Load valid neighbors" + }, + + "NEIGH_MISSING_IP": { + "desc": "Load NEIGH missing IP address", + "eStr": ["Invalid JSON data"] + }, + + "NEIGH_INVALID_VLAN": { + "desc": "Load NEIGH missing VLAN", + "eStr": ["does not satisfy the constraint"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json new file mode 100644 index 0000000000..165bbb6b86 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/neigh.json @@ -0,0 +1,73 @@ +{ + "VALID_NEIGH": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "vlan": "Vlan1000", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + }, + { + "vlan": "Vlan1000", + "neighbor": "100.1.1.4", + "family": "IPv4" + } + ] + } + } + }, + + "NEIGH_MISSING_IPV4": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "vlan": "Vlan1000", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + } + ] + } + } + }, + + "NEIGH_INVALID_VLAN": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "vlan": "INVALIDVlan", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + }, + { + "vlan": "Vlan1000", + "neighbor": "100.1.1.4", + "family": "IPv4" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-neigh.yang b/src/sonic-yang-models/yang-models/sonic-neigh.yang new file mode 100644 index 0000000000..3a160a463f --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-neigh.yang @@ -0,0 +1,55 @@ +module sonic-neigh { + yang-version 1.1; + namespace "http://github.com/sonic-net/sonic-neigh"; + prefix neigh; + + import ietf-inet-types { + prefix inet; + } + + import ietf-yang-types { + prefix yang; + } + + organization "SONiC"; + contact "SONiC"; + + description "NEIGH YANG Module for SONiC OS"; + + revision 2023-03-31 { + description "Initial Revision"; + } + + container sonic-neigh { + container NEIGH { + description "NEIGH configuration"; + list NEIGH_LIST { + key "vlan neighbor"; + + leaf vlan { + description "Neighbor Vlan interface ex. Vlan1000"; + type string { + pattern "Vlan[0-9]+"; + } + } + + leaf neighbor { + description "Neighbor IP address ex. 100.1.1.3"; + type inet:ip-address; + } + + leaf neigh { + description "Neighbor MAC address"; + type yang:mac-address; + } + + leaf family { + description "IP family of Neighbor address"; + type string { + pattern "IPv4|IPV4|IPv6|IPV6"; + } + } + } + } + } +}