Skip to content

mgmtd/bgpd: register bgpd backend client and add frr-bgp-peer operational data support[DRAFT]#21297

Draft
ashred-lnx wants to merge 8 commits intoFRRouting:masterfrom
ashred-lnx:ashred/bgpd-be-client-bgp-peer-yang-clean
Draft

mgmtd/bgpd: register bgpd backend client and add frr-bgp-peer operational data support[DRAFT]#21297
ashred-lnx wants to merge 8 commits intoFRRouting:masterfrom
ashred-lnx:ashred/bgpd-be-client-bgp-peer-yang-clean

Conversation

@ashred-lnx
Copy link
Copy Markdown
Contributor

Register bgpd as an mgmtd backend client (config/oper/rpc path wiring).
Add and wire frr-bgp-peer operational model/callback support under /frr-bgp-peer:lib/vrf.
Expose per-peer and per-AFI/SAFI operational fields through vtysh and FE periodic sampling.
Include compatibility and iterator hardening fixes to keep oper walks stable across FRR variants.
Stacked:

This branch is intentionally stacked on top of periodic notify/select support from #21253
Changes:

bgpd backend client wiring and operational xpath registration for /frr-bgp-peer:lib/vrf.
bgpd/bgp_peer_nb.c + bgpd/bgp_peer_nb.h callback implementation for:
peer identity/state, ASNs, queues, transitions, message counters, graceful-shutdown
AFI/SAFI list and counters
Build/YANG wiring updates required for bgpd/mgmtd integration.
Safe peer iteration in oper walk path to prevent runtime aborts.
Version-compatible callback handling for notify/AFI-SAFI lookup differences.

Testing:

`IPv4 Unicast Summary:
BGP router identifier 1.1.1.1, local AS number 65000 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 1, using 29 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
10.0.0.2        4      65001         0         0        0    0    0    never         Idle        0 N/A

Total number of neighbors 1
sudo python3 tests/topotests/lib/fe_client.py --server /var/run/frr/mgmtd_fe.sock --listen "/frr-bgp-peer:lib/vrf" --notify-mode periodic --notify-mode-data 2000 --notify-count 3 -v
{"frr-bgp-peer:lib":{"vrf":[{"id":"default","peer":[{"name":"10.0.0.2","status":"Idle","established-transitions":0,"in-queue":0,"out-queue":0,"local-as":65000,"peer-as":65001,"last-established":"1774068977","description":"","peer-group":"","peer-type":"external","neighbor-address":"10.0.0.2","messages":{"sent":{"last-notification-error-code":"","updates":0},"received":{"last-notification-error-code":"","updates":0}},"afi-safi":[{"afi-safi-name":"frr-routing:ipv4-unicast","rcvd-pfx":0,"rcvd-pfx-installed":0,"afi":"IPv4","safi":"unicast"}],"total-msgs-sent":0,"total-msgs-recvd":0,"graceful-shutdown":false}]}]}}
2026-03-22 20:02:15,777 DEBUG: Connecting to server on /var/run/frr/mgmtd_fe.sock
2026-03-22 20:02:15,778 INFO: Connected to server on /var/run/frr/mgmtd_fe.sock
2026-03-22 20:02:15,778 DEBUG: Sent native SESSION-REQ
2026-03-22 20:02:15,778 DEBUG: Recv native SESSION-REPLY Message: sess-id 1005: fixed: (1,): b''
2026-03-22 20:02:15,778 DEBUG: Sent NOTIFY_SELECT mode=1 mode_data=2000
2026-03-22 20:02:15,778 DEBUG: Waiting for Notify Message
2026-03-22 20:02:15,789 DEBUG: Received Notify Message: (2, 4): b'/frr-bgp-peer:lib/vrf\x00{"frr-bgp-peer:lib":{"vrf":[{"id":"default","peer":[{"name":"10.0.0.2","status":"Idle","established-transitions":0,"in-queue":0,"out-queue":0,"local-as":65000,"peer-as":65001,"last-established":"1774068976","description":"","peer-group":"","peer-type":"external","neighbor-address":"10.0.0.2","messages":{"sent":{"last-notification-error-code":"","updates":0},"received":{"last-notification-error-code":"","updates":0}},"afi-safi":[{"afi-safi-name":"frr-routing:ipv4-unicast","rcvd-pfx":0,"rcvd-pfx-installed":0,"afi":"IPv4","safi":"unicast"}],"total-msgs-sent":0,"total-msgs-recvd":0,"graceful-shutdown":false}]}]}}\x00'
2026-03-22 20:02:15,789 WARNING: ignoring datastore notification op: 4 xpath: /frr-bgp-peer:lib/vrf data: {"frr-bgp-peer:lib":{"vrf":[{"id":"default","peer":[{"name":"10.0.0.2","status":"Idle","established-transitions":0,"in-queue":0,"out-queue":0,"local-as":65000,"peer-as":65001,"last-established":"1774068976","description":"","peer-group":"","peer-type":"external","neighbor-address":"10.0.0.2","messages":{"sent":{"last-notification-error-code":"","updates":0},"received":{"last-notification-error-code":"","updates":0}},"afi-safi":[{"afi-safi-name":"frr-routing:ipv4-unicast","rcvd-pfx":0,"rcvd-pfx-installed":0,"afi":"IPv4","safi":"unicast"}],"total-msgs-sent":0,"total-msgs-recvd":0,"graceful-shutdown":false}]}]}}
2026-03-22 20:02:15,789 DEBUG: Waiting for Notify Message
2026-03-22 20:02:17,791 DEBUG: Received Notify Message: (2, 4): b'/frr-bgp-peer:lib/vrf\x00{"frr-bgp-peer:lib":{"vrf":[{"id":"default","peer":[{"name":"10.0.0.2","status":"Active","established-transitions":0,"in-queue":0,"out-queue":0,"local-as":65000,"peer-as":65001,"last-established":"1774068976","description":"","peer-group":"","peer-type":"external","neighbor-address":"10.0.0.2","messages":{"sent":{"last-notification-error-code":"","updates":0},"received":{"last-notification-error-code":"","updates":0}},"afi-safi":[{"afi-safi-name":"frr-routing:ipv4-unicast","rcvd-pfx":0,"rcvd-pfx-installed":0,"afi":"IPv4","safi":"unicast"}],"total-msgs-sent":0,"total-msgs-recvd":0,"graceful-shutdown":false}]}]}}\x00'
2026-03-22 20:02:17,791 WARNING: ignoring datastore notification op: 4 xpath: /frr-bgp-peer:lib/vrf data: {"frr-bgp-peer:lib":{"vrf":[{"id":"default","peer":[{"name":"10.0.0.2","status":"Active","established-transitions":0,"in-queue":0,"out-queue":0,"local-as":65000,"peer-as":65001,"last-established":"1774068976","description":"","peer-group":"","peer-type":"external","neighbor-address":"10.0.0.2","messages":{"sent":{"last-notification-error-code":"","updates":0},"received":{"last-notification-error-code":"","updates":0}},"afi-safi":[{"afi-safi-name":"frr-routing:ipv4-unicast","rcvd-pfx":0,"rcvd-pfx-installed":0,"afi":"IPv4","safi":"unicast"}],"total-msgs-sent":0,"total-msgs-recvd":0,"graceful-shutdown":false}]}]}}
2026-03-22 20:02:17,791 DEBUG: Waiting for Notify Message`

Extend NOTIFY_SELECT to carry mode/mode_data, add FE client API support, and implement per-session periodic sampling timers in mgmtd while keeping backend notify-select operations on-change.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Update tests/topotests/lib/fe_client.py to encode NOTIFY_SELECT mode/mode_data and add CLI flags for periodic sample testing, then remove the temporary standalone tools/mgmtd_notify_test_client.py helper.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Clarify mode/mode_data behavior for native NOTIFY_SELECT in user docs and
add inline code-path comments around validation and periodic scheduling.

Signed-off-by: Ashwin Reddy <ashwinreddy@users.noreply.github.com>
Register bgpd backend/xpath wiring for frr-bgp-peer and ensure mgmtd can resolve and load the model for operational queries.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Add callback-backed operational data handlers for peer state and afi-safi fields under /frr-bgp-peer:lib/vrf.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Apply version compatibility updates and safe peer iteration to prevent runtime aborts during operational data walks.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
@frrbot frrbot Bot added bgp mgmt FRR Management Infra tests Topotests, make check, etc labels Mar 23, 2026
Add missing SPDX-License-Identifier tags to bgpd peer northbound source/header files to satisfy verify-source checks.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Include zebra.h first for platform portability and cast epoch timestamp to uint64_t for explicit type conversion in YANG data emission.

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
@riw777 riw777 self-requested a review March 24, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bgp master mgmt FRR Management Infra rebase PR needs rebase size/XXL tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant