pub fn parse_nlri_list(
input: Bytes,
add_path: bool,
afi: &Afi,
) -> Result<Vec<NetworkPrefix>, ParserError>Expand description
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 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 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).
A short block of that shape, 0.0.0.0/0 followed by one prefix, is still misread.