Repository navigation
feat(bgp): optional attribute-255 clock on announcements - #2
Merged
Merged
Conversation
A `[[prefixes]]` entry with `dev_attr255_interval_secs = N` attaches attribute 255 (reserved for development, RFC 2042) carrying a 13-byte BGPKIT clock payload (`BGPKIT` magic, version, refresh round, unix seconds) to that prefix's announcements, re-announced every N seconds. The refresh task is scheduled per distinct interval at startup and re-reads the effective originated set on each tick, so a runtime suppression silences it and `prefix add` keeps the configured clock for the same network. The attribute is originated with OPTIONAL|TRANSITIVE; downstream speakers set PARTIAL per RFC 4271. Config validation rejects a refresh interval of 0. Tests: a fixed payload vector (including the 65,536 round wrap), encoded wire bytes plus a parse-back flag check, config roundtrip and zero-reject, and socket-level acceptance coverage where a refresh advances the embedded time and a runtime re-add keeps the clock.
digizeph
requested
a balanced review from Copilot
and removed request for
Copilot
September 29, 2026 01:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional per-prefix clock carried in attribute 255 (reserved for development, RFC 2042).
A
[[prefixes]]entry withdev_attr255_interval_secs = Nattaches a 13-byte payload to that prefix's announcements and re-announces it every N seconds. The field is optional, absent means no attribute, and0is rejected by config validation.Payload layout:
BGPKITmagic (6) + version (1) + refresh round (2, big-endian) + unix seconds (4, big-endian). The round is redundant with the timestamp once the interval is known, but it makes a single sample self-contained: a collector can count missed refreshes without knowing the cadence, and two samples reveal it. The container is deliberately not another originator's shape, so a code-255 sample is attributable from the payload alone.The attribute is originated with
OPTIONAL|TRANSITIVEexplicitly, rather thanDevelopment's.into()default, which also sets PARTIAL. The first downstream speaker that does not recognize the attribute sets PARTIAL per RFC 4271, so collector copies of the same update can reade0 ff 0d .... Whether they do, and where the payload stops changing, is the measurement this exists for. Originating an unknown optional-transitive attribute is DFZ-visible by construction, so it stays scoped to our own prefixes and is detachable by re-announcing without it.Runtime interaction: one refresh task per distinct interval re-dispatches the announcement and re-reads the effective prefix set on each tick, so a runtime suppression silences the clock and
prefix addon a configured network keeps it. Clearing the field and reloading detaches the attribute; scheduling a newly added or changed interval takes effect after a daemon restart.Tests cover the payload vector, the encoded bytes plus parse-back flags, the config roundtrip with zero rejection, and the socket-level refresh and runtime re-add paths.
Base is
feat/collector-revision; retarget tomainonce that branch lands.Note on CI: the
Rustworkflow only triggers for pull requests based onmain, so this PR runs no CI. Local results on this commit:cargo fmt --checkclean,cargo clippy --all-targets --all-features -- -D warningsclean,cargo test --all-features49 passed / 0 failed (42 lib, 6acceptance_peer, 1archive_integration).