Skip to content

Commit 3c8c013

Browse files
committed
workaround leaf-list via uses bug in BGP route-map (PR sonic-net#21078)
There is a bug in libyang when attempting to use table `BGP_PEER_GROUP_AF` and likely `BGP_NEIGHBOR_AF` in respect to `route_map_in` and `route_map_out`. The issue is with the use of `leaf-list` specifically when it is pulled in via a `uses` clause `bgpcmn:sonic-bgp-cmn-af`. The error message resembles that of if a child is specified that isn't recognized at all: ``` All Keys are not parsed in BGP_PEER_GROUP_AF dict_keys(['default|PEERS|ipv4_unicast']) exceptionList:["'route_map_in'"] ``` Moving the leaf-list to the parent rather than being imported through the `uses` clause works around this issue. Signed-off-by: Brad House (@bradh352)
1 parent 876cc35 commit 3c8c013

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

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

-16
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,6 @@ module sonic-bgp-common {
382382
description "Interval after which connection will get re-established";
383383
}
384384

385-
leaf-list route_map_in {
386-
type leafref {
387-
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
388-
}
389-
description "Route-map filter for incoming routes";
390-
max-elements 1;
391-
}
392-
393-
leaf-list route_map_out {
394-
type leafref {
395-
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
396-
}
397-
description "Route-map filter for outgoing routes";
398-
max-elements 1;
399-
}
400-
401385
leaf soft_reconfiguration_in {
402386
type boolean;
403387
description "Inbound soft reconfiguration";

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

+23
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ module sonic-bgp-neighbor {
2828
// prefix vlan;
2929
//}
3030

31+
import sonic-route-map {
32+
prefix rmap;
33+
}
34+
3135
import sonic-bgp-global {
3236
prefix bgpg;
3337
}
@@ -130,7 +134,26 @@ module sonic-bgp-neighbor {
130134
}
131135
description "BGP Neighbor, it will be neighbor address or interface name";
132136
}
137+
133138
uses bgpcmn:sonic-bgp-cmn-af;
139+
140+
// These should logically be in sonic-bgp-cmn-af, however due to a libyang2 bug when including
141+
// a leaf-list entry, there are validation failures.
142+
leaf-list route_map_in {
143+
type leafref {
144+
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
145+
}
146+
description "Route-map filter for incoming routes";
147+
max-elements 1;
148+
}
149+
150+
leaf-list route_map_out {
151+
type leafref {
152+
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
153+
}
154+
description "Route-map filter for outgoing routes";
155+
max-elements 1;
156+
}
134157
}
135158
}
136159
}

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

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ module sonic-bgp-peergroup {
1515
prefix bgpg;
1616
}
1717

18+
import sonic-route-map {
19+
prefix rmap;
20+
}
21+
1822
organization
1923
"SONiC";
2024

@@ -68,6 +72,24 @@ module sonic-bgp-peergroup {
6872
}
6973

7074
uses bgpcmn:sonic-bgp-cmn-af;
75+
76+
// These should logically be in sonic-bgp-cmn-af, however due to a libyang2 bug when including
77+
// a leaf-list entry, there are validation failures.
78+
leaf-list route_map_in {
79+
type leafref {
80+
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
81+
}
82+
description "Route-map filter for incoming routes";
83+
max-elements 1;
84+
}
85+
86+
leaf-list route_map_out {
87+
type leafref {
88+
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
89+
}
90+
description "Route-map filter for outgoing routes";
91+
max-elements 1;
92+
}
7193
}
7294
}
7395

0 commit comments

Comments
 (0)