Skip to content

Commit 0b08de0

Browse files
committed
Yang model changes for Anchor prefix
Files modified/added 1. setup.py: added the bgp_prefix_list.yang to the setup list 2. sonic-bgp-prefix-list.yang: new yang model for the prefix list which is added in configdb through cli 3. test files to test the yang model Signed-off-by: Mukul Chodhary <70460358+Muckthebuck@users.noreply.github.com>
1 parent 1332597 commit 0b08de0

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed

src/sonic-yang-models/doc/Configuration.md

+13
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
* [Static DNS](#static-dns)
9595
* [ASIC_SENSORS](#asic_sensors)
9696
* [SRv6](#srv6)
97+
* [Prefix List](#prefix-list)
9798
* [For Developers](#for-developers)
9899
* [Generating Application Config by Jinja2 Template](#generating-application-config-by-jinja2-template)
99100
* [Incremental Configuration by Subscribing to ConfigDB](#incremental-configuration-by-subscribing-to-configdb)
@@ -2913,6 +2914,18 @@ An example is as follows:
29132914
}
29142915
```
29152916

2917+
### Prefix List
2918+
Prefix list table stores a list of prefixes with type and prefix separated by `|`. The specific configuration for the prefix type are then rendered by the PrefixListMgr. Currently ANCHOR_PREFIX is supported to add RADIAN configuration.
2919+
2920+
An example is as follows:
2921+
```json
2922+
{
2923+
"PREFIX_LIST": {
2924+
"ANCHOR_PREFIX|fc00::/48": {}
2925+
}
2926+
}
2927+
```
2928+
29162929
### FIPS
29172930

29182931
The FIPS table introduces FIPS configuration.

src/sonic-yang-models/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def run(self):
205205
'./yang-models/sonic-system-port.yang',
206206
'./yang-models/sonic-macsec.yang',
207207
'./yang-models/sonic-bgp-sentinel.yang',
208+
'./yang-models/sonic-bgp-prefix-list.yang',
208209
'./yang-models/sonic-asic-sensors.yang',
209210
'./yang-models/sonic-bmp.yang',
210211
'./yang-models/sonic-xcvrd-log.yang',

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

+4
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,10 @@
28522852
"action": "uN",
28532853
"decap_dscp_mode": "pipe"
28542854
}
2855+
},
2856+
"PREFIX_LIST": {
2857+
"ANCHOR_PREFIX|10.0.0.0/8" : {},
2858+
"ANCHOR_PREFIX|FC00::/48" : {}
28552859
}
28562860
},
28572861
"SAMPLE_CONFIG_DB_UNKNOWN": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"BGP_PREFIX_LIST_WITH_VALID_IPV4_PREFIX": {
3+
"desc": "Load BGP prefix list table with a valid IPv4 prefix"
4+
},
5+
"BGP_PREFIX_LIST_WITH_VALID_IPV6_PREFIX": {
6+
"desc": "Load BGP prefix list table with a valid IPv6 prefix"
7+
},
8+
"BGP_PREFIX_LIST_WITH_INVALID_PREFIX": {
9+
"desc": "Load BGP prefix list table with an invalid prefix",
10+
"eStrKey": "InvalidValue",
11+
"eStr": ["prefix"]
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"BGP_PREFIX_LIST_WITH_VALID_IPV4_PREFIX": {
3+
"sonic-bgp-prefix-list:sonic-bgp-prefix-list": {
4+
"sonic-bgp-prefix-list:PREFIX_LIST": {
5+
"PREFIX_LIST_LIST": [
6+
{
7+
"name": "ANCHOR_PREFIX",
8+
"ip-prefix": "10.0.0.0/8"
9+
}
10+
]
11+
}
12+
}
13+
},
14+
"BGP_PREFIX_LIST_WITH_VALID_IPV6_PREFIX": {
15+
"sonic-bgp-prefix-list:sonic-bgp-prefix-list": {
16+
"sonic-bgp-prefix-list:PREFIX_LIST": {
17+
"PREFIX_LIST_LIST": [
18+
{
19+
"name": "ANCHOR_PREFIX",
20+
"ip-prefix": "fc00::/48"
21+
}
22+
]
23+
}
24+
}
25+
},
26+
"BGP_PREFIX_LIST_WITH_INVALID_PREFIX": {
27+
"sonic-bgp-prefix-list:sonic-bgp-prefix-list": {
28+
"sonic-bgp-prefix-list:PREFIX_LIST": {
29+
"PREFIX_LIST_LIST": [
30+
{
31+
"name": "ANCHOR_PREFIX",
32+
"ip-prefix": "invalid_prefix"
33+
}
34+
]
35+
}
36+
},
37+
"eStrKey": "InvalidValue",
38+
"eStr": ["prefix"]
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
module sonic-bgp-prefix-list {
3+
4+
yang-version 1.1;
5+
6+
namespace "http://github.com/sonic-net/sonic-bgp-prefix-list";
7+
prefix bgppl;
8+
9+
import sonic-types {
10+
prefix stypes;
11+
}
12+
13+
import sonic-extension {
14+
prefix ext;
15+
}
16+
17+
description "SONIC Device-specfifc BGP prefix lists data";
18+
19+
revision 2025-02-05 {
20+
description "Initial revision.";
21+
}
22+
23+
container sonic-bgp-prefix-list {
24+
25+
container PREFIX_LIST {
26+
27+
description "PREFIX_LIST part of config_db.json";
28+
29+
list PREFIX_LIST_LIST {
30+
31+
description "PREFIX_LIST part of config_db.json with prefix";
32+
33+
key "name ip-prefix";
34+
35+
leaf name {
36+
type string;
37+
description "Name of the prefix list";
38+
}
39+
40+
leaf ip-prefix {
41+
type union {
42+
type stypes:sonic-ip4-prefix;
43+
type stypes:sonic-ip6-prefix;
44+
}
45+
}
46+
47+
leaf family {
48+
49+
/* family leaf needed for backward compatibility
50+
Both ip4 and ip6 address are string in IETF RFC 6021,
51+
so must statement can check based on : or ., family
52+
should be IPv4 or IPv6 according.
53+
*/
54+
55+
must "(contains(../ip-prefix, ':') and current()='IPv6') or
56+
(contains(../ip-prefix, '.') and current()='IPv4')";
57+
type stypes:ip-family;
58+
}
59+
}
60+
}
61+
/* end of PREFIX_LIST */
62+
}
63+
}

0 commit comments

Comments
 (0)