From de03b224b03e353b511b8883b44bc470cb59dfa3 Mon Sep 17 00:00:00 2001 From: miatao Date: Wed, 22 Jul 2026 04:14:12 +0000 Subject: [PATCH 1/3] [sonic-yang-models]: Add VNet name support to BGP_NEIGHBOR YANG model Signed-off-by: miatao --- src/sonic-yang-models/doc/Configuration.md | 12 ++++ .../tests/files/sample_config_db.json | 9 +++ .../tests/yang_model_tests/tests/bgp.json | 7 +++ .../yang_model_tests/tests_config/bgp.json | 60 ++++++++++++++++++- .../yang-models/sonic-bgp-neighbor.yang | 31 ++++++++-- 5 files changed, 111 insertions(+), 8 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 90e0292ff8..c56c5873e4 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -520,6 +520,12 @@ attributes include remote AS number, neighbor router name, and local peering address. Dynamic neighbor is also supported by defining peer group name and IP ranges in **BGP_PEER_RANGE** table. +The table key format is `vrf_name|neighbor` where `vrf_name` can be: +- A VRF name (e.g. `default`, `Vrf1`) referencing an entry in **BGP_GLOBALS** +- A VNet name (e.g. `Vnet1`) referencing an entry in **VNET**, for overlay BGP neighbors + +Example: `BGP_NEIGHBOR|Vnet1|10.0.0.0` creates a BGP neighbor under VNet `Vnet1`. + ``` { "BGP_NEIGHBOR": { @@ -542,6 +548,12 @@ group name and IP ranges in **BGP_PEER_RANGE** table. "holdtime": "10", "asn": "64600", "keepalive": "3" + }, + + "Vnet1|10.0.0.0": { + "asn": 65100, + "name": "overlay-peer", + "admin_status": "up" } "BGP_PEER_RANGE": { 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 3f683c3b99..3aba6226c9 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1949,12 +1949,21 @@ "asn": "65100", "name": "bgp peer 65100", "ebgp_multihop_ttl": "3" + }, + "Vnet55|10.0.0.0": { + "asn": "65300", + "name": "overlay-peer", + "admin_status": "up" } }, "BGP_NEIGHBOR_AF": { "default|192.168.1.1|ipv4_unicast": { "route_map_in": [ "map1" ], "route_map_out": [ "map1" ] + }, + "Vnet55|10.0.0.0|ipv4_unicast": { + "admin_status": "up", + "send_default_route": false } }, "BGP_PEER_GROUP": { 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 d98ca3796d..9fb22eb433 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 @@ -32,6 +32,13 @@ "BGP_NEIGHBOR_ALL_VALID": { "desc": "Configure BGP neighbor table." }, + "BGP_NEIGHBOR_VNET_VALID": { + "desc": "Configure BGP neighbor with a VNet name as vrf_name." + }, + "BGP_NEIGHBOR_NEG_VNET_NOT_EXIST": { + "desc": "BGP neighbor vrf_name references a non-existing VNet.", + "eStrKey": "LeafRef" + }, "BGP_PEERGROUP_ALL_VALID": { "desc": "Configure BGP peer group table." }, 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 99ea273c12..73188d29ee 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 @@ -549,6 +549,64 @@ } } }, + + "BGP_NEIGHBOR_VNET_VALID": { + "sonic-vxlan:sonic-vxlan": { + "sonic-vxlan:VXLAN_TUNNEL": { + "VXLAN_TUNNEL_LIST": [ + { + "name": "vtep1", + "src_ip": "1.2.3.4" + }] + } + }, + "sonic-vnet:sonic-vnet": { + "sonic-vnet:VNET": { + "VNET_LIST": [ + { + "name": "Vnet1", + "vxlan_tunnel": "vtep1", + "vni": "10000" + }] + } + }, + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "Vnet1", + "neighbor": "10.0.0.0", + "asn": 65100, + "name": "overlay-peer", + "admin_status": "up" + }] + }, + "sonic-bgp-neighbor:BGP_NEIGHBOR_AF": { + "BGP_NEIGHBOR_AF_LIST": [ + { + "vrf_name": "Vnet1", + "neighbor": "10.0.0.0", + "afi_safi": "ipv4_unicast", + "admin_status": "up" + }] + } + } + }, + + "BGP_NEIGHBOR_NEG_VNET_NOT_EXIST": { + "sonic-bgp-neighbor:sonic-bgp-neighbor": { + "sonic-bgp-neighbor:BGP_NEIGHBOR": { + "BGP_NEIGHBOR_LIST": [ + { + "vrf_name": "Vnet1", + "neighbor": "10.0.0.0", + "asn": 65100, + "name": "overlay-peer" + }] + } + } + }, + "BGP_GLOBAL_NEG_VRF_NOT_EXIST": { "sonic-bgp-global:sonic-bgp-global": { "sonic-bgp-global:BGP_GLOBALS": { @@ -561,8 +619,6 @@ } } }, - - "BGP_GLOBAL_AF_NEG_GLOBAL_NOT_EXIST": { "sonic-bgp-global:sonic-bgp-global": { "sonic-bgp-global:BGP_GLOBALS_AF": { "BGP_GLOBALS_AF_LIST": [ 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 694980ee1a..c14058c299 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -40,6 +40,10 @@ module sonic-bgp-neighbor { prefix bgppg; } + import sonic-vnet { + prefix svnet; + } + organization "SONiC"; @@ -49,6 +53,11 @@ module sonic-bgp-neighbor { description "SONIC BGP Neighbor"; + revision 2026-07-22 { + description + "Add VNet name support to BGP_NEIGHBOR_LIST and BGP_NEIGHBOR_AF_LIST vrf_name leaf."; + } + revision 2021-02-26 { description "Initial revision."; @@ -94,10 +103,15 @@ module sonic-bgp-neighbor { key "vrf_name neighbor"; leaf vrf_name { - type leafref { - path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; + type union { + type leafref { + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; + } + type leafref { + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; + } } - description "Network-instance/VRF name"; + description "Network-instance/VRF name or VNet name (e.g. Vnet1) for overlay BGP neighbors"; } leaf neighbor { @@ -136,10 +150,15 @@ module sonic-bgp-neighbor { key "vrf_name neighbor afi_safi"; leaf vrf_name { - type leafref { - path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; + type union { + type leafref { + path "/bgpg:sonic-bgp-global/bgpg:BGP_GLOBALS/bgpg:BGP_GLOBALS_LIST/bgpg:vrf_name"; + } + type leafref { + path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"; + } } - description "Network-instance/VRF name"; + description "Network-instance/VRF name or VNet name (e.g. Vnet1) for overlay BGP neighbors"; } leaf neighbor { From e7da5452dd13cd5b8b09c336580d1c5e19028f17 Mon Sep 17 00:00:00 2001 From: miatao Date: Wed, 22 Jul 2026 18:51:47 +0000 Subject: [PATCH 2/3] Fix copilot comments Signed-off-by: miatao --- src/sonic-yang-models/doc/Configuration.md | 11 +++++------ .../tests/files/sample_config_db.json | 2 +- .../tests/yang_model_tests/tests_config/bgp.json | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index c56c5873e4..2722f12824 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -520,11 +520,10 @@ attributes include remote AS number, neighbor router name, and local peering address. Dynamic neighbor is also supported by defining peer group name and IP ranges in **BGP_PEER_RANGE** table. -The table key format is `vrf_name|neighbor` where `vrf_name` can be: -- A VRF name (e.g. `default`, `Vrf1`) referencing an entry in **BGP_GLOBALS** -- A VNet name (e.g. `Vnet1`) referencing an entry in **VNET**, for overlay BGP neighbors - -Example: `BGP_NEIGHBOR|Vnet1|10.0.0.0` creates a BGP neighbor under VNet `Vnet1`. +The table key can be a plain neighbor IP (e.g. `BGP_NEIGHBOR|10.0.0.61`) or a +`vrf_name|neighbor` pair (e.g. `BGP_NEIGHBOR|default|10.0.0.61`). In the second +form, `vrf_name` accepts a VRF name (e.g. `default`, `Vrf1`) or a VNet name +(e.g. `Vnet1`) for overlay BGP neighbors. ``` { @@ -540,7 +539,7 @@ Example: `BGP_NEIGHBOR|Vnet1|10.0.0.0` creates a BGP neighbor under VNet `Vnet1` "name": "ARISTA09T0" }, - "10.0.0.63": { + "default|10.0.0.63": { "rrclient": "0", "name": "ARISTA04T1", "local_addr": "10.0.0.62", 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 3aba6226c9..1168b3c868 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1963,7 +1963,7 @@ }, "Vnet55|10.0.0.0|ipv4_unicast": { "admin_status": "up", - "send_default_route": false + "send_default_route": "false" } }, "BGP_PEER_GROUP": { 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 73188d29ee..3df9a73491 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 @@ -619,6 +619,8 @@ } } }, + + "BGP_GLOBAL_AF_NEG_GLOBAL_NOT_EXIST": { "sonic-bgp-global:sonic-bgp-global": { "sonic-bgp-global:BGP_GLOBALS_AF": { "BGP_GLOBALS_AF_LIST": [ From 3df6dbb7056cb416f009894c303c807d3cf9854b Mon Sep 17 00:00:00 2001 From: miatao Date: Wed, 22 Jul 2026 22:08:05 +0000 Subject: [PATCH 3/3] Trigger CI