bgp-ls: accept prefix-length 0 in LsTLVIPReachability (default route)#3458
Closed
Vadims06 wants to merge 1 commit into
Closed
bgp-ls: accept prefix-length 0 in LsTLVIPReachability (default route)#3458Vadims06 wants to merge 1 commit into
Vadims06 wants to merge 1 commit into
Conversation
Member
|
Pushed, thanks! |
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.
Problem
GoBGP rejects a BGP-LS IPv4/IPv6 Topology Prefix NLRI whose IP Reachability Information TLV (type 265) carries prefix-length 0 (the default route
0.0.0.0/0or::/0), sending a NOTIFICATION and resetting the session in a loop.Observed with a Huawei NE40E advertising
default-route-advertise alwaysinto BGP-LS. The session reached ESTABLISHED but immediately dropped:Root cause
LsTLVIPReachability.DecodeFromBytesinpkg/packet/bgp/bgp.gohad two overly strict guards:if len(value) < 2— rejects a 1-byte value, but for prefix-length 0 the TLV value is exactly 1 byte (the0x00prefix-length octet with zero prefix bytes following).if value[0] > 128 || value[0] == 0— explicitly rejects prefix-length 0.A default route is a valid BGP-LS Prefix NLRI per RFC 7752 §3.2.3.2: prefix-length 0 → 0 prefix bytes → TLV value length 1.
toPrefix()had the same latent bug:(int(0)-1)/8+1evaluates to 1 (not 0) due to Go integer truncation, producing a wrongbytescount masked only by theif i >= len(l.Prefix) { break }guard inside the copy loop.Fix
< 1.value[0] == 0rejection.llas 0 when prefix-length is 0.toPrefix()for correctness.Test
Added a table-driven case for the exact captured TLV bytes
{0x01, 0x09, 0x00, 0x01, 0x00}(type 265, len 1, value0x00), verifying decode toprefix_length=0, prefix=[].