Skip to content

bmp msg stats#1646

Open
Fredi-raspall wants to merge 4 commits into
pr/fredi/bgp_sess_change_recordfrom
pr/fredi/fix_bmp_msg_stats
Open

bmp msg stats#1646
Fredi-raspall wants to merge 4 commits into
pr/fredi/bgp_sess_change_recordfrom
pr/fredi/fix_bmp_msg_stats

Conversation

@Fredi-raspall

Copy link
Copy Markdown
Contributor

This goes on top of #1645

  • Improve bgp message statistics
  • Currently, we only supported update messages.
  • Enable bmp mirroring to account for other message types (opens, notifications, keepalives) which better show the state of a session.

Note:

  • only received messages from a peer are supported.
  • Sent messages are not supported by frr.
  • The stats are at message level. In case of updates, these may contain many routes packed, which are not reflected in the stats.

@Fredi-raspall Fredi-raspall self-assigned this Jul 18, 2026
Copilot AI review requested due to automatic review settings July 18, 2026 16:41
@Fredi-raspall
Fredi-raspall requested a review from a team as a code owner July 18, 2026 16:41
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35c1dee7-1880-4c39-b350-4a7bb9dfc68e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

BMP startup is separated from router construction. BMP mirroring updates BGP counters, peer transitions emit router control events, and BGP status models plus Kubernetes conversion reflect required counters and optional reset reasons.

BMP and BGP integration

Layer / File(s) Summary
BGP status contracts and conversion
config/src/internal/status/mod.rs, config/src/converters/k8s/status/bgp.rs
BGP counters and neighbor messages are required, reset reasons are optional, and Kubernetes conversion logic matches the updated fields.
BMP route mirroring and counters
config/src/internal/routing/bmp.rs, routing/src/frr/renderer/bgp.rs, dataplane/src/runtime.rs, routing/src/bmp/bmp_render.rs
BMP mirroring is configurable and rendered to FRR; mirrored and monitored messages update neighbor counters.
BGP neighbor event propagation
routing/src/bmp/{bmp_render.rs,handler.rs,mod.rs}, routing/src/router/{ctl.rs,revent.rs}
Peer-up and peer-down processing creates neighbor events, sends them through router control, and formats them as router events.
BMP startup and router lifecycle decoupling
routing/src/router/mod.rs, dataplane/src/{runtime.rs,packet_processor/mod.rs}, routing/src/lib.rs, mgmt/src/processor/*, */tests/*
Router construction no longer starts or stops BMP; dataplane startup invokes the exported BMP server separately and callers use immutable router-control references.
Duration display formatting
routing/src/cli/{display.rs,mod.rs}
Elapsed-time formatting is centralized in PrettyDuration, and the display module is crate-visible.

Possibly related PRs

Suggested reviewers: sergeymatov

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the change, but it is too vague and does not clearly state the main update. Use a more specific title that mentions BGP/BMP message statistics and mirroring support.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description matches the changeset and explains the BMP mirroring and message statistics update.

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves BGP message-level statistics and session visibility by enabling BMP route mirroring and emitting router events on BGP neighbor state changes, so non-UPDATE message types (OPEN/KEEPALIVE/NOTIFICATION/etc.) can be accounted for.

Changes:

  • Add BMP “route mirroring” configuration/rendering and consume mirrored BGP messages to update per-neighbor message counters.
  • Generate and record BGP neighbor session state-change events (log + router eventlog) based on BMP peer up/down notifications.
  • Refactor BMP server lifecycle: remove BMP task ownership from Router, expose spawn_bmp_server, and start BMP from the dataplane runtime with a RouterCtlSender for event emission.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
routing/src/router/revent.rs Adds a new router event for BGP neighbor state changes; increases eventlog capacity.
routing/src/router/mod.rs Removes BMP server ownership/config from Router construction and shutdown.
routing/src/router/ctl.rs Adds a control message path for BGP neighbor events; makes sender APIs take &self.
routing/src/lib.rs Re-exports spawn_bmp_server from the routing crate.
routing/src/frr/test.rs Updates router construction for the new Router::new signature.
routing/src/frr/renderer/bgp.rs Renders bmp mirror when configured.
routing/src/bmp/mod.rs Renames/exports BMP spawn function and wires RouterCtlSender into the handler.
routing/src/bmp/handler.rs Calls async BMP processing that can now emit router control events.
routing/src/bmp/bmp_render.rs Adds route mirroring handling, counts mirrored message types, and emits session-change events.
mgmt/src/tests/mgmt.rs Updates router construction for the new Router::new signature.
mgmt/src/processor/proc.rs Adjusts status-population/config paths to use &RouterCtlSender instead of &mut.
mgmt/src/processor/launch.rs Updates interface notify loop to not require mutable RouterCtlSender.
dataplane/src/runtime.rs Starts BMP server from dataplane runtime and enables mirroring in BMP options.
dataplane/src/packet_processor/mod.rs Updates router startup for the new Router::new signature.
config/src/internal/status/mod.rs Makes BGP message counters non-optional; makes last reset reason optional; adds Display for session state.
config/src/internal/routing/bmp.rs Adds mirror option to internal BMP config model.
config/src/converters/k8s/status/bgp.rs Updates K8s conversion to match new non-optional BGP message counter structs.

Comment thread routing/src/bmp/handler.rs Outdated
Comment thread routing/src/bmp/bmp_render.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@routing/src/bmp/bmp_render.rs`:
- Around line 156-173: The BGP event currently identifies peers with
remote_router_id instead of the neighbor address. Update generate_bgp_event to
accept the status-map key as key, pass that address at its call site, and use
key for BgpNeighEvent.peer while leaving the session-state transition handling
unchanged.
- Around line 359-362: Remove the received.update increment from the UPDATE
handling in the route-monitoring path around BgpMessage::Update and
neigh.messages.received, so mirrored UPDATEs are not counted twice. Preserve
Route Monitoring’s prefix-statistics processing, and rely on the Route Mirroring
path as the sole source for the message counter.

In `@routing/src/bmp/handler.rs`:
- Around line 40-43: Update on_message and bmp_render::handle_bmp_message so
rendering returns an optional router-control event instead of awaiting while the
dp_status write guard is held. Release the guard after rendering, then await
sending the returned event through rtr_ctl; preserve existing behavior when no
event is produced.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54e51e10-35cb-4ecf-9c32-077e6ef821c4

📥 Commits

Reviewing files that changed from the base of the PR and between 1842c63 and 7cb0b9c.

📒 Files selected for processing (17)
  • config/src/converters/k8s/status/bgp.rs
  • config/src/internal/routing/bmp.rs
  • config/src/internal/status/mod.rs
  • dataplane/src/packet_processor/mod.rs
  • dataplane/src/runtime.rs
  • mgmt/src/processor/launch.rs
  • mgmt/src/processor/proc.rs
  • mgmt/src/tests/mgmt.rs
  • routing/src/bmp/bmp_render.rs
  • routing/src/bmp/handler.rs
  • routing/src/bmp/mod.rs
  • routing/src/frr/renderer/bgp.rs
  • routing/src/frr/test.rs
  • routing/src/lib.rs
  • routing/src/router/ctl.rs
  • routing/src/router/mod.rs
  • routing/src/router/revent.rs
💤 Files with no reviewable changes (1)
  • routing/src/router/mod.rs

Comment thread routing/src/bmp/bmp_render.rs Outdated
Comment thread routing/src/bmp/bmp_render.rs
Comment thread routing/src/bmp/handler.rs Outdated
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/fix_bmp_msg_stats branch from 7cb0b9c to e9f9fc9 Compare July 19, 2026 10:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@routing/src/bmp/bmp_render.rs`:
- Around line 236-240: Enable the received-OPEN counter update in the
BgpMessage::Open branch of the PeerUp handling, incrementing
neigh.messages.received.open with saturating arithmetic so the OPEN is recorded
without overflow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d13d436-eaa2-4397-b694-80a627f61c67

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb0b9c and e9f9fc9.

📒 Files selected for processing (7)
  • config/src/converters/k8s/status/bgp.rs
  • config/src/internal/routing/bmp.rs
  • config/src/internal/status/mod.rs
  • dataplane/src/runtime.rs
  • routing/src/bmp/bmp_render.rs
  • routing/src/bmp/handler.rs
  • routing/src/frr/renderer/bgp.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • routing/src/bmp/handler.rs
  • routing/src/frr/renderer/bgp.rs
  • config/src/internal/status/mod.rs
  • config/src/converters/k8s/status/bgp.rs
  • dataplane/src/runtime.rs

Comment thread routing/src/bmp/bmp_render.rs
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/fix_bmp_msg_stats branch 2 times, most recently from af03742 to a3f8a1c Compare July 19, 2026 12:22
@Fredi-raspall
Fredi-raspall changed the base branch from main to pr/fredi/bgp_sess_change_record July 20, 2026 09:00
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/bgp_sess_change_record branch from 49819bc to 0ca0ef1 Compare July 20, 2026 14:55
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/bgp_sess_change_record branch from 0ca0ef1 to c7fc043 Compare July 21, 2026 13:08
Making them optional overcomplicates the code for no real benefit.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Process route mirrored packets to provide better message stats.
This comes with limitations due to FRR's incomplete BMP
implementation.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
This is needed for the msg stats to be populated.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/fix_bmp_msg_stats branch from a3f8a1c to b65d004 Compare July 21, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants