From fbcbf7f35434630f532409242425f2a672fd2462 Mon Sep 17 00:00:00 2001 From: Brad House Date: Fri, 20 Nov 2026 00:07:10 +0000 Subject: [PATCH 1/2] [yang] Reference VLANs and VLAN sub-interfaces by leafref Removing a VLAN or sub-interface (config vlan del, config interface breakout, GCU) finds the rows that depend on it only through YANG leafrefs. These fields named a local VLAN, and the BGP neighbor keys also a sub-interface, by string pattern or plain string, so deleting the interface left their rows behind, and nothing refused a row naming a VLAN that never existed: - BGP_NEIGHBOR, BGP_INTERNAL_NEIGHBOR, BGP_VOQ_CHASSIS_NEIGHBOR neighbor - BGP local_addr (sonic-bgp-common) - DHCPV4_RELAY name and source_interface - DHCP_SERVER_IPV4 name - ROUTE_MAP match_interface and match_neighbor - RADIUS_SERVER src_intf - NEIGH port - MCLAG_UNIQUE_IP if_name - STP_VLAN name - DASH_HA_GLOBAL_CONFIG dpu_vlan Each pattern becomes a leafref to VLAN or VLAN_SUB_INTERFACE, and the commented-out leafrefs and imports left "until libyang back-links issue is resolved" are restored: libyang3 resolves a leafref inside a union per member. None of the changed modules is in the import closure of sonic-vlan or sonic-vlan-sub-interface. Where the old pattern stopped at Vlan4094, a must keeps Vlan4095 refused, because the VLAN name pattern accepts it and vlanid is optional. NEIGH port, STP_VLAN name and dpu_vlan accepted Vlan4095 before and still do. Fixtures that named a VLAN without defining it gain the VLAN row (the DHCP relay, server and match cases, and the sonic-yang-mgmt DHCP match fixture), and sample_config_db.json gains Vlan222, which its DHCPV4_RELAY already named. sonic-yang-mgmt gains a static SonicYang.union_member_types(type_obj), the compiled member types of a union ([] for a non-union). libyang-python's Type.union_types() zips compiled members with parsed ones, and libyang compiles a nested union such as inet:ip-address flat, so it drops the trailing compiled members: the leafrefs these unions now end with. sonic-utilities needs them to find what references a VLAN and goes through sonic_yang rather than importing libyang. The yJson view's union types use it too, so they keep those members. Signed-off-by: Brad House --- src/sonic-yang-mgmt/sonic_yang.py | 23 +- .../libyang-python-tests/test_sonic_yang.py | 43 ++ src/sonic-yang-models/doc/Configuration.md | 13 +- .../tests/files/sample_config_db.json | 4 + .../test_dhcp_server_ipv4_match.py | 5 + .../yang_model_pytests/test_smart_switch.py | 25 +- .../tests/yang_model_tests/tests/bgp.json | 33 ++ .../yang_model_tests/tests/bgp_internal.json | 20 + .../tests/bgp_voq_chassis_neighbor.json | 20 + .../tests/dhcp_server_ipv4.json | 10 + .../yang_model_tests/tests/dhcpv4_relay.json | 23 ++ .../tests/yang_model_tests/tests/mclag.json | 13 + .../tests/yang_model_tests/tests/neigh.json | 4 + .../tests/yang_model_tests/tests/radius.json | 13 + .../yang_model_tests/tests/route_filter.json | 27 +- .../tests/sonic-spanning-tree.json | 7 + .../yang_model_tests/tests_config/bgp.json | 265 +++++++++++++ .../tests_config/bgp_internal.json | 171 ++++++++ .../bgp_voq_chassis_neighbor.json | 174 ++++++++ .../tests_config/dhcp_server_ipv4.json | 149 +++++++ .../tests_config/dhcp_server_ipv4_match.json | 234 +++++++++++ .../tests_config/dhcpv4_relay.json | 253 ++++++++++++ .../yang_model_tests/tests_config/mclag.json | 372 ++++++++++++++++++ .../yang_model_tests/tests_config/neigh.json | 19 + .../yang_model_tests/tests_config/radius.json | 70 +++- .../tests_config/route_filter.json | 126 ++++++ .../tests_config/sonic-spanning-tree.json | 54 +++ .../yang-models/sonic-bgp-common.yang | 29 +- .../sonic-bgp-internal-neighbor.yang | 31 +- .../yang-models/sonic-bgp-neighbor.yang | 53 ++- .../sonic-bgp-voq-chassis-neighbor.yang | 31 +- .../yang-models/sonic-dhcp-server-ipv4.yang | 31 +- .../yang-models/sonic-dhcpv4-relay.yang | 37 +- .../yang-models/sonic-mclag.yang | 29 +- .../yang-models/sonic-neigh.yang | 26 +- .../yang-models/sonic-route-map.yang | 42 +- .../yang-models/sonic-smart-switch.yang | 19 +- .../yang-models/sonic-spanning-tree.yang | 18 +- .../yang-models/sonic-system-radius.yang | 26 +- 39 files changed, 2421 insertions(+), 121 deletions(-) diff --git a/src/sonic-yang-mgmt/sonic_yang.py b/src/sonic-yang-mgmt/sonic_yang.py index 943bbee39ff..743fcfeaa8b 100644 --- a/src/sonic-yang-mgmt/sonic_yang.py +++ b/src/sonic-yang-mgmt/sonic_yang.py @@ -2,6 +2,8 @@ import libyang as ly import syslog +from _libyang import ffi +from libyang.util import ly_array_iter from json import dump from glob import glob @@ -159,6 +161,20 @@ def _yjson_node(self, snode: Any) -> Tuple[Optional[str], Dict[str, Any]]: # legacy yJson consumers don't read those branches. return None, d + @staticmethod + def union_member_types(type_obj: ly.Type) -> List[ly.Type]: + """Return the compiled member types of a union, in compiled order. + + A nested union (such as inet:ip-address) is already flattened into its + members by libyang. A non-union returns []. Use this over + `Type.union_types()`, which pairs compiled members with parsed ones + and so drops the trailing members of a union holding a nested union. + """ + if type_obj.base() != ly.Type.UNION: + return [] + union = ffi.cast('struct lysc_type_union *', type_obj.cdata) + return [ly.Type(type_obj.context, member, None) for member in ly_array_iter(union.types)] + def _yjson_type(self, type_obj: Any) -> Dict[str, Any]: # Prefer the typedef-aware name (e.g. "stypes:hwsku") so consumers # that text-match on prefixed type names continue to work; fall back @@ -171,7 +187,12 @@ def _yjson_type(self, type_obj: Any) -> Dict[str, Any]: if path: d['path'] = {'@value': path} elif base == 'union': - members = [self._yjson_type(t) for t in type_obj.union_types()] + member_types = SonicYang.union_member_types(type_obj) + named = list(type_obj.union_types()) + if len(named) == len(member_types): + # The same members, carrying their typedef names. + member_types = named + members = [self._yjson_type(t) for t in member_types] if members: d['type'] = members[0] if len(members) == 1 else members return d diff --git a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py index 5321ea0374b..11b82be2bdd 100644 --- a/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py +++ b/src/sonic-yang-mgmt/tests/libyang-python-tests/test_sonic_yang.py @@ -484,6 +484,9 @@ def test_xlate_rev_xlate(self, sonic_yang_data): @pytest.fixture def dhcp_match_config(self): return { + "VLAN": { + "Vlan100": {"vlanid": "100"}, + }, "DHCP_SERVER_IPV4": { "Vlan100": { "mode": "PORT", @@ -785,5 +788,45 @@ def test_loaddata_default_logs_syslog_on_success(self, sonic_yang_data, monkeypa return + BGP_NEIGHBOR_XPATH = "/sonic-bgp-neighbor:sonic-bgp-neighbor/BGP_NEIGHBOR/BGP_NEIGHBOR_LIST" + + def _leaf_type(self, syc, leaf): + snodes = list(syc.ctx.find_path("{}/{}".format(self.BGP_NEIGHBOR_XPATH, leaf))) + assert len(snodes) == 1 + return snodes[0].type() + + def test_union_member_types_keeps_trailing_leafrefs(self, sonic_yang_data): + # neighbor is a union of inet:ip-address (itself a union of ipv4 and + # ipv6) and four leafrefs; libyang compiles it flat into six members. + syc = sonic_yang_data['syc'] + neighbor = self._leaf_type(syc, "neighbor") + + members = sy.SonicYang.union_member_types(neighbor) + assert [m.basename() for m in members] == ['string', 'string'] + ['leafref'] * 4 + assert 'VLAN_SUB_INTERFACE_LIST' in members[-1].leafref_path() + # union_types() pairs the six compiled members with the five parsed + # ones and drops the last. + assert len(list(neighbor.union_types())) == 5 + + def test_union_member_types_of_non_union(self, sonic_yang_data): + syc = sonic_yang_data['syc'] + assert sy.SonicYang.union_member_types(self._leaf_type(syc, "peer_group_name")) == [] + + def test_yjson_union_keeps_trailing_leafrefs(self, sonic_yang_data): + syc = sonic_yang_data['syc'] + + def child(node, kind, name): + children = node[kind] if isinstance(node[kind], list) else [node[kind]] + return next(c for c in children if c['@name'] == name) + + module = next(m['module'] for m in syc.yJson if m['module']['@name'] == 'sonic-bgp-neighbor') + node = child(module, 'container', 'sonic-bgp-neighbor') + node = child(node, 'container', 'BGP_NEIGHBOR') + node = child(node, 'list', 'BGP_NEIGHBOR_LIST') + node = child(node, 'leaf', 'neighbor') + members = node['type']['type'] + assert len(members) == 6 + assert 'VLAN_SUB_INTERFACE_LIST' in members[-1]['path']['@value'] + def teardown_class(self): pass diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 98f703e8b6f..cb94e55be60 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -546,6 +546,11 @@ The table key can be a plain neighbor IP (e.g. `BGP_NEIGHBOR|10.0.0.61`) or a form, `vrf_name` accepts a VRF name (e.g. `default`, `Vrf1`) or a VNet name (e.g. `Vnet1`) for overlay BGP neighbors. +An unnumbered neighbor is keyed by a port, port channel, VLAN or VLAN sub-interface, +which must exist in `PORT`, `PORTCHANNEL`, `VLAN` or `VLAN_SUB_INTERFACE`. +`local_addr` may name a port, port channel, loopback or VLAN, which must exist in +`PORT`, `PORTCHANNEL`, `LOOPBACK_INTERFACE` or `VLAN`. + ``` { "BGP_NEIGHBOR": { @@ -1210,6 +1215,9 @@ instance is supported in SONiC. ### DHCPV4_RELAY +The key names a VLAN, which must exist in `VLAN`. `source_interface` must exist in `PORT`, +`PORTCHANNEL`, `VLAN` or `LOOPBACK_INTERFACE`. + ``` { "DHCPV4_RELAY": { @@ -1247,6 +1255,7 @@ BMP related configuration are defined in **bgp_neighbor_table**,**bgp_rib_in_tab ### DHCP_SERVER_IPV4 IPV4 DHCP Server related configuration are defined in **DHCP_SERVER_IPV4**, **DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS**, **DHCP_SERVER_IPV4_RANGE**, **DHCP_SERVER_IPV4_PORT**, **DHCP_SERVER_IPV4_MATCH**, **DHCP_SERVER_IPV4_BINDING** tables. +The **DHCP_SERVER_IPV4** key names a VLAN, which must exist in `VLAN`, or the midplane bridge. ``` { "DHCP_SERVER_IPV4": { @@ -2065,6 +2074,7 @@ The **MUX_LINKMGR** table is used for dualtor device configuration. ### NEIGH The **NEIGH** table is used to keep track of resolved and static neighbors. +The interface in the key must exist in `PORT`, `PORTCHANNEL` or `VLAN`. Resolve case: ``` @@ -3527,6 +3537,7 @@ For the flags that can be changed by reconfiguration, we can update entries in ` ### RADIUS The RADIUS and RADIUS_SERVER tables define RADIUS configuration parameters. RADIUS table carries global configuration while RADIUS_SERVER table carries per server configuration. +A RADIUS_SERVER `src_intf` must exist in `PORT`, `PORTCHANNEL`, `VLAN`, `LOOPBACK_INTERFACE` or `MGMT_PORT`. ``` "RADIUS": { @@ -3868,7 +3879,7 @@ Like NTP global configuration, DASH HA global configuration must have one entry **dpu_vnet**: Name of the vnet used for VNET tunnel route in SmartSwitch HA scenarios. Replaces `vnet_name`. -**dpu_vlan**: DPU VLAN identifier, referencing a VLAN name from the VLAN table. +**dpu_vlan**: The VLAN hamgrd resolves the DPU PA address on; it must exist in the VLAN table. **cp_data_channel_port**: Control plane data channel port, used for bulk sync. 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 006e145daec..aad520800db 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -506,6 +506,10 @@ "vlanid": "12", "mtu": "9216", "admin_status": "up" + }, + "Vlan222": { + "description": "dhcpv4 relay", + "vlanid": "222" } }, diff --git a/src/sonic-yang-models/tests/yang_model_pytests/test_dhcp_server_ipv4_match.py b/src/sonic-yang-models/tests/yang_model_pytests/test_dhcp_server_ipv4_match.py index b0b85d4f9ef..b10e8de48ff 100644 --- a/src/sonic-yang-models/tests/yang_model_pytests/test_dhcp_server_ipv4_match.py +++ b/src/sonic-yang-models/tests/yang_model_pytests/test_dhcp_server_ipv4_match.py @@ -3,6 +3,11 @@ def match_binding_data(match_name="vendor", binding_name="b1"): return { + "sonic-vlan:sonic-vlan": { + "VLAN": { + "VLAN_LIST": [{"name": "Vlan100"}], + }, + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [{ diff --git a/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py b/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py index 60546cf55a4..c4175af1775 100644 --- a/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py +++ b/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py @@ -544,8 +544,17 @@ def test_dash_ha_global_config_dpu_vnet_invalid(self, yang_model): yang_model.load_data(data, 'Invalid leafref value "NonExistentVnet"') def test_dash_ha_global_config_dpu_vlan(self, yang_model): - """Test dpu_vlan string field""" + """Test dpu_vlan referencing an existing VLAN""" data = { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, "sonic-smart-switch:sonic-smart-switch": { "sonic-smart-switch:DASH_HA_GLOBAL_CONFIG": { "global": { @@ -557,6 +566,20 @@ def test_dash_ha_global_config_dpu_vlan(self, yang_model): } yang_model.load_data(data) + def test_dash_ha_global_config_dpu_vlan_invalid(self, yang_model): + """Test dpu_vlan with non-existent VLAN reference""" + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DASH_HA_GLOBAL_CONFIG": { + "global": { + "dpu_vlan": "Vlan100", + "cp_data_channel_port": 11234 + } + } + } + } + yang_model.load_data(data, 'Invalid leafref value "Vlan100"') + @pytest.mark.parametrize( "dpu_name, error_message", [ ("dpu0", None), diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index 2cf9ed5afb2..fa989963bfe 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -321,5 +321,38 @@ "BGP_SENTINEL_INVALID_RANGE_IPV6": { "desc": "does not satisfy.", "eStr": "Invalid value \"fc00:f0::/129\" in \"ip_range\" element." + }, + "BGP_NEIGHBOR_VLAN_VALID": { + "desc": "A BGP neighbor on an existing VLAN is accepted." + }, + "BGP_NEIGHBOR_VLAN_MISSING": { + "desc": "A BGP neighbor naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_NEIGHBOR_SUBINTF_VALID": { + "desc": "A BGP neighbor on an existing VLAN sub-interface is accepted." + }, + "BGP_NEIGHBOR_SUBINTF_MISSING": { + "desc": "A BGP neighbor naming a VLAN sub-interface that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_VALID": { + "desc": "A BGP neighbor local_addr naming an existing VLAN is accepted." + }, + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_MISSING": { + "desc": "A BGP neighbor local_addr naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_NEIGHBOR_VLAN_4095": { + "desc": "A BGP neighbor on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] + }, + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_4095": { + "desc": "A BGP neighbor local_addr of Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_internal.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_internal.json index eb1943b9742..ddd5c1e8cb5 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_internal.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_internal.json @@ -18,5 +18,25 @@ "desc": "Internal BGP neighbor description contains a newline.", "eStrKey": "Pattern", "eStr": ["name"] + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_VALID": { + "desc": "A BGP_INTERNAL_NEIGHBOR on an existing VLAN is accepted." + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_MISSING": { + "desc": "A BGP_INTERNAL_NEIGHBOR naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_INTERNAL_SUBINTF_NEIGHBOR_VALID": { + "desc": "A BGP_INTERNAL_NEIGHBOR on an existing VLAN sub-interface is accepted." + }, + "BGP_INTERNAL_SUBINTF_NEIGHBOR_MISSING": { + "desc": "A BGP_INTERNAL_NEIGHBOR naming a VLAN sub-interface that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_4095": { + "desc": "A BGP_INTERNAL_NEIGHBOR on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_voq_chassis_neighbor.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_voq_chassis_neighbor.json index a9058fbfd46..42ce82dd93e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_voq_chassis_neighbor.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp_voq_chassis_neighbor.json @@ -18,5 +18,25 @@ "desc": "VOQ chassis BGP neighbor description contains a newline.", "eStrKey": "Pattern", "eStr": ["name"] + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_VALID": { + "desc": "A BGP_VOQ_CHASSIS_NEIGHBOR on an existing VLAN is accepted." + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_MISSING": { + "desc": "A BGP_VOQ_CHASSIS_NEIGHBOR naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_VOQ_CHASSIS_SUBINTF_NEIGHBOR_VALID": { + "desc": "A BGP_VOQ_CHASSIS_NEIGHBOR on an existing VLAN sub-interface is accepted." + }, + "BGP_VOQ_CHASSIS_SUBINTF_NEIGHBOR_MISSING": { + "desc": "A BGP_VOQ_CHASSIS_NEIGHBOR naming a VLAN sub-interface that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_4095": { + "desc": "A BGP_VOQ_CHASSIS_NEIGHBOR on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json index b317c7657bf..6b9380db91a 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json @@ -114,5 +114,15 @@ "DHCP_SERVER_IPV4_RANGE_THREE_IP": { "desc": "Three ips in DHCP_SERVER_IPV4_RANGE", "eStrKey": "Must" + }, + "DHCP_SERVER_IPV4_VLAN_MISSING": { + "desc": "Configure DHCP_SERVER_IPV4 on a VLAN that does not exist.", + "eStrKey": "LeafRef" + }, + "DHCP_SERVER_IPV4_VLAN_4095": { + "desc": "Configure DHCP_SERVER_IPV4 on Vlan4095.", + "eStr": [ + "Vlan4095 is reserved" + ] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json index 54d91ee112a..ed5d80cb7fc 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json @@ -45,5 +45,28 @@ "DHCPv4_RELAY_WITH_SERVER_VRF_AND_MISSING_SOURCE_INTERFACE_OPTION": { "desc": "Add dhcpv4 relay with server_vrf and missing source-interface option.", "eStrKey": "Must" + }, + "DHCPv4_RELAY_VLAN_MISSING": { + "desc": "Add dhcpv4 relay on a VLAN that does not exist.", + "eStrKey": "LeafRef" + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_VALID": { + "desc": "Add dhcpv4 relay with an existing VLAN as source_interface." + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_MISSING": { + "desc": "Add dhcpv4 relay with a source_interface VLAN that does not exist.", + "eStrKey": "LeafRef" + }, + "DHCPv4_RELAY_VLAN_4095": { + "desc": "Add dhcpv4 relay on Vlan4095.", + "eStr": [ + "Vlan4095 is reserved" + ] + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_4095": { + "desc": "Add dhcpv4 relay with Vlan4095 as source_interface.", + "eStr": [ + "Vlan4095 is reserved" + ] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/mclag.json b/src/sonic-yang-models/tests/yang_model_tests/tests/mclag.json index b7f3c69e1da..c3d1b651608 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/mclag.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/mclag.json @@ -28,5 +28,18 @@ "MCLAG_UNIQUE_IP_DOMAIN_ABSENT_TEST": { "desc": "mclag unique ip configured without domain", "eStr" : "mclag not configured" + }, + "MCLAG_UNIQUE_IP_VALID_TEST": { + "desc": "MCLAG unique ip on an existing VLAN is accepted." + }, + "MCLAG_UNIQUE_IP_VLAN_MISSING_TEST": { + "desc": "MCLAG unique ip naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "MCLAG_UNIQUE_IP_VLAN_4095_TEST": { + "desc": "MCLAG unique ip on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } } 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 index 07d414749f0..7f7a17153be 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/neigh.json @@ -27,5 +27,9 @@ "VALID_NEIGH_PORT": { "desc": "Load valid PORT" + }, + "NEIGH_VLAN_MISSING": { + "desc": "Load NEIGH on a VLAN that does not exist", + "eStrKey": "LeafRef" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/radius.json b/src/sonic-yang-models/tests/yang_model_tests/tests/radius.json index c7e68740881..783ba90e1bd 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/radius.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/radius.json @@ -32,5 +32,18 @@ "RADIUS_SERVER_INVALID_VRF_TEST" : { "desc": "Radius server configuration with invalid VRF in RADIUS_SERVER table.", "eStr": "Invalid VRF name" + }, + "RADIUS_SERVER_SRC_INTF_VLAN_TEST": { + "desc": "RADIUS server src_intf on an existing VLAN is accepted." + }, + "RADIUS_SERVER_SRC_INTF_VLAN_MISSING_TEST": { + "desc": "RADIUS server src_intf naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "RADIUS_SERVER_SRC_INTF_VLAN_4095_TEST": { + "desc": "RADIUS server src_intf of Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json index 33ac825ae23..ccd09b140fd 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/route_filter.json @@ -109,7 +109,32 @@ "ROUTE_MAP_MATCH_TAG_MUST_COND_FALSE": { "desc": "Configure route map table with more than one match tag in list.", "eStr": "Too many match_tag elements" + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN": { + "desc": "Route map match_interface on an existing VLAN is accepted." + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN_MISSING": { + "desc": "Route map match_interface naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN": { + "desc": "Route map match_neighbor on an existing VLAN is accepted." + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN_MISSING": { + "desc": "Route map match_neighbor naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN_4095": { + "desc": "Route map match_interface on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN_4095": { + "desc": "Route map match_neighbor on Vlan4095 is refused.", + "eStr": [ + "Vlan4095 is reserved" + ] } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-spanning-tree.json b/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-spanning-tree.json index 52a7514d218..23f3103d8b0 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-spanning-tree.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/sonic-spanning-tree.json @@ -2,5 +2,12 @@ "PVST_GLOBAL_VALID": { "desc": "Configure valid global PVST settings", "eStr": [] + }, + "PVST_VLAN_VALID": { + "desc": "An STP_VLAN row naming an existing VLAN is accepted." + }, + "PVST_VLAN_MISSING_VLAN": { + "desc": "An STP_VLAN row naming a VLAN that does not exist is refused.", + "eStrKey": "LeafRef" } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index d0cade25dc2..8705155c499 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -2434,5 +2434,270 @@ ] } } + }, + + "BGP_NEIGHBOR_VLAN_VALID": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Vlan100", + "asn": 65200 + } + ] + } + } + }, + + "BGP_NEIGHBOR_VLAN_MISSING": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Vlan100", + "asn": 65200 + } + ] + } + } + }, + + "BGP_NEIGHBOR_SUBINTF_VALID": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet0.10" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Ethernet0.10", + "asn": 65200 + } + ] + } + } + }, + + "BGP_NEIGHBOR_SUBINTF_MISSING": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Ethernet0.10", + "asn": 65200 + } + ] + } + } + }, + + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_VALID": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "10.0.0.1", + "asn": 65200, + "local_addr": "Vlan100" + } + ] + } + } + }, + + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_MISSING": { + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "10.0.0.1", + "asn": 65200, + "local_addr": "Vlan100" + } + ] + } + } + }, + + "BGP_NEIGHBOR_VLAN_4095": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "Vlan4095", + "asn": 65200 + } + ] + } + } + }, + + "BGP_NEIGHBOR_LOCAL_ADDR_VLAN_4095": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-bgp-global:sonic-bgp-global": { + "sonic-bgp-global:BGP_GLOBALS": { + "BGP_GLOBALS_LIST": [ + { + "vrf_name": "default", + "local_asn": 65001 + } + ] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "default", + "neighbor": "10.0.0.1", + "asn": 65200, + "local_addr": "Vlan4095" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_internal.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_internal.json index 7a3dedb6cfa..a76fa824cc5 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_internal.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_internal.json @@ -170,5 +170,176 @@ } } } + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_VALID": { + "sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": { + "sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": { + "BGP_INTERNAL_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan100", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "MASIC", + "platform": "multi-asic" + } + } + } + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_MISSING": { + "sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": { + "sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": { + "BGP_INTERNAL_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan100", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "MASIC", + "platform": "multi-asic" + } + } + } + }, + "BGP_INTERNAL_SUBINTF_NEIGHBOR_VALID": { + "sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": { + "sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": { + "BGP_INTERNAL_NEIGHBOR_LIST": [ + { + "neighbor": "Ethernet0.10", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet0.10" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "MASIC", + "platform": "multi-asic" + } + } + } + }, + "BGP_INTERNAL_SUBINTF_NEIGHBOR_MISSING": { + "sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": { + "sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": { + "BGP_INTERNAL_NEIGHBOR_LIST": [ + { + "neighbor": "Ethernet0.10", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "MASIC", + "platform": "multi-asic" + } + } + } + }, + "BGP_INTERNAL_VLAN_NEIGHBOR_4095": { + "sonic-bgp-internal-neighbor:sonic-bgp-internal-neighbor": { + "sonic-bgp-internal-neighbor:BGP_INTERNAL_NEIGHBOR": { + "BGP_INTERNAL_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan4095", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "MASIC", + "platform": "multi-asic" + } + } + } } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_voq_chassis_neighbor.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_voq_chassis_neighbor.json index 1f2cc8967c0..93c0c8dfa05 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_voq_chassis_neighbor.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp_voq_chassis_neighbor.json @@ -206,5 +206,179 @@ } } } + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_VALID": { + "sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": { + "sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": { + "BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan100", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "sonic-chassis", + "platform": "voq-chassis", + "switch_type": "voq" + } + } + } + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_MISSING": { + "sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": { + "sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": { + "BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan100", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "sonic-chassis", + "platform": "voq-chassis", + "switch_type": "voq" + } + } + } + }, + "BGP_VOQ_CHASSIS_SUBINTF_NEIGHBOR_VALID": { + "sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": { + "sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": { + "BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [ + { + "neighbor": "Ethernet0.10", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet0.10" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "sonic-chassis", + "platform": "voq-chassis", + "switch_type": "voq" + } + } + } + }, + "BGP_VOQ_CHASSIS_SUBINTF_NEIGHBOR_MISSING": { + "sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": { + "sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": { + "BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [ + { + "neighbor": "Ethernet0.10", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "speed": 25000, + "admin_status": "up" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "sonic-chassis", + "platform": "voq-chassis", + "switch_type": "voq" + } + } + } + }, + "BGP_VOQ_CHASSIS_VLAN_NEIGHBOR_4095": { + "sonic-bgp-voq-chassis-neighbor:sonic-bgp-voq-chassis-neighbor": { + "sonic-bgp-voq-chassis-neighbor:BGP_VOQ_CHASSIS_NEIGHBOR": { + "BGP_VOQ_CHASSIS_NEIGHBOR_LIST": [ + { + "neighbor": "Vlan4095", + "asn": "65001", + "name": "ASIC0", + "admin_status": "up" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "localhost": { + "bgp_asn": "65001", + "default_bgp_status": "up", + "hostname": "sonic-chassis", + "platform": "voq-chassis", + "switch_type": "voq" + } + } + } } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json index db7b4da141a..018560a9d84 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json @@ -97,6 +97,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_WITH_INVALID_VLAN": { @@ -130,6 +139,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_INCORRECT_NETMASK": { @@ -147,6 +165,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_STATE_WRONG_VALUE": { @@ -163,6 +190,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_MODE_WRONG_VALUE": { @@ -179,6 +215,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_WITH_NON_EXIST_BRIDGE": { @@ -232,6 +277,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_PORT_WITH_NO_EXIST_NAME": { @@ -288,6 +342,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_PORT_WITH_NO_EXIST_PORT": { @@ -538,6 +601,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_LEASE_TIME_ABSENT": { @@ -620,6 +692,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_MODE_ABSENT": { @@ -702,6 +783,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_NETMASK_ABSENT": { @@ -784,6 +874,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_STATE_ABSENT": { @@ -866,6 +965,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } } }, "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_ID_ABSENT": { @@ -934,5 +1042,46 @@ ] } } + }, + "DHCP_SERVER_IPV4_VLAN_MISSING": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { + "DHCP_SERVER_IPV4_LIST": [ + { + "name": "Vlan1000", + "gateway": "192.168.0.1", + "lease_time": 3600, + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + ] + } + } + }, + "DHCP_SERVER_IPV4_VLAN_4095": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { + "DHCP_SERVER_IPV4_LIST": [ + { + "name": "Vlan4095", + "gateway": "192.168.0.1", + "lease_time": 3600, + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4_match.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4_match.json index 16472a42c51..7d07d9120ac 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4_match.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4_match.json @@ -1,5 +1,14 @@ { "DHCP_SERVER_IPV4_MATCH_VALID_IP_BINDING": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -75,6 +84,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_VALID_RANGE_BINDING": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -125,6 +143,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_MAX_LENGTH_BOUNDARIES": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -253,6 +280,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_MATCHES_ABSENT": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -280,6 +316,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_NON_EXIST_MATCH": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -319,6 +364,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_NON_EXIST_INTERFACE": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -358,6 +412,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_BOTH_IPS_AND_RANGES": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -411,6 +474,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_POOL_ABSENT": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -447,6 +519,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_NON_EXIST_RANGE": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -497,6 +578,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_INVALID_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -536,6 +626,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_NAME_EMPTY": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -575,6 +674,15 @@ } }, "DHCP_SERVER_IPV4_BINDING_NAME_OVERLENGTH": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -614,6 +722,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_VALID_ALIAS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -658,6 +775,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_UNKNOWN_ALIAS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -702,6 +828,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_NO_PORT_TABLE": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -727,6 +862,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_PORT_NAME_WITHOUT_ALIAS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -771,6 +915,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_PORT_NAME_WITH_ALIAS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -815,6 +968,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_PORTCHANNEL": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -869,6 +1031,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_CIRCUIT_ID_OVERLENGTH_ALIAS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -913,6 +1084,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_OPTION60_SKIPS_PORT_CHECK": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -938,6 +1118,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_BINDING_DUPLICATE_OPTION60": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -983,6 +1172,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_BINDING_DUPLICATE_CIRCUIT_ID": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -1047,6 +1245,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_NAME_WITH_KEY_SEPARATOR": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -1086,6 +1293,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_NAME_WITH_LIST_SEPARATOR": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -1125,6 +1341,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_NAME_PUNCTUATION": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ @@ -1164,6 +1389,15 @@ } }, "DHCP_SERVER_IPV4_MATCH_BINDING_NAME_WITH_KEY_SEPARATOR": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + } + ] + } + }, "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4": { "DHCP_SERVER_IPV4_LIST": [ diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json index 4ca652ad070..d39008b5db1 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json @@ -11,6 +11,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_MULTIPLE_SERVERS": { @@ -26,6 +35,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_SERVER_VRF": { @@ -63,6 +81,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan888" + } + ] + } } }, "DHCPv4_RELAY_WITH_LINK_SELECT": { @@ -88,6 +115,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_AGENT_RELAY_MODE_DISCARD": { @@ -103,6 +139,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_AGENT_RELAY_MODE_APPEND": { @@ -118,6 +163,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_AGENT_RELAY_MODE_REPLACE": { @@ -133,6 +187,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_AGENT_RELAY_MODE_FORWARD": { @@ -148,6 +211,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_VALID_MAX_HOP_CNT": { @@ -163,6 +235,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_MISSING_SERVER_IP": { @@ -174,6 +255,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } } }, "DHCPv4_RELAY_WITH_SERVER_VRF_AND_MISSING_LINK_SELECT_OPTION": { @@ -210,6 +300,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan888" + } + ] + } } }, "DHCPv4_RELAY_WITH_SERVER_VRF_AND_MISSING_VRF_SELECT_OPTION": { @@ -246,6 +345,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan888" + } + ] + } } }, "DHCPv4_RELAY_WITH_SERVER_VRF_AND_MISSING_SERVER_OVERRIDE_OPTION": { @@ -282,6 +390,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan888" + } + ] + } } }, "DHCPv4_RELAY_WITH_SERVER_VRF_AND_MISSING_SOURCE_INTERFACE_OPTION": { @@ -318,6 +435,15 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan888" + } + ] + } } }, "DHCPv4_RELAY_WITH_INVALID_MAX_HOP_CNT": { @@ -333,6 +459,133 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan999" + } + ] + } + } + }, + "DHCPv4_RELAY_VLAN_MISSING": { + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan777", + "dhcpv4_servers": [ + "192.168.20.100" + ] + } + ] + } + } + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_VALID": { + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan777", + "dhcpv4_servers": [ + "192.168.20.100" + ], + "link_selection": "enable", + "source_interface": "Vlan778" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + }, + { + "name": "Vlan778" + } + ] + } + } + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_MISSING": { + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan777", + "dhcpv4_servers": [ + "192.168.20.100" + ], + "link_selection": "enable", + "source_interface": "Vlan778" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + } + ] + } + } + }, + "DHCPv4_RELAY_VLAN_4095": { + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan4095", + "dhcpv4_servers": [ + "192.168.20.100" + ] + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + } + }, + "DHCPv4_RELAY_SOURCE_INTERFACE_VLAN_4095": { + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan777", + "dhcpv4_servers": [ + "192.168.20.100" + ], + "link_selection": "enable", + "source_interface": "Vlan4095" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan777" + }, + { + "name": "Vlan4095" + } + ] + } } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json index 30c4a7331ae..9e62ba32a16 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/mclag.json @@ -352,5 +352,377 @@ ] } } + }, + "MCLAG_UNIQUE_IP_VALID_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + }, + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet10", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet10", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel2" + }, + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel10" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan12" + }, + { + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "PortChannel10", + "tagging_mode": "tagged", + "name": "Vlan100" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan12" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan12" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "12.1.1.1/24", + "scope": "global", + "name": "Vlan12" + } + ] + } + }, + "sonic-mclag:sonic-mclag": { + "sonic-mclag:MCLAG_DOMAIN": { + "MCLAG_DOMAIN_LIST": [ + { + "domain_id": "123", + "source_ip": "12.1.1.1", + "peer_ip": "12.1.1.2", + "peer_link": "PortChannel2", + "keepalive_interval": "1", + "session_timeout": "30" + } + ] + }, + "sonic-mclag:MCLAG_INTERFACE": { + "MCLAG_INTERFACE_LIST": [ + { + "domain_id": "123", + "if_name": "PortChannel10", + "if_type": "Portchannel" + } + ] + }, + "sonic-mclag:MCLAG_UNIQUE_IP": { + "MCLAG_UNIQUE_IP_LIST": [ + { + "if_name": "Vlan100", + "unique_ip": "enable" + } + ] + } + } + }, + "MCLAG_UNIQUE_IP_VLAN_MISSING_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + }, + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet10", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet10", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel2" + }, + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel10" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan12" + }, + { + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "PortChannel10", + "tagging_mode": "tagged", + "name": "Vlan100" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan12" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan12" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "12.1.1.1/24", + "scope": "global", + "name": "Vlan12" + } + ] + } + }, + "sonic-mclag:sonic-mclag": { + "sonic-mclag:MCLAG_DOMAIN": { + "MCLAG_DOMAIN_LIST": [ + { + "domain_id": "123", + "source_ip": "12.1.1.1", + "peer_ip": "12.1.1.2", + "peer_link": "PortChannel2", + "keepalive_interval": "1", + "session_timeout": "30" + } + ] + }, + "sonic-mclag:MCLAG_INTERFACE": { + "MCLAG_INTERFACE_LIST": [ + { + "domain_id": "123", + "if_name": "PortChannel10", + "if_type": "Portchannel" + } + ] + }, + "sonic-mclag:MCLAG_UNIQUE_IP": { + "MCLAG_UNIQUE_IP_LIST": [ + { + "if_name": "Vlan200", + "unique_ip": "enable" + } + ] + } + } + }, + "MCLAG_UNIQUE_IP_VLAN_4095_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + }, + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet10", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet10", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel2" + }, + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "lacp_key": "auto", + "name": "PortChannel10" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan12" + }, + { + "name": "Vlan100" + }, + { + "name": "Vlan4095" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "PortChannel10", + "tagging_mode": "tagged", + "name": "Vlan100" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan12" + }, + { + "port": "PortChannel2", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan12" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "12.1.1.1/24", + "scope": "global", + "name": "Vlan12" + } + ] + } + }, + "sonic-mclag:sonic-mclag": { + "sonic-mclag:MCLAG_DOMAIN": { + "MCLAG_DOMAIN_LIST": [ + { + "domain_id": "123", + "source_ip": "12.1.1.1", + "peer_ip": "12.1.1.2", + "peer_link": "PortChannel2", + "keepalive_interval": "1", + "session_timeout": "30" + } + ] + }, + "sonic-mclag:MCLAG_INTERFACE": { + "MCLAG_INTERFACE_LIST": [ + { + "domain_id": "123", + "if_name": "PortChannel10", + "if_type": "Portchannel" + } + ] + }, + "sonic-mclag:MCLAG_UNIQUE_IP": { + "MCLAG_UNIQUE_IP_LIST": [ + { + "if_name": "Vlan4095", + "unique_ip": "enable" + } + ] + } + } } } 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 index 76758d9e6f1..a4932f3a069 100644 --- 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 @@ -152,5 +152,24 @@ ] } } + }, + "NEIGH_VLAN_MISSING": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "port": "Vlan1000", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + }, + { + "port": "Vlan1000", + "neighbor": "100.1.1.4", + "family": "IPv4" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/radius.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/radius.json index 3f58635ef75..5a94ccbd40b 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/radius.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/radius.json @@ -134,6 +134,74 @@ ] } } + }, + "RADIUS_SERVER_SRC_INTF_VLAN_TEST": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-system-radius:sonic-system-radius": { + "sonic-system-radius:RADIUS_SERVER": { + "RADIUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "priority": 5, + "timeout": 6, + "auth_type": "chap", + "passkey": "brcm123", + "src_intf": "Vlan100", + "vrf": "default" + } + ] + } + } + }, + "RADIUS_SERVER_SRC_INTF_VLAN_MISSING_TEST": { + "sonic-system-radius:sonic-system-radius": { + "sonic-system-radius:RADIUS_SERVER": { + "RADIUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "priority": 5, + "timeout": 6, + "auth_type": "chap", + "passkey": "brcm123", + "src_intf": "Vlan100", + "vrf": "default" + } + ] + } + } + }, + "RADIUS_SERVER_SRC_INTF_VLAN_4095_TEST": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-system-radius:sonic-system-radius": { + "sonic-system-radius:RADIUS_SERVER": { + "RADIUS_SERVER_LIST": [ + { + "ipaddress": "192.168.1.1", + "priority": 5, + "timeout": 6, + "auth_type": "chap", + "passkey": "brcm123", + "src_intf": "Vlan4095", + "vrf": "default" + } + ] + } + } } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json index d146f77a3c6..e043a1fa986 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/route_filter.json @@ -635,6 +635,132 @@ ] } } + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_interface": "Vlan100" + } + ] + } + } + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN_MISSING": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_interface": "Vlan100" + } + ] + } + } + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_neighbor": [ + "Vlan100" + ] + } + ] + } + } + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN_MISSING": { + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_neighbor": [ + "Vlan100" + ] + } + ] + } + } + }, + "ROUTE_MAP_MATCH_INTERFACE_VLAN_4095": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_interface": "Vlan4095" + } + ] + } + } + }, + "ROUTE_MAP_MATCH_NEIGHBOR_VLAN_4095": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan4095" + } + ] + } + }, + "sonic-route-map:sonic-route-map": { + "sonic-route-map:ROUTE_MAP": { + "ROUTE_MAP_LIST": [ + { + "name": "map1", + "stmt_name": 1, + "route_operation": "permit", + "match_neighbor": [ + "Vlan4095" + ] + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-spanning-tree.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-spanning-tree.json index dea73c498f1..d8a2dbc83b3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-spanning-tree.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/sonic-spanning-tree.json @@ -30,5 +30,59 @@ ] } } + }, + "PVST_VLAN_VALID": { + "sonic-spanning-tree:sonic-spanning-tree": { + "sonic-spanning-tree:STP": { + "STP_LIST": [ + { + "keyleaf": "GLOBAL", + "mode": "pvst" + } + ] + }, + "sonic-spanning-tree:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "name": "Vlan120", + "vlanid": "120", + "enabled": "true", + "priority": "32768" + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan120", + "vlanid": 120 + } + ] + } + } + }, + "PVST_VLAN_MISSING_VLAN": { + "sonic-spanning-tree:sonic-spanning-tree": { + "sonic-spanning-tree:STP": { + "STP_LIST": [ + { + "keyleaf": "GLOBAL", + "mode": "pvst" + } + ] + }, + "sonic-spanning-tree:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "name": "Vlan120", + "vlanid": "120", + "enabled": "true", + "priority": "32768" + } + ] + } + } } } \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index be6c13ff96d..b7d157fdf09 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -19,10 +19,9 @@ module sonic-bgp-common { prefix lag; } - // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. - // import sonic-vlan { - // prefix vlan; - // } + import sonic-vlan { + prefix vlan; + } import sonic-loopback-interface { prefix lointf; @@ -49,6 +48,13 @@ module sonic-bgp-common { description "SONIC BGP common YANG attributes for Neighbors and Peer group"; + revision 2026-11-19 { + description + "local_addr names a VLAN by leafref to VLAN, so it cannot name a VLAN that does not + exist and the VLAN's removal finds the neighbors and peer groups that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2026-09-08 { description "Reject newline characters in template-based BGP neighbor descriptions."; @@ -219,6 +225,9 @@ module sonic-bgp-common { } leaf local_addr { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -227,18 +236,16 @@ module sonic-bgp-common { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - //type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - //} type leafref { path "/lointf:sonic-loopback-interface/lointf:LOOPBACK_INTERFACE/lointf:LOOPBACK_INTERFACE_LIST/lointf:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } - description "Local source address or interface name to use for connection."; + description + "Local source address, or the port, port channel, loopback or VLAN to source the + connection from; the interface must exist in its table."; } leaf passive_mode { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang index 9afc2b872f3..630381cfeec 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-internal-neighbor.yang @@ -23,6 +23,14 @@ module sonic-bgp-internal-neighbor { prefix lag; } + import sonic-vlan { + prefix vlan; + } + + import sonic-vlan-sub-interface { + prefix subintf; + } + organization "SONiC"; @@ -32,6 +40,14 @@ module sonic-bgp-internal-neighbor { description "SONIC BGP Internal Neighbor for multi asic platforms"; + revision 2026-11-19 { + description + "neighbor names a VLAN by leafref to VLAN and a sub-interface by leafref to + VLAN_SUB_INTERFACE, so an unnumbered neighbor cannot name an interface that does + not exist and the interface's removal finds the neighbors that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2021-04-10 { description "Initial revision."; @@ -48,6 +64,9 @@ module sonic-bgp-internal-neighbor { } leaf neighbor { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -56,14 +75,16 @@ module sonic-bgp-internal-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } - type string { - pattern '(Ethernet|Eth|PortChannel|Po)[0-9]+\.[0-9]+'; + type leafref { + path "/subintf:sonic-vlan-sub-interface/subintf:VLAN_SUB_INTERFACE/subintf:VLAN_SUB_INTERFACE_LIST/subintf:name"; } } - description "BGP Neighbor address or interface name"; + description + "BGP neighbor address, or the port, port channel, VLAN or VLAN sub-interface + of an unnumbered neighbor; the interface must exist in its table."; } uses bgpcmn:sonic-bgp-cmn-neigh { refine asn { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index 189fe93a1b8..a65055fd77c 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -19,10 +19,13 @@ module sonic-bgp-neighbor { prefix lag; } - // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. - //import sonic-vlan { - // prefix vlan; - //} + import sonic-vlan { + prefix vlan; + } + + import sonic-vlan-sub-interface { + prefix subintf; + } import sonic-bgp-global { prefix bgpg; @@ -45,6 +48,14 @@ module sonic-bgp-neighbor { description "SONIC BGP Neighbor"; + revision 2026-11-19 { + description + "neighbor names a VLAN by leafref to VLAN and a sub-interface by leafref to + VLAN_SUB_INTERFACE, so an unnumbered neighbor cannot name an interface that does + not exist and the interface's removal finds the neighbors that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2026-07-22 { description "Add VNet name support to BGP_NEIGHBOR_LIST and BGP_NEIGHBOR_AF_LIST vrf_name leaf."; @@ -62,6 +73,9 @@ module sonic-bgp-neighbor { key "neighbor"; leaf neighbor { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -70,14 +84,16 @@ module sonic-bgp-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } - type string { - pattern '(Ethernet|Eth|PortChannel|Po)[0-9]+\.[0-9]+'; + type leafref { + path "/subintf:sonic-vlan-sub-interface/subintf:VLAN_SUB_INTERFACE/subintf:VLAN_SUB_INTERFACE_LIST/subintf:name"; } } - description "BGP Neighbor address or interface name"; + description + "BGP neighbor address, or the port, port channel, VLAN or VLAN sub-interface of an + unnumbered neighbor; the interface must exist in its table."; } uses bgpcmn:sonic-bgp-cmn-neigh { @@ -107,6 +123,9 @@ module sonic-bgp-neighbor { } leaf neighbor { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -115,18 +134,16 @@ module sonic-bgp-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - // type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - // } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } - type string { - pattern '(Ethernet|Eth|PortChannel|Po)[0-9]+\.[0-9]+'; + type leafref { + path "/subintf:sonic-vlan-sub-interface/subintf:VLAN_SUB_INTERFACE/subintf:VLAN_SUB_INTERFACE_LIST/subintf:name"; } } - description "BGP Neighbor, it will be neighbor address or interface name"; + description + "BGP neighbor address, or the port, port channel, VLAN or VLAN sub-interface of an + unnumbered neighbor; the interface must exist in its table."; } leaf peer_group_name { diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang index 3041b04dbdf..140e843a581 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-voq-chassis-neighbor.yang @@ -23,6 +23,14 @@ module sonic-bgp-voq-chassis-neighbor { prefix lag; } + import sonic-vlan { + prefix vlan; + } + + import sonic-vlan-sub-interface { + prefix subintf; + } + organization "SONiC"; @@ -32,6 +40,14 @@ module sonic-bgp-voq-chassis-neighbor { description "SONIC BGP Internal Neighbor for voq chassis platforms"; + revision 2026-11-19 { + description + "neighbor names a VLAN by leafref to VLAN and a sub-interface by leafref to + VLAN_SUB_INTERFACE, so an unnumbered neighbor cannot name an interface that does + not exist and the interface's removal finds the neighbors that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2021-04-10 { description "Initial revision."; @@ -48,6 +64,9 @@ module sonic-bgp-voq-chassis-neighbor { } leaf neighbor { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -56,14 +75,16 @@ module sonic-bgp-voq-chassis-neighbor { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } - type string { - pattern '(Ethernet|Eth|PortChannel|Po)[0-9]+\.[0-9]+'; + type leafref { + path "/subintf:sonic-vlan-sub-interface/subintf:VLAN_SUB_INTERFACE/subintf:VLAN_SUB_INTERFACE_LIST/subintf:name"; } } - description "BGP Neighbor address or interface name"; + description + "BGP neighbor address, or the port, port channel, VLAN or VLAN sub-interface + of an unnumbered neighbor; the interface must exist in its table."; } uses bgpcmn:sonic-bgp-cmn-neigh { diff --git a/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang b/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang index f17a49a2496..4705b1ee6f1 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang @@ -14,10 +14,9 @@ module sonic-dhcp-server-ipv4 { prefix stypes; } - // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. - // import sonic-vlan { - // prefix vlan; - // } + import sonic-vlan { + prefix vlan; + } import sonic-port { prefix port; @@ -33,6 +32,13 @@ module sonic-dhcp-server-ipv4 { description "DHCP_SERVER_IPV4 YANG module for SONiC OS"; + revision 2026-11-19 { + description + "DHCP_SERVER_IPV4 name names a VLAN by leafref to VLAN, so a server cannot name a + VLAN that does not exist and the VLAN's removal finds the server that uses it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2026-08-22 { description "Add match condition based DHCPv4 address assignment"; } @@ -53,18 +59,19 @@ module sonic-dhcp-server-ipv4 { key "name"; leaf name { - description "Interface name for DHCP server"; + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } + description + "The VLAN or midplane bridge the DHCP server serves; it must exist in its + table."; type union { - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - // type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - // } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; - } type leafref { path "/smartswitch:sonic-smart-switch/smartswitch:MID_PLANE_BRIDGE/smartswitch:GLOBAL/smartswitch:bridge"; } + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang index 53f64dc8c33..b9db7036886 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang @@ -28,10 +28,21 @@ module sonic-dhcpv4-relay { prefix loopback; } + import sonic-vlan { + prefix vlan; + } + organization "SONiC"; contact "SONiC"; description "DHCPv4 Relay yang Module for SONiC OS"; + revision 2026-11-19 { + description + "name and source_interface name a VLAN by leafref to VLAN, so a relay cannot name a + VLAN that does not exist and the VLAN's removal finds the relays that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2024-12-30 { description "First Revision"; } @@ -44,15 +55,12 @@ module sonic-dhcpv4-relay { key "name"; leaf name { - description "VLAN ID"; - type union { - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - // type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - // } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; - } + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } + description "The VLAN the relay serves; it must exist in VLAN."; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } @@ -77,7 +85,12 @@ module sonic-dhcpv4-relay { } leaf source_interface { - description "Used to determine the source IP address of the relayed packet"; + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } + description + "The port, port channel, VLAN or loopback whose address is the source IP + address of the relayed packet; it must exist in its table."; type union { type leafref { path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; @@ -85,8 +98,8 @@ module sonic-dhcpv4-relay { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } type leafref { path "/loopback:sonic-loopback-interface/loopback:LOOPBACK_INTERFACE/loopback:LOOPBACK_INTERFACE_LIST/loopback:name"; diff --git a/src/sonic-yang-models/yang-models/sonic-mclag.yang b/src/sonic-yang-models/yang-models/sonic-mclag.yang index f7b94f85eaa..336f58c5255 100644 --- a/src/sonic-yang-models/yang-models/sonic-mclag.yang +++ b/src/sonic-yang-models/yang-models/sonic-mclag.yang @@ -15,10 +15,9 @@ module sonic-mclag { prefix lag; } - // Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. - //import sonic-vlan { - // prefix vlan; - //} + import sonic-vlan { + prefix vlan; + } organization "SONiC"; @@ -29,6 +28,13 @@ module sonic-mclag { description "SONIC MCLAG"; + revision 2026-11-19 { + description + "MCLAG_UNIQUE_IP if_name names its VLAN by leafref to VLAN, so a row cannot name a + VLAN that does not exist and the VLAN's removal finds the row that uses it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2019-10-01 { description "Initial revision."; @@ -134,7 +140,7 @@ module sonic-mclag { error-app-tag mclag-invalid; } - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern + // The VLAN_INTERFACE address check below is not enabled. //must // "count(/vlan:sonic-vlan/vlan:VLAN_INTERFACE/vlan:VLAN_INTERFACE_IPPREFIX_LIST[vlan:name=current()/if_name]) = 0" { // error-message "remove configured ip/v6 address and reconfigure after separate ip configuration"; @@ -142,13 +148,12 @@ module sonic-mclag { // } leaf if_name { - description "Vlan interface name on which MCLAG unique ip config is done"; - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - //type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - //} - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } + description "The VLAN on which MCLAG unique ip config is done; it must exist in VLAN."; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } leaf unique_ip { diff --git a/src/sonic-yang-models/yang-models/sonic-neigh.yang b/src/sonic-yang-models/yang-models/sonic-neigh.yang index 0d3271ff174..b5629cde49f 100644 --- a/src/sonic-yang-models/yang-models/sonic-neigh.yang +++ b/src/sonic-yang-models/yang-models/sonic-neigh.yang @@ -18,16 +18,22 @@ module sonic-neigh { import sonic-port { prefix port; } - // TODO: Uncomment the following lines when sonic-vlan.yang is available - // import sonic-vlan { - // prefix svlan; - // } + + import sonic-vlan { + prefix svlan; + } organization "SONiC"; contact "SONiC"; description "NEIGH YANG Module for SONiC OS"; + revision 2026-11-19 { + description + "NEIGH port names a VLAN by leafref to VLAN, so a neighbor cannot name a + VLAN that does not exist and the VLAN's removal finds the neighbors on it."; + } + revision 2023-03-31 { description "Initial Revision"; } @@ -39,7 +45,9 @@ module sonic-neigh { key "port neighbor"; leaf port { - description "Neighbor interface ex. Vlan1000, PortChannel1024"; + description + "The port channel, port or VLAN the neighbor is on, ex. Vlan1000 or + PortChannel1024; it must exist in its table."; type union { type leafref { path /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name; @@ -47,13 +55,9 @@ module sonic-neigh { type leafref { path /port:sonic-port/port:PORT/port:PORT_LIST/port:name; } - type string { - pattern "Vlan[0-9]+"; + type leafref { + path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; } - // TODO: Uncomment the following lines when sonic-vlan.yang is available - // type leafref { - // path "/svlan:sonic-vlan/svlan:VLAN/svlan:VLAN_LIST/svlan:name"; - // } } } diff --git a/src/sonic-yang-models/yang-models/sonic-route-map.yang b/src/sonic-yang-models/yang-models/sonic-route-map.yang index 6475259dd00..59c0aa27307 100644 --- a/src/sonic-yang-models/yang-models/sonic-route-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-route-map.yang @@ -18,10 +18,9 @@ module sonic-route-map { import sonic-routing-policy-sets { prefix rpolsets; } -// Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. -// import sonic-vlan { -// prefix vlan; -// } + import sonic-vlan { + prefix vlan; + } import sonic-vrf { prefix vrf; @@ -40,6 +39,14 @@ module sonic-route-map { description "SONIC Route map YANG"; + revision 2026-11-19 { + description + "match_interface and match_neighbor name a VLAN by leafref to VLAN, so a route map + cannot match a VLAN that does not exist and the VLAN's removal finds the route maps + that match it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2021-02-26 { description "Initial revision."; @@ -56,14 +63,12 @@ module sonic-route-map { type leafref { path "/loopback:sonic-loopback-interface/loopback:LOOPBACK_INTERFACE/loopback:LOOPBACK_INTERFACE_LIST/loopback:name"; } - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - //type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - //} - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } + description + "A port, port channel, loopback or VLAN; it must exist in its table."; } typedef bgp-origin-attr-type { @@ -156,6 +161,9 @@ module sonic-route-map { } leaf match_interface{ + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type route-map-intf; description "Match based on interface"; } @@ -201,6 +209,9 @@ module sonic-route-map { } leaf-list match_neighbor { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type inet:ip-address; type leafref { @@ -209,17 +220,14 @@ module sonic-route-map { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - // Comment VLAN leaf reference here until libyang back-links issue is resolved and use VLAN string pattern - //type leafref { - // path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - //} - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } ordered-by user; description - "IP addresse or interface for match operation."; + "The neighbor address, or the port, port channel or VLAN of an unnumbered + neighbor, to match; the interface must exist in its table."; max-elements 1; } diff --git a/src/sonic-yang-models/yang-models/sonic-smart-switch.yang b/src/sonic-yang-models/yang-models/sonic-smart-switch.yang index 5254015d4eb..7e1ad94b10f 100644 --- a/src/sonic-yang-models/yang-models/sonic-smart-switch.yang +++ b/src/sonic-yang-models/yang-models/sonic-smart-switch.yang @@ -17,6 +17,10 @@ module sonic-smart-switch { prefix sonic-vnet; } + import sonic-vlan { + prefix vlan; + } + organization "SONiC"; @@ -53,6 +57,13 @@ module sonic-smart-switch { description "Add dpu_vnet, dpu_vlan (string). Allow underscore in dpu name."; } + revision 2026-11-19 { + description + "DASH_HA_GLOBAL_CONFIG dpu_vlan names its VLAN by leafref to VLAN, so it + cannot name a VLAN that does not exist and the VLAN's removal finds the + setting that uses it."; + } + container sonic-smart-switch { container MID_PLANE_BRIDGE { @@ -308,9 +319,11 @@ module sonic-smart-switch { } leaf dpu_vlan { - description "DPU VLAN identifier, name of the VLAN"; - type string { - length "1..255"; + description + "The VLAN hamgrd resolves the DPU PA address on; it must exist + in VLAN."; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } } diff --git a/src/sonic-yang-models/yang-models/sonic-spanning-tree.yang b/src/sonic-yang-models/yang-models/sonic-spanning-tree.yang index 5f0ef0a9cbf..fae47ca660c 100644 --- a/src/sonic-yang-models/yang-models/sonic-spanning-tree.yang +++ b/src/sonic-yang-models/yang-models/sonic-spanning-tree.yang @@ -10,6 +10,10 @@ module sonic-spanning-tree { } */ + import sonic-vlan { + prefix vlan; + } + organization "SONiC"; @@ -19,6 +23,13 @@ module sonic-spanning-tree { description "YANG model for Spanning Tree Protocol (STP) in SONiC, supporting PVST and MSTP"; + revision 2026-11-19 { + description + "STP_VLAN name names its VLAN by leafref to VLAN, so a row cannot + name a VLAN that does not exist and the VLAN's removal finds the + row that uses it."; + } + revision 2025-03-15 { description "Initial YANG model written for PVST & MSTP configurations xFlow & BRCM"; @@ -176,9 +187,12 @@ module sonic-spanning-tree { "List of VLAN STP configurations"; leaf name { - type string; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + } description - "Vlan identifier in format 'Vlan'"; + "The VLAN this row configures, in format 'Vlan'; it must exist + in VLAN."; } leaf vlanid { diff --git a/src/sonic-yang-models/yang-models/sonic-system-radius.yang b/src/sonic-yang-models/yang-models/sonic-system-radius.yang index 4b5212b5b7d..e6e922b6200 100644 --- a/src/sonic-yang-models/yang-models/sonic-system-radius.yang +++ b/src/sonic-yang-models/yang-models/sonic-system-radius.yang @@ -15,10 +15,9 @@ module sonic-system-radius { prefix lag; } -// Comment sonic-vlan import here until libyang back-links issue is resolved for VLAN leaf reference. -// import sonic-vlan { -// prefix vlan; -// } + import sonic-vlan { + prefix vlan; + } import sonic-loopback-interface { prefix loopback; @@ -31,6 +30,13 @@ module sonic-system-radius { description "Remote Authentication Dial-In User Service (RADIUS) YANG module for SONiC OS."; + revision 2026-11-19 { + description + "RADIUS_SERVER src_intf names a VLAN by leafref to VLAN, so a server cannot name a + VLAN that does not exist and the VLAN's removal finds the servers that use it. + Vlan4095, which the VLAN name pattern admits, stays refused."; + } + revision 2022-11-11 { description "Initial revision."; } @@ -181,6 +187,9 @@ module sonic-system-radius { } leaf src_intf { + must "current() != 'Vlan4095'" { + error-message "Vlan4095 is reserved; a VLAN ID runs up to 4094."; + } type union { type leafref { path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; @@ -188,10 +197,9 @@ module sonic-system-radius { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern 'Vlan([0-9]{1,3}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + type leafref { + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; } - type leafref { path "/loopback:sonic-loopback-interface/loopback:LOOPBACK_INTERFACE/loopback:LOOPBACK_INTERFACE_LIST/loopback:name"; } @@ -199,7 +207,9 @@ module sonic-system-radius { path "/mgmt-port:sonic-mgmt_port/mgmt-port:MGMT_PORT/mgmt-port:MGMT_PORT_LIST/mgmt-port:name"; } } - description "Source interface to use for RADIUS server communication."; + description + "The port, port channel, VLAN, loopback or management port to source + RADIUS server communication from; it must exist in its table."; } } } From 934c9de5a80f7fadf8bcee981e0b829188e31cd6 Mon Sep 17 00:00:00 2001 From: Xichen Lin Date: Fri, 27 Nov 2026 08:40:31 +0000 Subject: [PATCH 2/2] [yang] Require matching VLAN IP for DHCP server configuration Reject DHCP server configuration unless the same VLAN has a configured VLAN_INTERFACE prefix of the corresponding address family. Apply the dependency to legacy VLAN fields and native DHCPv4/DHCPv6 relay tables. Keep vlanid optional and preserve bare VLANs without DHCP servers. Add focused dependency tests and provide valid IP dependencies in existing fixtures so their original checks remain meaningful. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7a24f7e2-7126-444f-bc0c-4ee2c7d97330 Signed-off-by: Xichen Lin --- .../yang_model_tests/tests/dhcpv4_relay.json | 18 + .../yang_model_tests/tests/dhcpv6_relay.json | 21 ++ .../tests/yang_model_tests/tests/vlan.json | 39 ++ .../tests_config/dhcpv4_relay.json | 335 ++++++++++++++++++ .../tests_config/dhcpv6_relay.json | 145 ++++++++ .../yang_model_tests/tests_config/vlan.json | 238 ++++++++++++- .../yang-models/sonic-dhcpv4-relay.yang | 8 + .../yang-models/sonic-dhcpv6-relay.yang | 12 + .../yang-models/sonic-vlan.yang | 12 + 9 files changed, 809 insertions(+), 19 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json index ed5d80cb7fc..01641acf0fc 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv4_relay.json @@ -68,5 +68,23 @@ "eStr": [ "Vlan4095 is reserved" ] + }, + "DHCPv4_RELAY_WITH_NO_IP": { + "desc": "Reject DHCPV4_RELAY.dhcpv4_servers with no ip.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] + }, + "DHCPv4_RELAY_WITH_WRONG_IP_FAMILY": { + "desc": "Reject DHCPV4_RELAY.dhcpv4_servers with wrong ip family.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] + }, + "DHCPv4_RELAY_WITH_IP_ON_OTHER_VLAN": { + "desc": "Reject DHCPV4_RELAY.dhcpv4_servers with ip on other vlan.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json index fb05271f99b..74fdf083d2c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json @@ -9,5 +9,26 @@ "DHCPv6_OPTION_WITH_INVALID_BOOLEAN_TYPE": { "desc": "Add dhcpv6 option with invalid option boolean types.", "eStrKey": "Pattern" + }, + "DHCPV6_RELAY_WITH_NO_IP": { + "desc": "Reject DHCP_RELAY.dhcpv6_servers with no ip.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "DHCPV6_RELAY_WITH_WRONG_IP_FAMILY": { + "desc": "Reject DHCP_RELAY.dhcpv6_servers with wrong ip family.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "DHCPV6_RELAY_WITH_IP_ON_OTHER_VLAN": { + "desc": "Reject DHCP_RELAY.dhcpv6_servers with ip on other vlan.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "DHCPV6_RELAY_OPTIONS_WITHOUT_SERVERS": { + "desc": "Allow DHCPv6 relay options without an IP when no DHCPv6 server is configured." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json index be8405dbd9e..98fff3ed033 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json @@ -168,5 +168,44 @@ "VLAN_INTERFACE_WITH_MISSING_VNET": { "desc": "Attempt to reference VNET name without the VNET being present.", "eStrKey": "LeafRef" + }, + "VLAN_DHCPV4_WITH_NO_IP": { + "desc": "Reject VLAN.dhcp_servers with no ip.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] + }, + "VLAN_DHCPV4_WITH_WRONG_IP_FAMILY": { + "desc": "Reject VLAN.dhcp_servers with wrong ip family.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] + }, + "VLAN_DHCPV4_WITH_IP_ON_OTHER_VLAN": { + "desc": "Reject VLAN.dhcp_servers with ip on other vlan.", + "eStr": [ + "DHCPv4 servers require an IPv4 prefix on the same VLAN" + ] + }, + "VLAN_DHCPV6_WITH_NO_IP": { + "desc": "Reject VLAN.dhcpv6_servers with no ip.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "VLAN_DHCPV6_WITH_WRONG_IP_FAMILY": { + "desc": "Reject VLAN.dhcpv6_servers with wrong ip family.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "VLAN_DHCPV6_WITH_IP_ON_OTHER_VLAN": { + "desc": "Reject VLAN.dhcpv6_servers with ip on other vlan.", + "eStr": [ + "DHCPv6 servers require an IPv6 prefix on the same VLAN" + ] + }, + "VLAN_EMPTY_DHCP_SERVER_LISTS_WITHOUT_IP": { + "desc": "Allow a bare VLAN without an IP when both DHCP server lists are empty." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json index d39008b5db1..16acd38b1b9 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv4_relay.json @@ -19,6 +19,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -43,6 +56,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -89,6 +115,19 @@ "name": "Vlan888" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan888", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan888" + } + ] } } }, @@ -123,6 +162,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -147,6 +199,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -171,6 +236,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -195,6 +273,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -219,6 +310,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -243,6 +347,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -308,6 +425,19 @@ "name": "Vlan888" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan888", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan888" + } + ] } } }, @@ -353,6 +483,19 @@ "name": "Vlan888" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan888", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan888" + } + ] } } }, @@ -398,6 +541,19 @@ "name": "Vlan888" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan888", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan888" + } + ] } } }, @@ -443,6 +599,19 @@ "name": "Vlan888" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan888", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan888" + } + ] } } }, @@ -467,6 +636,19 @@ "name": "Vlan999" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan999", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan999" + } + ] } } }, @@ -509,6 +691,19 @@ "name": "Vlan778" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -534,6 +729,19 @@ "name": "Vlan777" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] } } }, @@ -557,6 +765,19 @@ "name": "Vlan4095" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan4095", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan4095" + } + ] } } }, @@ -585,6 +806,120 @@ "name": "Vlan4095" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan777", + "ip-prefix": "192.0.2.1/24" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan777" + } + ] + } + } + }, + "DHCPv4_RELAY_WITH_NO_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + } + ] + } + }, + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv4_servers": [ + "192.0.2.200" + ] + } + ] + } + } + }, + "DHCPv4_RELAY_WITH_WRONG_IP_FAMILY": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "2001:db8::1/64" + } + ] + } + }, + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv4_servers": [ + "192.0.2.200" + ] + } + ] + } + } + }, + "DHCPv4_RELAY_WITH_IP_ON_OTHER_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + }, + { + "name": "Vlan200" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan200" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan200", + "ip-prefix": "192.0.2.1/24" + } + ] + } + }, + "sonic-dhcpv4-relay:sonic-dhcpv4-relay": { + "sonic-dhcpv4-relay:DHCPV4_RELAY": { + "DHCPV4_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv4_servers": [ + "192.0.2.200" + ] + } + ] } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json index 0547b06fbb7..f3998d6b68d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json @@ -11,6 +11,28 @@ } ] } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan500" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan500" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan500", + "ip-prefix": "2001:db8::1/64" + } + ] + } } }, "DHCPV6_SERVER_VALID_FORMAT": { @@ -97,5 +119,128 @@ ] } } + }, + "DHCPV6_RELAY_WITH_NO_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + } + ] + } + }, + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv6_servers": [ + "2001:db8::200" + ] + } + ] + } + } + }, + "DHCPV6_RELAY_WITH_WRONG_IP_FAMILY": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "192.0.2.1/24" + } + ] + } + }, + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv6_servers": [ + "2001:db8::200" + ] + } + ] + } + } + }, + "DHCPV6_RELAY_WITH_IP_ON_OTHER_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100 + }, + { + "name": "Vlan200" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan200" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan200", + "ip-prefix": "2001:db8::1/64" + } + ] + } + }, + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "name": "Vlan100", + "dhcpv6_servers": [ + "2001:db8::200" + ] + } + ] + } + } + }, + "DHCPV6_RELAY_OPTIONS_WITHOUT_SERVERS": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100" + } + ] + } + }, + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "name": "Vlan100", + "rfc6939_support": "true", + "interface_id": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json index 54f1dcfed01..d9253dee2fd 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json @@ -25,6 +25,26 @@ "mac": "00:aa:bb:cc:dd:ee" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + }, + { + "name": "Vlan200" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "192.0.2.1/24" + }, + { + "name": "Vlan200", + "ip-prefix": "198.51.100.1/24" + } + ] } } }, @@ -35,9 +55,6 @@ { "admin_status": "up", "description": "server_vlan", - "dhcp_servers": [ - "10.186.72.56" - ], "mtu": "9100", "name": "Vlan8090" } @@ -52,9 +69,6 @@ { "admin_status": "up", "description": "server_vlan", - "dhcp_servers": [ - "10.186.72.56" - ], "mtu": "9100", "name": "Vlan123456789012" } @@ -76,6 +90,19 @@ "name": "Vlan100" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "192.0.2.1/24" + } + ] } } }, @@ -93,6 +120,19 @@ "name": "Vlan500" } ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan500" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan500", + "ip-prefix": "2001:db8::1/64" + } + ] } } }, @@ -314,19 +354,18 @@ } }, "ALL_VLAN_TEST": { - "sonic-vlan:sonic-vlan": { - "sonic-vlan:VLAN": { - "VLAN_LIST": [{ - "name": "Vlan1-4094", - "description": "server_vlan", - "dhcp_servers": [ - "10.186.72.56" - ], - "mtu": "9100", - "admin_status": "up" - }] - } - } + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1-4094", + "description": "server_vlan", + "mtu": "9100", + "admin_status": "up" + } + ] + } + } }, "VLAN_INTERFACE_WRONG_NAT_ZONE_RANGE": { "sonic-port:sonic-port": { @@ -1586,5 +1625,166 @@ ] } } + }, + "VLAN_DHCPV4_WITH_NO_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcp_servers": [ + "192.0.2.200" + ] + } + ] + } + } + }, + "VLAN_DHCPV4_WITH_WRONG_IP_FAMILY": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcp_servers": [ + "192.0.2.200" + ] + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "2001:db8::1/64" + } + ] + } + } + }, + "VLAN_DHCPV4_WITH_IP_ON_OTHER_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcp_servers": [ + "192.0.2.200" + ] + }, + { + "name": "Vlan200" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan200" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan200", + "ip-prefix": "192.0.2.1/24" + } + ] + } + } + }, + "VLAN_DHCPV6_WITH_NO_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcpv6_servers": [ + "2001:db8::200" + ] + } + ] + } + } + }, + "VLAN_DHCPV6_WITH_WRONG_IP_FAMILY": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcpv6_servers": [ + "2001:db8::200" + ] + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan100", + "ip-prefix": "192.0.2.1/24" + } + ] + } + } + }, + "VLAN_DHCPV6_WITH_IP_ON_OTHER_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "vlanid": 100, + "dhcpv6_servers": [ + "2001:db8::200" + ] + }, + { + "name": "Vlan200" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan200" + } + ], + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Vlan200", + "ip-prefix": "2001:db8::1/64" + } + ] + } + } + }, + "VLAN_EMPTY_DHCP_SERVER_LISTS_WITHOUT_IP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan100", + "dhcp_servers": [], + "dhcpv6_servers": [] + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang index b9db7036886..33e59216821 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv4-relay.yang @@ -36,6 +36,10 @@ module sonic-dhcpv4-relay { contact "SONiC"; description "DHCPv4 Relay yang Module for SONiC OS"; + revision 2026-11-27 { + description "Require a matching VLAN IPv4 address for DHCP relay"; + } + revision 2026-11-19 { description "name and source_interface name a VLAN by leafref to VLAN, so a relay cannot name a @@ -68,6 +72,10 @@ module sonic-dhcpv4-relay { description "Server IPv4 address list"; min-elements 1; type inet:ipv4-address; + must "/vlan:sonic-vlan/vlan:VLAN_INTERFACE/vlan:VLAN_INTERFACE_IPPREFIX_LIST + [vlan:name=current()/../name and not(contains(vlan:ip-prefix, ':'))]" { + error-message "DHCPv4 servers require an IPv4 prefix on the same VLAN"; + } } leaf server_vrf { diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang index e2a118ae756..a1789b7501a 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -10,12 +10,20 @@ module sonic-dhcpv6-relay { prefix inet; } + import sonic-vlan { + prefix vlan; + } + organization "SONiC"; contact "SONiC"; description "DHCPv6 Relay yang Module for SONiC OS"; + revision 2026-11-27 { + description "Require a matching VLAN IPv6 address for DHCP relay"; + } + revision 2021-10-30 { description "First Revision"; } @@ -39,6 +47,10 @@ module sonic-dhcpv6-relay { description "Configure the dhcp v6 servers"; type inet:ipv6-address; ordered-by user; + must "/vlan:sonic-vlan/vlan:VLAN_INTERFACE/vlan:VLAN_INTERFACE_IPPREFIX_LIST + [vlan:name=current()/../name and contains(vlan:ip-prefix, ':')]" { + error-message "DHCPv6 servers require an IPv6 prefix on the same VLAN"; + } } leaf rfc6939_support { diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index d23e6f2c4ff..68666acda6c 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -47,6 +47,10 @@ module sonic-vlan { description "VLAN yang Module for SONiC OS"; + revision 2026-11-27 { + description "Require a matching VLAN IP address for DHCP server configuration"; + } + revision 2026-10-30 { description "Count priority-tagged VLAN members in the one-untagged-VLAN-per-port check."; } @@ -269,12 +273,20 @@ module sonic-vlan { description "Configure the dhcp v4 servers"; type inet:ip-address; ordered-by user; + must "/vlan:sonic-vlan/vlan:VLAN_INTERFACE/vlan:VLAN_INTERFACE_IPPREFIX_LIST + [vlan:name=current()/../name and not(contains(vlan:ip-prefix, ':'))]" { + error-message "DHCPv4 servers require an IPv4 prefix on the same VLAN"; + } } leaf-list dhcpv6_servers { description "Configure the dhcp v6 servers"; type inet:ipv6-address; ordered-by user; + must "/vlan:sonic-vlan/vlan:VLAN_INTERFACE/vlan:VLAN_INTERFACE_IPPREFIX_LIST + [vlan:name=current()/../name and contains(vlan:ip-prefix, ':')]" { + error-message "DHCPv6 servers require an IPv6 prefix on the same VLAN"; + } } leaf mtu {