Hello!
Replies inline, as your message is rather long and structured.
On Fri, Oct 23, 2026 at 12:23:38PM +0900, taichi aoki via Bird-users wrote:
I would like to extend BMP in BIRD 3 and I am writing before starting the work, following the “upfront consultation” advice in CONTRIBUTING.md and Maria’s reply to Matthieu Gouel in January [1].
We appreciate this approach a lot.
Why: today I monitor my routers by polling “show protocols all” over the control socket every 60 seconds. Every poll costs the daemon CPU, and what I get is a snapshot: a session that flaps between two polls, or a route that changes and changes back, is invisible, and anything I do see is up to a minute late. For route-level questions (what is actually in the table, what was dropped by RPKI or other filters, when did it change) I would need “show route” dumps, which do not scale. BMP already pushes Peer Up/Down and Adj-RIB-In pre/post-policy to my own collector; what I miss is:
- Loc-RIB monitoring (RFC 9069): the selected routes of the BIRD tables I choose to monitor, including non-BGP ones, as a stream instead of table dumps.
- Statistics Reports (RFC 7854 4.8, RFC 8671): periodic reports of the route counters BIRD already keeps, where they map to defined stat types, so most of my CLI polling can stop.
- Adj-RIB-Out (RFC 8671): what we announce to each peer, to verify export policy (RPKI invalids, leaks) from the collector. This is the one I need least; it is on the list because others asked for it here [3] and I would rather align with your TX plans than leave it out.
To avoid confusion: the current “post-policy” monitoring is Adj-RIB-In after import filters (L flag). Loc-RIB (peer type 3) and Adj-RIB-Out (O flag) do not exist in BIRD today.
Note: You may get this information via the CORECONF API which is currently in progress. While streaming the data you need won’t be in the first release of the CORECONF, it still has higher priority than BMP.
How I would do it in thread-next, please correct me where I am wrong:
- Loc-RIB. BIRD has no BGP Loc-RIB as such: a table is shared by all protocols and its best route is chosen by preference, not only by the BGP decision process.
This may be way more complicated than just one table, e.g. some IXPs have one table per client, and it’s common to have auxiliary tables for whatever black magic you need to do.
Also please note that we have a rather large update in progress where the best route selection would be done asynchronously.
I would map one configured BIRD table to one Loc-RIB instance peer: channels on protocol bmp, one rt_export_subscribe of best routes per table through the existing bmp_add_table path, the table name in the VRF/Table Name TLV, the F flag when the channel has an export filter, and the local AS and BGP ID of the per-peer header taken from the bmp protocol configuration and the router id. Mandatory BGP attributes synthesized for non-BGP routes, which RFC 9069 explicitly allows in a Loc-RIB. Does this mapping match how you would present BIRD tables as Loc-RIBs?
Looks reasonable to me. Please note that we expect to add options to exclude some protocol instances from BMP, and that may lead to a problem with having a best route from a peer. This has to be thought through and properly tested.
- Peer state. Whatever BMP needs beyond the current ea_bgp_* attributes (counters for statistics, VRF/RD for the RD Instance peer type and distinguisher, FSM event code for Peer Down) published by BGP in proto_state and read by BMP. I would like to agree on the attribute set before coding.
These attributes may get some refactoring quite soon, depends on the current state of structured filter types. For now, I would suggest adding these attributes early in a separate patch upfront, so that we can then refactor them together with others.
- Statistics. A timer in BMP. The counters live in the BGP channel import and export stats on BGP’s side, and they must not turn into a journal item per route update. Either BGP publishes a snapshot into proto_state on its own timer while some BMP instance wants statistics, or the counters become atomics that BMP’s timer reads. I lean to the first; which fits your locking rules better?
We expect all relevant statistics to become a subscribable object with possibly atomic access and triggers. That’s another refactoring pending which we have not yet architected properly.
It is going to be part of the CORECONF implementation, and I would consider this a prerequisite for stats in BMP as well.
- Adj-RIB-Out, post-policy only; pre-policy Adj-RIB-Out is out of scope. bgp_ptx already exposes a struct rt_exporter as c->c.out_table with feed_net implemented, but there is no live journal push yet (“TODO: actually implement exports” in bgp_free_pending_tx).
This observation is right.
I would push on prefix add/withdraw in the ptx path, only when the exporter has subscribers, and let BMP subscribe out_table the same way it subscribes import tables today.
Please note that monitoring Adj-RIB-Out post-policy by RFC 8671 does not monitor Adj-RIB-Out as meant by RFC 4271. There may be routes in Adj-RIB-Out which have not been sent yet, and if you want an RFC-compliant implementation, you need to hook into the BGP actually encoding the data into the TX buffer.
But (!) even this buffer may be then waiting for the kernel to get actually sent over TCP, and we have no good means of monitoring that.
Is this the merging of the BMP TX with the BGP TX data structures you mentioned in [1], and is anyone already working on it?
No. We want to convert the overall BMP implementation into just a variant of BGP with different encoding. That would allow sending deduplicated BMP updates, i.e. more prefixes with one attribute set, if applicable.
I suppose that nobody is working on that right now and it is pretty detached so it may be contributed, probably.
Yet there is another caveat → until next LTS version is released (which is approx. April 2027), we are merging BIRD 2 into BIRD 3 to keep the codebases aligned. There will be particularly nasty merge conflicts for sure in this.
[…]
- Tests. I could not find BMP cases in bird-tools netlab master. I would write them (BIRD to collector: Peer Up, route monitoring pre/post/out, End-of-RIB after the initial dump, Loc-RIB, statistics). David mentioned a BMP lab test case in April [2]; if that exists somewhere I would rather build on it.
They are there, brand new.
- Initial dump pacing. bmp_check_routes walks the whole feed in one event run and nothing is written to the socket until it returns, so the entire Adj-RIB-In dump (one message per route, roughly 130 bytes each, times pre/post) sits in TX buffers before the first byte goes out. Above “tx buffer limit” the session is declared stalled and reconnected, which starts the same dump again; with a table larger than the limit this loops forever, logging “Connection stalled” each time. I would break out of the walk after N routes or when the TX backlog passes a high-water mark derived from the limit, reschedule the event and let the socket drain in between. The stall at the hard limit stays for a collector that really does not read. Two questions: do you prefer this local to BMP, or implemented generically as rt_export_retry_later (which is declared but not defined)? And a paused reader keeps journal items of the table alive; is there a bound you want on that lag? This one is independent of the rest and I can send it first as a standalone patch.
This will be consumed by the aforementioned overhaul.
- Is this direction acceptable for thread-next? What would you do differently?
See above. Note: In this case it actually does make sense to go for BIRD 3 only, as the internal API for this is quite different in BIRD 2.
- Patch order I have in mind: dump pacing (6), BGP state attributes, Loc-RIB, statistics, per-peer header, Adj-RIB-Out, docs, tests. Adj-RIB-Out can also be a separate round later if you prefer.
More BGP state attributes are not blocked by anything, probably.
Loc-RIB seems to be quite doable for now, with some caveats.
Statistics need proper architecting and may block you for some time. We’ll look at it with others in the team and get back to you.
Adj-RIB-Out would benefit from the overall BMP refactoring. As that is quite a complicated thing regarding BIRD 2/3 merges, I would suggest doing this in a separate branch intended to be rebased onto BIRD 3.6 when we expect to stop the merging.
Note: There may be quite a lot to do on reconfiguration which I have not thought about too deeply.
- Does any of this collide with your unpublished plans for BGP TX or BMP?
See above.
BTW: The style and structure of your text suggest usage of an LLM. How much are you personally familiar with the BIRD codebase and BMP itself? Did you review what the LLM generated for you?
I somehow also expect that your contribution will be LLM-assisted. Are you going to be able to review your contribution fully and thoroughly before sending it to the upstream?
Thanks, and happy routing!
Maria
–
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.