diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 827ae61150..0bf08f7778 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -502,6 +502,11 @@ 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 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. + ``` { "BGP_NEIGHBOR": { @@ -516,7 +521,7 @@ group name and IP ranges in **BGP_PEER_RANGE** table. "name": "ARISTA09T0" }, - "10.0.0.63": { + "default|10.0.0.63": { "rrclient": "0", "name": "ARISTA04T1", "local_addr": "10.0.0.62", @@ -524,8 +529,16 @@ 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", + "local_addr": "10.1.0.1", + "admin_status": "up" + } + } +} "BGP_PEER_RANGE": { "BGPSLBPassive": { "name": "BGPSLBPassive", 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": { 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..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 @@ -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": { 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 {