Skip to content

Commit

Permalink
workaround leaf-list via uses bug in BGP route-map (PR sonic-net#21078)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
bradh352 committed Dec 24, 2024
1 parent 4fbb94c commit ab4b75b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
16 changes: 0 additions & 16 deletions src/sonic-yang-models/yang-models/sonic-bgp-common.yang
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,6 @@ module sonic-bgp-common {
description "Interval after which connection will get re-established";
}

leaf-list route_map_in {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for incoming routes";
max-elements 1;
}

leaf-list route_map_out {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for outgoing routes";
max-elements 1;
}

leaf soft_reconfiguration_in {
type boolean;
description "Inbound soft reconfiguration";
Expand Down
23 changes: 23 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ module sonic-bgp-neighbor {
// prefix vlan;
//}

import sonic-route-map {
prefix rmap;
}

import sonic-bgp-global {
prefix bgpg;
}
Expand Down Expand Up @@ -130,7 +134,26 @@ module sonic-bgp-neighbor {
}
description "BGP Neighbor, it will be neighbor address or interface name";
}

uses bgpcmn:sonic-bgp-cmn-af;

// These should logically be in sonic-bgp-cmn-af, however due to a libyang2 bug when including
// a leaf-list entry, there are validation failures.
leaf-list route_map_in {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for incoming routes";
max-elements 1;
}

leaf-list route_map_out {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for outgoing routes";
max-elements 1;
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-bgp-peergroup.yang
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module sonic-bgp-peergroup {
prefix bgpg;
}

import sonic-route-map {
prefix rmap;
}

organization
"SONiC";

Expand Down Expand Up @@ -68,6 +72,24 @@ module sonic-bgp-peergroup {
}

uses bgpcmn:sonic-bgp-cmn-af;

// These should logically be in sonic-bgp-cmn-af, however due to a libyang2 bug when including
// a leaf-list entry, there are validation failures.
leaf-list route_map_in {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for incoming routes";
max-elements 1;
}

leaf-list route_map_out {
type leafref {
path "/rmap:sonic-route-map/rmap:ROUTE_MAP_SET/rmap:ROUTE_MAP_SET_LIST/rmap:name";
}
description "Route-map filter for outgoing routes";
max-elements 1;
}
}
}

Expand Down

0 comments on commit ab4b75b

Please sign in to comment.