Skip to content

Commit 6e18426

Browse files
authored
[yang models] Add vnet/vrf to bgp peer range (sonic-net#24531)
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
1 parent a74b90e commit 6e18426

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
@@ -1885,6 +1885,20 @@
18851885
],
18861886
"name": "BGPVac",
18871887
"src_address": "10.1.0.32"
1888+
},
1889+
"vnet1|BGPWithVnet": {
1890+
"ip_range": [
1891+
"10.10.0.0/24"
1892+
],
1893+
"name": "BGPWithVnet",
1894+
"src_address": "10.1.0.32"
1895+
},
1896+
"Vrf_blue|BGPWithVrf": {
1897+
"ip_range": [
1898+
"10.11.0.0/24"
1899+
],
1900+
"name": "BGPWithVrf",
1901+
"src_address": "10.1.0.32"
18881902
}
18891903
},
18901904
"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
@@ -190,6 +190,16 @@
190190
"BGP_PEERRANGE_ALL_VALID": {
191191
"desc": "Configure BGP peer range table."
192192
},
193+
"BGP_PEERRANGE_VALID_VNET": {
194+
"desc": "Configure BGP peer range with a valid vnet."
195+
},
196+
"BGP_PEERRANGE_VALID_VRF": {
197+
"desc": "Configure BGP peer range with a valid vrf."
198+
},
199+
"BGP_PEERRANGE_INVALID_VNET_OR_VRF": {
200+
"desc": "Configure BGP peer range with an invalid vnet or vrf.",
201+
"eStrKey" : "InvalidValue"
202+
},
193203
"BGP_ALLOWED_PREFIXES_ALL_VALID": {
194204
"desc": "Configue BGP allowed prefix list."
195205
},

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
@@ -1684,10 +1684,97 @@
16841684
},
16851685

16861686
"BGP_PEERRANGE_ALL_VALID": {
1687+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1688+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1689+
"BGP_PEER_RANGE_TEMPLATE_LIST": [
1690+
{
1691+
"peer_range_name": "BGPSLBPassive",
1692+
"name": "BGPSLBPassive",
1693+
"src_address": "10.1.0.32",
1694+
"peer_asn": "65200",
1695+
"ip_range": [
1696+
"10.255.0.0/25"
1697+
]
1698+
}
1699+
]
1700+
}
1701+
}
1702+
},
1703+
1704+
"BGP_PEERRANGE_VALID_VNET": {
1705+
"sonic-vxlan:sonic-vxlan": {
1706+
"sonic-vxlan:VXLAN_TUNNEL": {
1707+
"VXLAN_TUNNEL_LIST": [
1708+
{
1709+
"name": "vtep1",
1710+
"src_ip": "1.2.3.4"
1711+
}
1712+
]
1713+
}
1714+
},
1715+
"sonic-vnet:sonic-vnet": {
1716+
"sonic-vnet:VNET": {
1717+
"VNET_LIST": [
1718+
{
1719+
"name": "Vnet1",
1720+
"vxlan_tunnel": "vtep1",
1721+
"vni": "10000"
1722+
}
1723+
]
1724+
}
1725+
},
1726+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1727+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1728+
"BGP_PEER_RANGE_LIST": [
1729+
{
1730+
"vrf_name": "Vnet1",
1731+
"peer_range_name": "BGPSLBPassive",
1732+
"name": "BGPSLBPassive",
1733+
"src_address": "10.1.0.32",
1734+
"peer_asn": "65200",
1735+
"ip_range": [
1736+
"10.255.0.0/25"
1737+
]
1738+
}
1739+
]
1740+
}
1741+
}
1742+
},
1743+
1744+
"BGP_PEERRANGE_VALID_VRF": {
1745+
"sonic-vrf:sonic-vrf":{
1746+
"sonic-vrf:VRF": {
1747+
"VRF_LIST": [
1748+
{
1749+
"name":"Vrf1"
1750+
}
1751+
]
1752+
}
1753+
},
1754+
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
1755+
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
1756+
"BGP_PEER_RANGE_LIST": [
1757+
{
1758+
"vrf_name": "Vrf1",
1759+
"peer_range_name": "BGPSLBPassive",
1760+
"name": "BGPSLBPassive",
1761+
"src_address": "10.1.0.32",
1762+
"peer_asn": "65200",
1763+
"ip_range": [
1764+
"10.255.0.0/25"
1765+
]
1766+
}
1767+
]
1768+
}
1769+
}
1770+
},
1771+
1772+
"BGP_PEERRANGE_INVALID_VNET_OR_VRF": {
16871773
"sonic-bgp-peerrange:sonic-bgp-peerrange": {
16881774
"sonic-bgp-peerrange:BGP_PEER_RANGE": {
16891775
"BGP_PEER_RANGE_LIST": [
16901776
{
1777+
"vrf_name": "Vnet1",
16911778
"peer_range_name": "BGPSLBPassive",
16921779
"name": "BGPSLBPassive",
16931780
"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)