server: use configured local address for nexthop when set#3420
Draft
sergei-ilisavskii wants to merge 1 commit into
Draft
server: use configured local address for nexthop when set#3420sergei-ilisavskii wants to merge 1 commit into
sergei-ilisavskii wants to merge 1 commit into
Conversation
When Transport.Config.LocalAddress is set to a specific (non-wildcard) address, override Transport.State.LocalAddress with it instead of using the TCP connection's local address. This is needed for deployments where the BGP listener binds to an internal address (e.g. VRFs over GENEVE tunnels) but the configured address should be advertised as the nexthop. The override is applied in fsm.stateChange() when the session reaches ESTABLISHED, which is the single point where Transport.State.LocalAddress is written. All downstream consumers (PeerInfo, nexthop rewrite, watch events) read from Transport.State and automatically get the correct value. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
I need to do additional tests, will come back with results soon |
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.
Summary
When
Transport.Config.LocalAddressis set to a specific (non-wildcard) address, overrideTransport.State.LocalAddresswith it instead of using the TCP connection's local address. This ensures the configured address is advertised as the BGP nexthop.This is needed for deployments where the BGP listener binds to an internal address (e.g., VRFs over GENEVE tunnels) but the configured local address is what should be advertised as the nexthop. Without this fix, the TCP connection's local address (the listener's bind address) is used, resulting in incorrect nexthop advertisement.
Background
This issue was originally addressed in #2827 and #2839 (both closed). The fix was applied to downstream forks and evolved with IPv6 improvements, but was inadvertently removed during two upstream refactoring commits:
075aab46("convert PeerInfo to use netip instead of net", Aug 2025) removed the override fromhandleFSMMessage0c74e9c6("server: remove access to fsm.conn in server", Oct 2025) removed the override fromtoConfigApproach
Rather than re-adding the override in two separate locations in
server.goas the original PRs did, this fix applies the override infsm.stateChange()— the single point whereTransport.State.LocalAddressis written when a session reaches ESTABLISHED. All downstream consumers (NewPeerInfo,prePolicyFilterpath/nexthop rewrite, watch events) read fromTransport.Stateand automatically get the correct value.The override only applies when the configured address is valid and non-unspecified (not
0.0.0.0or::). IPv6 zone information is stripped since BGP nexthop attributes cannot carry zone info.Test plan
TestStateChangeLocalAddressOverridewith 6 sub-tests covering:go build ./...passesgo vet ./pkg/server/...passes🤖 Generated with Claude Code