From b00d1ccde3b5d4911d22eeace76c90c7adf388d5 Mon Sep 17 00:00:00 2001 From: miatao Date: Wed, 22 Jul 2026 04:14:12 +0000 Subject: [PATCH 1/4] [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/yang_model_tests/tests/bgp.json | 7 +++ .../yang_model_tests/tests_config/bgp.json | 60 ++++++++++++++++++- .../yang-models/sonic-bgp-neighbor.yang | 31 ++++++++-- 4 files changed, 102 insertions(+), 8 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 827ae61150..2764aa5894 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -502,6 +502,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": { @@ -524,6 +530,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/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index d130d061d6..e5093eda37 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 @@ -25,6 +25,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 83980b054c..9db0202634 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 @@ -507,6 +507,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": { @@ -519,8 +577,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 368b52d457..5b1859098f 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 { @@ -139,10 +153,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 4760b899388338ed9c66cb4a3649d1b7539523fb Mon Sep 17 00:00:00 2001 From: miatao Date: Wed, 22 Jul 2026 18:51:47 +0000 Subject: [PATCH 2/4] Fix copilot comments Signed-off-by: miatao --- src/sonic-yang-models/doc/Configuration.md | 11 +++++------ .../tests/yang_model_tests/tests_config/bgp.json | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 2764aa5894..bbc55042d0 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -502,11 +502,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. ``` { @@ -522,7 +521,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/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index 9db0202634..22fca56085 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 @@ -577,6 +577,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 75968abfeb03f0935252206b12c2ce946c3d6c93 Mon Sep 17 00:00:00 2001 From: miatao Date: Fri, 24 Jul 2026 04:21:48 +0000 Subject: [PATCH 3/4] Fix Nina's comments Signed-off-by: miatao --- src/sonic-yang-models/doc/Configuration.md | 1 + src/sonic-yang-models/tests/files/sample_config_db.json | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index bbc55042d0..d905a5760a 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -534,6 +534,7 @@ form, `vrf_name` accepts a VRF name (e.g. `default`, `Vrf1`) or a VNet name "Vnet1|10.0.0.0": { "asn": 65100, "name": "overlay-peer", + "local_addr": "10.1.0.1", "admin_status": "up" } 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 63716b51b1..709a6b36c5 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1922,10 +1922,19 @@ "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": { + }, + "Vnet55|10.0.0.0|ipv4_unicast": { + "admin_status": "up", + "send_default_route": "false" } }, "BGP_PEER_GROUP": { From 2dd0346abac5ecd70f25b8329c7d7aafeb9945ce Mon Sep 17 00:00:00 2001 From: miatao Date: Fri, 24 Jul 2026 17:23:13 +0000 Subject: [PATCH 4/4] Fix configuration markdown format Signed-off-by: miatao --- src/sonic-yang-models/doc/Configuration.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index d905a5760a..0bf08f7778 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -537,7 +537,8 @@ form, `vrf_name` accepts a VRF name (e.g. `default`, `Vrf1`) or a VNet name "local_addr": "10.1.0.1", "admin_status": "up" } - + } +} "BGP_PEER_RANGE": { "BGPSLBPassive": { "name": "BGPSLBPassive",