From 1cbceeb5dd22dcb020764457c79326a3b3749f87 Mon Sep 17 00:00:00 2001 From: Pawel Foremski Date: Fri, 4 Sep 2026 12:49:54 +0200 Subject: [PATCH] fix: rv-live should honor the BMP peer A flag processRecord() parsed the BGP message without setting Meta.ParseAS4, so attribute parsing fell back to the pipe-wide caps, which default to CAP_AS4 on and CAP_AS_GUESS off. Peers that never negotiated RFC 6793 with the collector thus failed with "ASPATH: invalid ASPATH segment length: N < 2+4*M" and were dropped. Bmp.FromBytes() already parses the Per-Peer header, whose A flag (RFC 7854/4.2) announces the legacy 2-byte AS_PATH format. bmp.Reader.setMeta() uses it, so "read --format=obmp" has always handled such peers correctly - only the Kafka path ignored it. The flag is trusted only when set. Setting ParseAS4=1 on a clear flag would be the strict reading, but senders that never set it (routeviews, as of 2026-09) would then pin every peer to 4-byte ASNs and short-circuit the retry in attrs.Aspath.Unmarshal, silently breaking --guess-asn: measured against routeviews route-views7, --guess-asn went 0 -> 720 parse errors per ~90s. NB: must happen before fixPath(), which triggers attribute parsing. --- stages/rv-live/openbmp.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stages/rv-live/openbmp.go b/stages/rv-live/openbmp.go index 5ba9b9a..0fe2dc9 100644 --- a/stages/rv-live/openbmp.go +++ b/stages/rv-live/openbmp.go @@ -45,6 +45,13 @@ func (s *RvLive) processRecord(record *kgo.Record) error { return fmt.Errorf("dangling bytes after BGP message: %d/%d", n, len(bm.BgpData)) } + // the peer A flag announces the legacy 2-byte AS_PATH encoding (RFC 7854/4.2) + // NB: trust it only when set; routeviews never sets it, and assuming 4-byte + // ASNs on a clear flag would defeat --guess-asn + if bm.Peer.Is2ByteAS() { + m.ParseAS4 = -1 + } + // set time if !bm.Peer.Time.IsZero() { m.Time = bm.Peer.Time