Conversation
RFC 5881 describes single-hop BFD for IPv4 and IPv6, and in it there's a requirement to set the TLL/Hop Limit to 255 for all control packets. We weren't updating the value on the UdpSocket we use to send our control packets, allowing the OS to pick its own defaults. This was discovered when doing manual validation of dual-stack BFD for static routes with FRR as our peer. IPv4 sessions came all the way up, but IPv6 sessions never did. Debug logs on the FRR side showed the following errors, which were the dead giveaway of the issue: ``` 2026-03-04 19:25:53 [DEBG] bfdd: [YA0Q5-C0BPV] control-packet: invalid TTL: 60 expected 255 [mhop:no peer:fd00:101::6 local:fd00:101::5 port:4] 2026-03-04 19:25:53 [DEBG] bfdd: [YA0Q5-C0BPV] control-packet: invalid TTL: 60 expected 255 [mhop:no peer:fd00:101::2 local:fd00:101::1 port:2] 2026-03-04 19:25:54 [DEBG] bfdd: [YA0Q5-C0BPV] control-packet: invalid TTL: 60 expected 255 [mhop:no peer:fd00:101::a local:fd00:101::9 port:3] ```
Stop allocating a new UdpSocket for every BFD packet we transmit. That's horribly inefficient and unnecessary. Restructures egress() to use nested loops with different break conditions based on the type of error: socket errors trigger a new socket creation while channel errors still break out of the egress function. Fixes: #655
Contributor
Author
|
Manual testing confirmed this branch fixes BFD for IPv6 and doesn't break IPv4. Switch1: FRR: |
internet-diglett
approved these changes
Mar 11, 2026
Reduce the amount of times we supply default args to logger by creating a child logger with the k/v attributes attached.
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.
First and foremost, this PR adds explicit settings for TTL / Hop Limit to ensure control packets are always sent using 255 (mandated by RFC 5881). There is also a little bit of cleanup done to the egress() function to avoid creating a new socket for every packet we send. It also adds unit tests to validate the TTL/HL change and updates the existing tests to include IPv6 peers in addition to IPv4 peers. One other small cleanup is added to use a type alias throughout the BFD codebase instead of just in a single file.
Fixes #660
Fixes #655
Fixes #531