From 5b33d477eab13d29a3368d87c2cc33311cb90e94 Mon Sep 17 00:00:00 2001 From: Mingwei Zhang Date: Fri, 6 Nov 2026 07:46:49 -0800 Subject: [PATCH 1/3] fix(parser): decode an NLRI block whole so a leading default route survives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parse_nlri_list read a leading 0x00 byte as an ADD-PATH path identifier and kept that reading for the rest of the block. A default route (RFC 4271 §4.3) is a valid non-ADD-PATH encoding of exactly that byte, so the four bytes after it were eaten as a path id, and the retry the memory optimization added in b3f52ad resumed at the failure position rather than the block start. Prefixes already decoded out of path-id bytes stayed in the list and the real ones were dropped. When both readings failed, the message became a MalformedNlri warning with an empty withdrawal list, so every withdrawal in it disappeared without an error. Decode the block whole under one reading, and fall back to the whole block under the other. ADD-PATH data wrapped in a non-ADD-PATH subtype still decodes with its path ids, which is the case the guess exists for; a plain block whose bytes also frame exactly as ADD-PATH still takes the guess, because nothing in the bytes decides between them. Verified against the three RIPE RIS files named in #360: an independent MRT decoder and this build now agree on all 1,039,666 records and on every prefix of the 1020-, 166- and 627-withdrawal messages. route-views.amsix 2020-06-17 18:30, the ADD-PATH-under-subtype-4 data from #31, is unchanged at 3,679,857 elements. --- CHANGELOG.md | 4 + src/parser/bgp/messages.rs | 25 +++++ src/parser/utils.rs | 197 ++++++++++++++++++++++++++++--------- 3 files changed, 177 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e1efc3..2725a207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ All notable changes to this project will be documented in this file. * **EVPN NLRI support** ([RFC 7432](https://datatracker.ietf.org/doc/html/rfc7432), [RFC 9136](https://datatracker.ietf.org/doc/html/rfc9136)): `MP_REACH_NLRI` and `MP_UNREACH_NLRI` for AFI 25 / SAFI 70 decode into `Nlri::evpn_nlris`, one `EvpnNlri` per route with its route distinguisher and a route-type-specific body: type 2 (MAC/IP advertisement: ESI, Ethernet tag, MAC, optional IP, label), type 3 (inclusive multicast), and type 5 (IP prefix). Route types 1 and 4 keep their octets in `EvpnRoutePayload::Raw`, and an EVPN end-of-RIB marker decodes to an empty list. Until now an EVPN BMP feed produced only `AttributeValue::Raw` and no fields at all. The encoder writes the same routes back, so `MrtRecord::try_from(&BmpMessage)` keeps converting EVPN route monitoring messages, and text output renders an `ANNOUNCED (EVPN)` / `WITHDRAWN (EVPN)` section instead of dropping them. ([#355](https://github.com/bgpkit/bgpkit-parser/pull/355)) * **MAC Mobility extended community encoder**: `ExtendedCommunity::MacMobility` re-encodes to the 8 wire octets, so a decoded EVPN route survives a decode/encode round trip of its communities. ([#355](https://github.com/bgpkit/bgpkit-parser/pull/355)) +### Fixed + +* **Withdrawals are no longer lost when an NLRI block starts with the default route**: `parse_nlri_list` took a leading `0x00` byte as an ADD-PATH path identifier, kept that reading for the rest of the block, and retried at the failure position, so a withdrawn list beginning with `0.0.0.0/0` or `::/0` dropped prefixes in the middle of the list, and a list that failed both ways became a `MalformedNlri` warning with no withdrawals at all. The ADD-PATH guess is now all-or-nothing for the block, and a failed guess re-parses the block from its start, which keeps ADD-PATH data wrapped in a non-ADD-PATH record (issue [#31](https://github.com/bgpkit/bgpkit-parser/issues/31)) decoding with its path ids. In RIPE RIS 2026-02 updates files a 1020-withdrawal message and a 166-withdrawal message returned nothing, and a 627-withdrawal message kept its element count while losing 11 real prefixes and inventing 7. ([#360](https://github.com/bgpkit/bgpkit-parser/issues/360)) + ## v0.23.0 - 2026-10-17 ### Breaking changes diff --git a/src/parser/bgp/messages.rs b/src/parser/bgp/messages.rs index 62351226..1979d47e 100644 --- a/src/parser/bgp/messages.rs +++ b/src/parser/bgp/messages.rs @@ -2012,4 +2012,29 @@ mod tests { panic!("Expected Capacities in second parameter"); } } + + #[test] + fn test_parse_bgp_update_message_keeps_withdrawals_starting_with_default_route() { + // Withdrawn routes 0.0.0.0/0, 1.0.0.0/24, 1.0.4.0/24, no attributes, no announced NLRI. + // A leading default route must not be read as an ADD-PATH path identifier (#360). + let withdrawn: &[u8] = &[ + 0x00, // 0.0.0.0/0 + 0x18, 0x01, 0x00, 0x00, // 1.0.0.0/24 + 0x18, 0x01, 0x00, 0x04, // 1.0.4.0/24 + ]; + let mut buf = BytesMut::new(); + buf.put_u16(withdrawn.len() as u16); + buf.put_slice(withdrawn); + buf.put_u16(0); + + let msg = parse_bgp_update_message(buf.freeze(), false, &AsnLength::Bits32).unwrap(); + let got: Vec = msg + .withdrawn_prefixes + .iter() + .map(|p| p.prefix.to_string()) + .collect(); + assert_eq!(got, vec!["0.0.0.0/0", "1.0.0.0/24", "1.0.4.0/24"]); + assert!(msg.withdrawn_prefixes.iter().all(|p| p.path_id.is_none())); + assert!(msg.attributes.validation_warnings().is_empty()); + } } diff --git a/src/parser/utils.rs b/src/parser/utils.rs index 11cbfc52..32690acc 100644 --- a/src/parser/utils.rs +++ b/src/parser/utils.rs @@ -12,7 +12,6 @@ use crate::error::ParserError; use crate::models::*; use crate::ParserError::TruncatedMsg; use bytes::{Buf, BufMut, Bytes, BytesMut}; -use log::debug; use regex::Regex; use std::net::IpAddr; @@ -283,48 +282,55 @@ fn try_parse_prefix( Ok((NetworkPrefix::new(prefix, path_id), pos)) } -pub fn parse_nlri_list( +/// Decode an NLRI block with a known ADD-PATH setting. +/// +/// Every entry is decoded the same way, and an error discards the whole block: partially decoded +/// prefixes must not escape to the caller. +fn parse_nlri_list_exact( mut input: Bytes, add_path: bool, afi: &Afi, ) -> Result, ParserError> { let mut prefixes = Vec::new(); - let mut is_add_path = add_path; - let mut use_heuristic = false; - while input.remaining() > 0 { - let data = input.as_ref(); - - // Check heuristic: if not add_path and first byte is 0, likely Add-Path format - if !is_add_path && !data.is_empty() && data[0] == 0 { - debug!("NLRI: first byte is 0, treating as Add-Path format"); - is_add_path = true; - use_heuristic = true; - } - - // Try parsing - let (prefix, consumed) = match try_parse_prefix(data, afi, is_add_path) { - Ok(result) => result, - Err(_) if use_heuristic => { - // Heuristic was wrong, retry with original add_path setting - debug!( - "NLRI: Add-Path heuristic failed, retrying with add_path={}", - add_path - ); - is_add_path = add_path; - use_heuristic = false; - try_parse_prefix(data, afi, add_path)? - } - Err(e) => return Err(e), - }; - + let (prefix, consumed) = try_parse_prefix(input.as_ref(), afi, add_path)?; input.advance(consumed); prefixes.push(prefix); } - Ok(prefixes) } +/// Parse an NLRI block, resolving a leading `0x00` byte that the ADD-PATH flag cannot explain. +/// +/// A block starting with `0x00` is ambiguous. RFC 4271 §4.3 reads it as a prefix length of 0, the +/// default route. Some producers instead wrap an ADD-PATH message in a non-ADD-PATH record, where +/// the same byte is the first octet of a path identifier (issue #31), and guessing matters there: +/// without it two thirds of the elements of such a file disappear. +/// +/// The guess is made over the whole block, and a block the ADD-PATH reading cannot consume falls +/// back to the flag. Retrying at the failure position, the previous behaviour, kept the prefixes +/// already decoded out of path-id bytes and dropped the real ones, which emptied or corrupted +/// withdrawal lists that begin with the default route (#360). +/// +/// A plain block whose bytes also happen to frame exactly as ADD-PATH is still read as ADD-PATH: +/// the bytes carry nothing that decides between them, and on the data that motivated the guess the +/// ADD-PATH reading is the correct one (see `test_parse_nlri_list_ambiguous_block_prefers_add_path`). +pub fn parse_nlri_list( + input: Bytes, + add_path: bool, + afi: &Afi, +) -> Result, ParserError> { + if add_path { + return parse_nlri_list_exact(input, true, afi); + } + if input.first() == Some(&0) { + if let Ok(prefixes) = parse_nlri_list_exact(input.clone(), true, afi) { + return Ok(prefixes); + } + } + parse_nlri_list_exact(input, false, afi) +} + pub fn encode_asn(asn: &Asn, asn_len: &AsnLength) -> Bytes { let mut bytes = BytesMut::new(); match asn_len { @@ -1018,24 +1024,117 @@ mod tests { } #[test] - fn test_parse_nlri_list_heuristic_then_retry() { - // This test verifies the retry mechanism works correctly - // We create data that looks like Add-Path (starts with 0) but isn't valid as such - // This should trigger heuristic, fail, then retry successfully - - // Data: first byte is 0 (triggers heuristic for add-path) - // But if parsed as add-path: path_id=0, len=0, which is valid /0 - // Actually this is a valid Add-Path format for default route - let input = Bytes::from(vec![ - 0x00, // Could be interpreted as: - // - Non-Add-Path: prefix_len = 0 (/0 default) - // - Add-Path: path_id[0] of 4-byte path_id - ]); + fn test_parse_nlri_list_single_default_route() { + // A lone 0x00 is a prefix length of 0 with no address octets: the default route. + let prefixes = parse_nlri_list(Bytes::from_static(&[0x00]), false, &Afi::Ipv4).unwrap(); + assert_eq!(prefixes.len(), 1); + assert_eq!(prefixes[0].prefix.to_string(), "0.0.0.0/0"); + assert_eq!(prefixes[0].path_id, None); + } + + // A block whose first prefix is the default route is not an ADD-PATH block. Reading the 0x00 as + // a path identifier shifted the decode and dropped or invented withdrawals (#360). + fn assert_ipv4_block(block: &'static [u8], expected: &[&str]) { + let prefixes = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); + let got: Vec = prefixes.iter().map(|p| p.prefix.to_string()).collect(); + assert_eq!(got, expected); + assert!( + prefixes.iter().all(|p| p.path_id.is_none()), + "non-ADD-PATH block must not produce path ids" + ); + } + + #[test] + fn test_parse_nlri_list_non_addpath_default_route_at_head() { + assert_ipv4_block( + &[ + 0x00, // 0.0.0.0/0 + 0x18, 0x01, 0x00, 0x00, // 1.0.0.0/24 + 0x18, 0x01, 0x00, 0x04, // 1.0.4.0/24 + 0x18, 0x01, 0x00, 0x05, // 1.0.5.0/24 + 0x18, 0x01, 0x00, 0x06, // 1.0.6.0/24 + ], + &[ + "0.0.0.0/0", + "1.0.0.0/24", + "1.0.4.0/24", + "1.0.5.0/24", + "1.0.6.0/24", + ], + ); + } - // Both interpretations should work for this simple case - let result = parse_nlri_list(input.clone(), false, &Afi::Ipv4); - // Should succeed with either interpretation - assert!(result.is_ok() || result.is_err()); - // The key is: no panic, and if it succeeds, it should be consistent + #[test] + fn test_parse_nlri_list_non_addpath_default_route_in_middle() { + assert_ipv4_block( + &[ + 0x18, 0x01, 0x00, 0x00, // 1.0.0.0/24 + 0x00, // 0.0.0.0/0 + 0x18, 0x01, 0x00, 0x04, // 1.0.4.0/24 + ], + &["1.0.0.0/24", "0.0.0.0/0", "1.0.4.0/24"], + ); + } + + #[test] + fn test_parse_nlri_list_non_addpath_default_route_at_tail() { + assert_ipv4_block( + &[ + 0x18, 0x01, 0x00, 0x00, // 1.0.0.0/24 + 0x18, 0x01, 0x00, 0x04, // 1.0.4.0/24 + 0x00, // 0.0.0.0/0 + ], + &["1.0.0.0/24", "1.0.4.0/24", "0.0.0.0/0"], + ); + } + + #[test] + fn test_parse_nlri_list_non_addpath_ipv6_default_route_at_head() { + let block = &[ + 0x00, // ::/0 + 0x30, 0x2a, 0x0a, 0x02, 0xc0, 0x00, 0x1a, // 2a0a:2c0:1a::/48 + 0x2a, 0x26, 0x20, 0x01, 0x29, 0x20, 0x00, // 2620:129:2000::/42 + 0x20, 0x28, 0x04, 0x50, 0x5c, // 2804:505c::/32 + ]; + let prefixes = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv6).unwrap(); + let got: Vec = prefixes.iter().map(|p| p.prefix.to_string()).collect(); + assert_eq!( + got, + vec![ + "::/0", + "2a0a:2c0:1a::/48", + "2620:129:2000::/42", + "2804:505c::/32" + ] + ); + assert!(prefixes.iter().all(|p| p.path_id.is_none())); + } + + #[test] + fn test_parse_nlri_list_ambiguous_block_prefers_add_path() { + // Bytes from route-views.amsix 2020-06-17 18:30 UTC: ADD-PATH data under a non-ADD-PATH + // subtype, one entry. Framing it without path ids yields a run of /0 prefixes, framing it + // with them yields the real route. Both readings consume the block, and this is the reading + // the data requires, so the guess stays on ties. + let block = &[0x00, 0x00, 0x01, 0xe2, 0x18, 0x8a, 0x61, 0x16]; + let plain = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); + assert_eq!(plain.len(), 1); + assert_eq!(plain[0].prefix.to_string(), "138.97.22.0/24"); + assert_eq!(plain[0].path_id, Some(482)); + } + + #[test] + fn test_parse_nlri_list_wrapped_addpath_block_keeps_path_ids() { + // ADD-PATH data under a non-ADD-PATH flag still has to decode with its path ids (#31). + let block = &[ + 0x00, 0x00, 0x00, 0x01, 0x18, 0xc0, 0xa8, 0x01, // path_id 1, 192.168.1.0/24 + 0x00, 0x00, 0x00, 0x02, 0x18, 0xc0, 0xa8, 0x02, // path_id 2, 192.168.2.0/24 + ]; + let prefixes = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); + assert_eq!(prefixes.len(), 2); + assert_eq!(prefixes[0].prefix.to_string(), "192.168.1.0/24"); + assert_eq!(prefixes[1].prefix.to_string(), "192.168.2.0/24"); + assert_eq!(prefixes[0].path_id, Some(1)); + assert_eq!(prefixes[1].path_id, Some(2)); } } From 1eb8521d51fd7bee27c9f3f87c9523a0eac034d5 Mon Sep 17 00:00:00 2001 From: Mingwei Zhang Date: Fri, 6 Nov 2026 08:17:29 -0800 Subject: [PATCH 2/3] docs(parser): scope the #360 changelog claim and log the tie-break The Fixed entry said withdrawals are no longer lost when a block starts with the default route. A short block that frames exactly as ADD-PATH is still decoded that way, so 0.0.0.0/0 followed by one /24 keeps losing the /24. Scope the headline to a guess that cannot frame the block, name the limitation in the entry and in the doc comment, and pin it with a test so the behaviour cannot drift silently. Also restore a debug trace when the guess is taken and when it fails, which the old heuristic emitted, and correct the "two thirds" figure to the measured 74% of the amsix file. --- CHANGELOG.md | 2 +- src/parser/utils.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2725a207..76e85247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. ### Fixed -* **Withdrawals are no longer lost when an NLRI block starts with the default route**: `parse_nlri_list` took a leading `0x00` byte as an ADD-PATH path identifier, kept that reading for the rest of the block, and retried at the failure position, so a withdrawn list beginning with `0.0.0.0/0` or `::/0` dropped prefixes in the middle of the list, and a list that failed both ways became a `MalformedNlri` warning with no withdrawals at all. The ADD-PATH guess is now all-or-nothing for the block, and a failed guess re-parses the block from its start, which keeps ADD-PATH data wrapped in a non-ADD-PATH record (issue [#31](https://github.com/bgpkit/bgpkit-parser/issues/31)) decoding with its path ids. In RIPE RIS 2026-02 updates files a 1020-withdrawal message and a 166-withdrawal message returned nothing, and a 627-withdrawal message kept its element count while losing 11 real prefixes and inventing 7. ([#360](https://github.com/bgpkit/bgpkit-parser/issues/360)) +* **Withdrawals are no longer lost when the ADD-PATH guess cannot frame an NLRI block that starts with the default route**: `parse_nlri_list` took a leading `0x00` byte as an ADD-PATH path identifier, kept that reading for the rest of the block, and retried at the failure position, so a withdrawn list beginning with `0.0.0.0/0` or `::/0` dropped prefixes in the middle of the list, and a list that failed both ways became a `MalformedNlri` warning with no withdrawals at all. The ADD-PATH guess is now all-or-nothing for the block, and a failed guess re-parses the block from its start, which keeps ADD-PATH data wrapped in a non-ADD-PATH record (issue [#31](https://github.com/bgpkit/bgpkit-parser/issues/31)) decoding with its path ids. A block whose bytes frame under both readings is still decoded as ADD-PATH, so a short non-ADD-PATH list of that shape keeps the old reading. In RIPE RIS 2026-02 updates files a 1020-withdrawal message and a 166-withdrawal message returned nothing, and a 627-withdrawal message kept its element count while losing 11 real prefixes and inventing 7. ([#360](https://github.com/bgpkit/bgpkit-parser/issues/360)) ## v0.23.0 - 2026-10-17 diff --git a/src/parser/utils.rs b/src/parser/utils.rs index 32690acc..cf703788 100644 --- a/src/parser/utils.rs +++ b/src/parser/utils.rs @@ -12,6 +12,7 @@ use crate::error::ParserError; use crate::models::*; use crate::ParserError::TruncatedMsg; use bytes::{Buf, BufMut, Bytes, BytesMut}; +use log::debug; use regex::Regex; use std::net::IpAddr; @@ -305,7 +306,7 @@ fn parse_nlri_list_exact( /// A block starting with `0x00` is ambiguous. RFC 4271 §4.3 reads it as a prefix length of 0, the /// default route. Some producers instead wrap an ADD-PATH message in a non-ADD-PATH record, where /// the same byte is the first octet of a path identifier (issue #31), and guessing matters there: -/// without it two thirds of the elements of such a file disappear. +/// without it almost three quarters of the elements of such a file disappear. /// /// The guess is made over the whole block, and a block the ADD-PATH reading cannot consume falls /// back to the flag. Retrying at the failure position, the previous behaviour, kept the prefixes @@ -315,6 +316,7 @@ fn parse_nlri_list_exact( /// A plain block whose bytes also happen to frame exactly as ADD-PATH is still read as ADD-PATH: /// the bytes carry nothing that decides between them, and on the data that motivated the guess the /// ADD-PATH reading is the correct one (see `test_parse_nlri_list_ambiguous_block_prefers_add_path`). +/// A short block of that shape, `0.0.0.0/0` followed by one prefix, is still misread. pub fn parse_nlri_list( input: Bytes, add_path: bool, @@ -324,9 +326,11 @@ pub fn parse_nlri_list( return parse_nlri_list_exact(input, true, afi); } if input.first() == Some(&0) { + debug!("NLRI: block starts with 0x00, trying the ADD-PATH framing"); if let Ok(prefixes) = parse_nlri_list_exact(input.clone(), true, afi) { return Ok(prefixes); } + debug!("NLRI: the ADD-PATH framing does not consume the block, decoding with the flag"); } parse_nlri_list_exact(input, false, afi) } @@ -1123,6 +1127,18 @@ mod tests { assert_eq!(plain[0].path_id, Some(482)); } + #[test] + fn test_parse_nlri_list_short_ambiguous_block_is_read_as_add_path() { + // 0.0.0.0/0 followed by one /24 also frames exactly as a single ADD-PATH entry, so the + // guess stays on and the /24 is lost. The bytes decide nothing here; the limitation is + // deliberate and recorded in the CHANGELOG. + let block = &[0x00, 0x18, 0x01, 0x00, 0x00]; + let prefixes = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); + assert_eq!(prefixes.len(), 1); + assert_eq!(prefixes[0].prefix.to_string(), "0.0.0.0/0"); + assert!(prefixes[0].path_id.is_some()); + } + #[test] fn test_parse_nlri_list_wrapped_addpath_block_keeps_path_ids() { // ADD-PATH data under a non-ADD-PATH flag still has to decode with its path ids (#31). From 9e85b3bec9c8d115d7af1509d9320012378427a4 Mon Sep 17 00:00:00 2001 From: Mingwei Zhang Date: Fri, 6 Nov 2026 08:30:27 -0800 Subject: [PATCH 3/3] docs(parser): name both findings a failed NLRI block produces A block that fails under both framings does not always yield a MalformedNlri finding: that is the classic IPv4 withdrawn/announced field path, while a failing MP_UNREACH_NLRI attribute is stored raw and raises OptionalAttributeError. Say which field produces which, and assert in the tie-break test that the plain framing also consumes the block, so the premise the decision rests on is executable. --- CHANGELOG.md | 2 +- src/parser/utils.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76e85247..c319aaf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file. ### Fixed -* **Withdrawals are no longer lost when the ADD-PATH guess cannot frame an NLRI block that starts with the default route**: `parse_nlri_list` took a leading `0x00` byte as an ADD-PATH path identifier, kept that reading for the rest of the block, and retried at the failure position, so a withdrawn list beginning with `0.0.0.0/0` or `::/0` dropped prefixes in the middle of the list, and a list that failed both ways became a `MalformedNlri` warning with no withdrawals at all. The ADD-PATH guess is now all-or-nothing for the block, and a failed guess re-parses the block from its start, which keeps ADD-PATH data wrapped in a non-ADD-PATH record (issue [#31](https://github.com/bgpkit/bgpkit-parser/issues/31)) decoding with its path ids. A block whose bytes frame under both readings is still decoded as ADD-PATH, so a short non-ADD-PATH list of that shape keeps the old reading. In RIPE RIS 2026-02 updates files a 1020-withdrawal message and a 166-withdrawal message returned nothing, and a 627-withdrawal message kept its element count while losing 11 real prefixes and inventing 7. ([#360](https://github.com/bgpkit/bgpkit-parser/issues/360)) +* **Withdrawals are no longer lost when the ADD-PATH guess cannot frame an NLRI block that starts with the default route**: `parse_nlri_list` took a leading `0x00` byte as an ADD-PATH path identifier, kept that reading for the rest of the block, and retried at the failure position, so a withdrawn list beginning with `0.0.0.0/0` or `::/0` dropped prefixes in the middle of the list, and a list that failed both ways left the message with none of those withdrawals: the classic IPv4 fields came back as an empty list plus a `MalformedNlri` finding, and a failing `MP_UNREACH_NLRI` attribute was kept raw with an `OptionalAttributeError` finding. The ADD-PATH guess is now all-or-nothing for the block, and a failed guess re-parses the block from its start, which keeps ADD-PATH data wrapped in a non-ADD-PATH record (issue [#31](https://github.com/bgpkit/bgpkit-parser/issues/31)) decoding with its path ids. A block whose bytes frame under both readings is still decoded as ADD-PATH, so a short non-ADD-PATH list of that shape keeps the old reading. In RIPE RIS 2026-02 updates files a 1020-withdrawal message and a 166-withdrawal message returned nothing, and a 627-withdrawal message kept its element count while losing 11 real prefixes and inventing 7. ([#360](https://github.com/bgpkit/bgpkit-parser/issues/360)) ## v0.23.0 - 2026-10-17 diff --git a/src/parser/utils.rs b/src/parser/utils.rs index cf703788..faa520d1 100644 --- a/src/parser/utils.rs +++ b/src/parser/utils.rs @@ -1121,6 +1121,10 @@ mod tests { // with them yields the real route. Both readings consume the block, and this is the reading // the data requires, so the guess stays on ties. let block = &[0x00, 0x00, 0x01, 0xe2, 0x18, 0x8a, 0x61, 0x16]; + // Both readings have to consume the block for this to be the tie the wrapper resolves. + let framed = parse_nlri_list_exact(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); + assert_eq!(framed.len(), 4); + assert!(framed.iter().all(|p| p.path_id.is_none())); let plain = parse_nlri_list(Bytes::from_static(block), false, &Afi::Ipv4).unwrap(); assert_eq!(plain.len(), 1); assert_eq!(plain[0].prefix.to_string(), "138.97.22.0/24");