From 0457a2785300877fa2aaeb87c69f9bcba1054b81 Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Thu, 20 Mar 2025 17:32:44 +0000 Subject: [PATCH] [YANG] sonic-neigh.yang need support portchannel #### Why I did it NEIGH need to support PORTCHANNEL for t1 topology when VLAN is non-existent. ##### Work item tracking - Microsoft ADO **(number only)**: 31872308 #### How I did it Add portchannel to port as an alllowed leafref #### How to verify it unit test #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) - [ ] - [ ] #### Description for the changelog #### Link to config_db schema for YANG module changes #### A picture of a cute animal (not mandatory but encouraged) --- .../tests/yang_model_tests/tests/neigh.json | 13 +++- .../yang_model_tests/tests_config/neigh.json | 65 +++++++++++++++++-- .../yang-models/sonic-neigh.yang | 27 +++++--- 3 files changed, 89 insertions(+), 16 deletions(-) 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 33f87167d680..6ed1e7aa2999 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 @@ -10,6 +10,17 @@ "NEIGH_INVALID_VLAN": { "desc": "Load NEIGH missing VLAN", - "eStr": ["does not satisfy the constraint"] + "eStrKey": "InvalidValue", + "eStr": ["port"] + }, + + "VALID_NEIGH_PORTCHANNEL": { + "desc": "Load valid PORTCHANNEL" + }, + + "NEIGH_INVALID_PORTCHANNEL": { + "desc": "Load NEIGH missing PORTCHANNEL", + "eStrKey": "InvalidValue", + "eStr": ["port"] } } 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 165bbb6b8649..b2d532e71d48 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 @@ -13,13 +13,13 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.3", "neigh": "00:02:02:03:04:05", "family": "IPv4" }, { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.4", "family": "IPv4" } @@ -42,7 +42,7 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "Vlan1000", + "port": "Vlan1000", "neigh": "00:02:02:03:04:05", "family": "IPv4" } @@ -56,18 +56,73 @@ "sonic-neigh:NEIGH": { "NEIGH_LIST": [ { - "vlan": "INVALIDVlan", + "port": "INVALIDVlan", "neighbor": "100.1.1.3", "neigh": "00:02:02:03:04:05", "family": "IPv4" }, { - "vlan": "Vlan1000", + "port": "Vlan1000", "neighbor": "100.1.1.4", "family": "IPv4" } ] } } + }, + + "VALID_NEIGH_PORTCHANNEL": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "port": "PortChannel1024", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + }, + { + "port": "PortChannel1024", + "neighbor": "100.1.1.4", + "family": "IPv4" + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "name": "PortChannel1024" + } + ] + } + } + }, + + "NEIGH_INVALID_PORTCHANNEL": { + "sonic-neigh:sonic-neigh": { + "sonic-neigh:NEIGH": { + "NEIGH_LIST": [ + { + "port": "PortChannel10", + "neighbor": "100.1.1.3", + "neigh": "00:02:02:03:04:05", + "family": "IPv4" + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "name": "PortChannel11" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-neigh.yang b/src/sonic-yang-models/yang-models/sonic-neigh.yang index 32e6065b16b7..85220ee7f216 100644 --- a/src/sonic-yang-models/yang-models/sonic-neigh.yang +++ b/src/sonic-yang-models/yang-models/sonic-neigh.yang @@ -11,6 +11,9 @@ module sonic-neigh { prefix yang; } + import sonic-portchannel { + prefix lag; + } // TODO: Uncomment the following lines when sonic-vlan.yang is available // import sonic-vlan { // prefix svlan; @@ -29,18 +32,22 @@ module sonic-neigh { container NEIGH { description "NEIGH configuration"; list NEIGH_LIST { - key "vlan neighbor"; + key "port neighbor"; - leaf vlan { - // TODO: Remove the following lines when sonic-vlan.yang is available - description "Neighbor Vlan interface ex. Vlan1000"; - type string { - pattern "Vlan[0-9]+"; + leaf port { + description "Neighbor interface ex. Vlan1000, PortChannel1024"; + type union { + type leafref { + path /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name; + } + type string { + pattern "Vlan[0-9]+"; + } + // TODO: Uncomment the following lines when sonic-vlan.yang is available + // 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"; - // } } leaf neighbor {