Skip to content

Commit cded206

Browse files
authored
[action] [PR:24531] [yang models] Add vnet/vrf to bgp peer range (#1875)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it Bgp peer range yang model currently has no field to associate with a vnet or vrf, even though this feature is supported. ##### Work item tracking - Microsoft ADO **(number only)**: 31626685 #### How I did it Added vnet/vrf name field to the key for bgp peer range. #### How to verify it Tested on a physical testbed and UTs <img width="2445" height="619" alt="image" src="https://github.com/user-attachments/assets/673e3173-a826-41ff-9471-a86d7a70e172" /> <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 202205 - [ ] 202211 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
1 parent 5f4935c commit cded206

File tree

4 files changed

+168
-1
lines changed

4 files changed

+168
-1
lines changed

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,20 @@
18601860
],
18611861
"name": "BGPVac",
18621862
"src_address": "10.1.0.32"
1863+
},
1864+
"vnet1|BGPWithVnet": {
1865+
"ip_range": [
1866+
"10.10.0.0/24"
1867+
],
1868+
"name": "BGPWithVnet",
1869+
"src_address": "10.1.0.32"
1870+
},
1871+
"Vrf_blue|BGPWithVrf": {
1872+
"ip_range": [
1873+
"10.11.0.0/24"
1874+
],
1875+
"name": "BGPWithVrf",
1876+
"src_address": "10.1.0.32"
18631877
}
18641878
},
18651879
"BGP_SENTINELS": {

src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@
178178
"BGP_PEERRANGE_ALL_VALID": {
179179
"desc": "Configure BGP peer range table."
180180
},
181+
"BGP_PEERRANGE_VALID_VNET": {
182+
"desc": "Configure BGP peer range with a valid vnet."
183+
},
184+
"BGP_PEERRANGE_VALID_VRF": {
185+
"desc": "Configure BGP peer range with a valid vrf."
186+
},
187+
"BGP_PEERRANGE_INVALID_VNET_OR_VRF": {
188+
"desc": "Configure BGP peer range with an invalid vnet or vrf.",
189+
"eStrKey" : "InvalidValue"
190+
},
181191
"BGP_ALLOWED_PREFIXES_ALL_VALID": {
182192
"desc": "Configue BGP allowed prefix list."
183193
},

src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,10 +1530,97 @@
15301530
},
15311531

15321532
"BGP_PEERRANGE_ALL_VALID": {
1533+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1534+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1535+
"BGP_PEER_RANGE_TEMPLATE_LIST": [
1536+
{
1537+
"peer_range_name": "BGPSLBPassive",
1538+
"name": "BGPSLBPassive",
1539+
"src_address": "10.1.0.32",
1540+
"peer_asn": "65200",
1541+
"ip_range": [
1542+
"10.255.0.0/25"
1543+
]
1544+
}
1545+
]
1546+
}
1547+
}
1548+
},
1549+
1550+
"BGP_PEERRANGE_VALID_VNET": {
1551+
"sonic-vxlan:sonic-vxlan": {
1552+
"sonic-vxlan:VXLAN_TUNNEL": {
1553+
"VXLAN_TUNNEL_LIST": [
1554+
{
1555+
"name": "vtep1",
1556+
"src_ip": "1.2.3.4"
1557+
}
1558+
]
1559+
}
1560+
},
1561+
"sonic-vnet:sonic-vnet": {
1562+
"sonic-vnet:VNET": {
1563+
"VNET_LIST": [
1564+
{
1565+
"name": "Vnet1",
1566+
"vxlan_tunnel": "vtep1",
1567+
"vni": "10000"
1568+
}
1569+
]
1570+
}
1571+
},
1572+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1573+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1574+
"BGP_PEER_RANGE_LIST": [
1575+
{
1576+
"vrf_name": "Vnet1",
1577+
"peer_range_name": "BGPSLBPassive",
1578+
"name": "BGPSLBPassive",
1579+
"src_address": "10.1.0.32",
1580+
"peer_asn": "65200",
1581+
"ip_range": [
1582+
"10.255.0.0/25"
1583+
]
1584+
}
1585+
]
1586+
}
1587+
}
1588+
},
1589+
1590+
"BGP_PEERRANGE_VALID_VRF": {
1591+
"sonic-vrf:sonic-vrf":{
1592+
"sonic-vrf:VRF": {
1593+
"VRF_LIST": [
1594+
{
1595+
"name":"Vrf1"
1596+
}
1597+
]
1598+
}
1599+
},
1600+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1601+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1602+
"BGP_PEER_RANGE_LIST": [
1603+
{
1604+
"vrf_name": "Vrf1",
1605+
"peer_range_name": "BGPSLBPassive",
1606+
"name": "BGPSLBPassive",
1607+
"src_address": "10.1.0.32",
1608+
"peer_asn": "65200",
1609+
"ip_range": [
1610+
"10.255.0.0/25"
1611+
]
1612+
}
1613+
]
1614+
}
1615+
}
1616+
},
1617+
1618+
"BGP_PEERRANGE_INVALID_VNET_OR_VRF": {
15331619
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
15341620
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
15351621
"BGP_PEER_RANGE_LIST": [
15361622
{
1623+
"vrf_name": "Vnet1",
15371624
"peer_range_name": "BGPSLBPassive",
15381625
"name": "BGPSLBPassive",
15391626
"src_address": "10.1.0.32",

src/sonic-yang-models/yang-models/sonic-bgp-peerrange.yang

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ module sonic-bgp-peerrange {
1111
prefix stypes;
1212
}
1313

14+
import sonic-vrf {
15+
prefix vrf;
16+
}
17+
18+
import sonic-vnet {
19+
prefix svnet;
20+
}
21+
1422
organization
1523
"SONiC";
1624

@@ -28,6 +36,54 @@ module sonic-bgp-peerrange {
2836
container sonic-bgp-peerrange {
2937
container BGP_PEER_RANGE {
3038
list BGP_PEER_RANGE_LIST {
39+
description "This list supports BGP_PEER_RANGE_TEMPLATE configurations with vnet and vrf support";
40+
key "vrf_name peer_range_name";
41+
42+
leaf vrf_name {
43+
type union {
44+
type leafref {
45+
path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name";
46+
}
47+
type leafref {
48+
path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name";
49+
}
50+
}
51+
description "vrf or vnet name";
52+
}
53+
54+
leaf peer_range_name {
55+
type string;
56+
description "Peer range name";
57+
}
58+
59+
leaf name {
60+
type string;
61+
must "(current() = current()/../peer_range_name)" {
62+
error-message "Invalid name, name must match peer_range_name";
63+
}
64+
}
65+
66+
leaf src_address {
67+
type inet:ip-address;
68+
description "Source address to use for connection";
69+
}
70+
71+
leaf peer_asn {
72+
type uint32 {
73+
range "1..4294967295";
74+
}
75+
description "Peer AS number";
76+
}
77+
78+
leaf-list ip_range {
79+
type stypes:sonic-ip-prefix;
80+
ordered-by user;
81+
description "A range of addresses";
82+
}
83+
}
84+
85+
list BGP_PEER_RANGE_TEMPLATE_LIST {
86+
description "This list is to support template based BGP peer range configurations.";
3187
key "peer_range_name";
3288

3389
leaf peer_range_name {
@@ -38,7 +94,7 @@ module sonic-bgp-peerrange {
3894
leaf name {
3995
type string;
4096
must "(current() = current()/../peer_range_name)" {
41-
error-message "Invalid name";
97+
error-message "Invalid name, name must match peer_range_name";
4298
}
4399
}
44100

0 commit comments

Comments
 (0)