bgp: honor the configured transport local address #633
This fixes a separate bug: on master, if a peer has no session, UpdatePeer with a change in needs_teardown cancels the dial loop and nothing starts it again. For example, changing remote_port or passive (true to false) on an idle peer. Please move this fix to a separate commit with a test.
This is a behavior change that is not related to local-address. Before this patch, a bind_device() error was ignored. Now the connection fails. This is the same as GoBGP, so the change itself is fine. Can you split it out as a preparatory commit? It can change the socket setup to return errors, and then the local-address commit only adds the bind() call.
Before this patch, connect errors were not logged. connect_retry_time is 3 seconds by default, so this prints a warning every 3 seconds while the peer is down. Can we log only the socket setup errors (bind_device, bind) at warn level, and the connect error at debug level?
I want to keep the README to the essential information only. If you want to add this kind of detail, please add a new file instead, for example docs/configuration.md.
Requested changes.
moved this into its own commit, 499904e. Added tests, both fail without the fix.
As suggested - split this into preparatory commit 61e4ff3, including a regression test for failed device binding. The local-address commit now adds the address binding on top.
Changed this so socket setup failures log at warn, while connection failures and timeouts log at debug.
Moved the details to docs/configuration.md and left a short link in the README, is it ok like this?
Merged, thanks.
fujita
nuclearcat
The transport local-address setting was accepted but ignored, so the kernel chose the source for outgoing connections and incoming sessions could target any local address. Peers requiring a particular source could therefore fail to establish despite a valid configuration.
Bind outgoing sockets to the configured address and check incoming connection destinations, retaining GoBGP's wildcard and bind-interface exceptions. Carry the setting through configuration, peer groups and the gRPC API, report it before connection, and restart sessions when it changes. Keep retrying bind failures without falling back to another source.
Add inline configuration, API and TCP regressions covering IPv4, IPv6, scoped addresses, inheritance, dynamic peers, bind failures and updates. Compare behavior with GoBGP v4.6.0 source; live GoBGP interoperability has not been tested for this change.
Did you use an AI tool?
Assisted-by: OpenAI Codex