Skip to content

Add support for End-of-RIB marker elems#258

Open
alistairking wants to merge 10 commits into
CAIDA:masterfrom
alistairking:a6r--eor
Open

Add support for End-of-RIB marker elems#258
alistairking wants to merge 10 commits into
CAIDA:masterfrom
alistairking:a6r--eor

Conversation

@alistairking

Copy link
Copy Markdown
Member

BGPStream previously discarded BGP End-of-RIB markers (RFC 4724): they arrive as empty UPDATE messages that yield zero elems, so consumers had no way to tell when a peer had finished sending its initial table dump after a session/graceful restart.

This adds a new BGPSTREAM_ELEM_TYPE_END_OF_RIB elem type. Detection happens in the shared update-processing path (so it covers MRT, BMP, and RIS Live): a completely empty UPDATE is treated as an IPv4-unicast EoR (0.0.0.0/0), and an UPDATE carrying only an empty MP_UNREACH for a unicast AFI is treated as an EoR for that address family (e.g. ::/0 for IPv6). Non-unicast cases are ignored (bgpstream is unicast-only anyway).

The new type is filterable via elemtype endofrib and is included by default (like all other elem types) when no elemtype filter is set. In the native ASCII output it appears with an E type character; the bgpdump-compatible output deliberately omits it, since the original RIPE bgpdump tool has no representation for EoR markers and we want to stay faithful to that format.

Also fixes a latent bug in the RIS Live format plugin where a recycled record slot kept a stale msg_type, which could cause a cleared UPDATE buffer to be reprocessed — previously harmless (zero elems), but it would have produced a spurious EoR elem with this change.

Copilot AI 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.

Pull request overview

This PR adds first-class support for BGP End-of-RIB (EoR) markers (RFC 4724) by emitting a new BGPSTREAM_ELEM_TYPE_END_OF_RIB element, making EoRs visible to consumers across MRT/BMP/RIS Live parsing and filterable via elemtype=endofrib. It also updates output formatting to represent (or intentionally omit) EoRs depending on the output format, and fixes a RIS Live record-reuse bug that could otherwise cause mis-processing.

Changes:

  • Add EoR detection in the shared UPDATE processing path and emit BGPSTREAM_ELEM_TYPE_END_OF_RIB.
  • Add endofrib element-type filtering support and ASCII output support (E), while deliberately omitting EoRs from bgpdump-compatible output.
  • Fix RIS Live format state reuse by clearing msg_type when recycling record data.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/bgpreader.c Documents E elem type in ASCII header and skips empty bgpdump lines (needed for EoR omission).
lib/formats/bs_format_rislive.c Clears recycled msg_type to avoid stale-type reprocessing.
lib/formats/bgpstream_parsebgp_common.h Adds eor_done flag to ensure one EoR elem per UPDATE record.
lib/formats/bgpstream_parsebgp_common.c Implements EoR detection and emission in shared UPDATE processing.
lib/bgpstream_record.c Adds elemtype-mask filtering for the new END_OF_RIB elem type.
lib/bgpstream_filter.h Introduces BGPSTREAM_FILTER_ELEM_TYPE_END_OF_RIB mask bit.
lib/bgpstream_filter.c Parses elemtype=endofrib and sets the new mask bit.
lib/bgpstream_elem.h Adds BGPSTREAM_ELEM_TYPE_END_OF_RIB enum value.
lib/bgpstream_elem.c Adds ASCII type char E and custom ASCII serialization for END_OF_RIB.
lib/bgpstream_bgpdump.c Emits an empty string for END_OF_RIB to stay faithful to original bgpdump output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/formats/bgpstream_parsebgp_common.c
Comment thread lib/formats/bgpstream_parsebgp_common.c Outdated
Comment thread lib/formats/bgpstream_parsebgp_common.c

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@alistairking alistairking marked this pull request as ready for review June 30, 2026 23:11
@alistairking

Copy link
Copy Markdown
Member Author

Tested this with (a lot) of assistance from @0x0ac and it seems to do the right thing. For example:

bgpreader -d kafka -o "brokers=stream.routeviews.org:9092" -o "topic=routeviews.peru.32590.bmp_raw" -o "offset=latest" -f "elemtype peerstates endofrib"

U|S|1780612754.941837||bmp-02|peru|45.183.45.210|32590|45.183.47.120|||||||ACTIVE

U|S|1780612754.941837||bmp-02|peru|45.183.45.210|32590|2803:cd60:6411:5::2c|||||||ACTIVE

U|E|1782860820.922348||bmp-02|peru|45.183.45.210|32590|45.183.47.120|0.0.0.0/0||||||

U|E|1782860823.786587||bmp-02|peru|45.183.45.210|32590|2803:cd60:6411:5::2c|::/0||||||

(extra line breaks added by me for legibility)

Copilot AI 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.

Pull request overview

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

Comment thread lib/formats/bgpstream_parsebgp_common.c
Comment thread lib/formats/bgpstream_parsebgp_common.c Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Comment thread test/bgpstream-test-eor.c
strcmp(buf, exp->prefixes[e]) == 0);
e++;
}
CHECK_MSG(exp->desc, "elem count", e == exp->n_elems);
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