Skip to content

Commit 6e9370e

Browse files
committed
start peering connection to neighbors from node's advertise-ip
1 parent 803bd90 commit 6e9370e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pkg/controllers/routing/bgp_peers.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,19 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
8989

9090
currentNodes = append(currentNodes, nodeIP.String())
9191
nrc.activeNodes[nodeIP.String()] = true
92+
// explicitly set neighbors.transport.config.local-address with nodeIP which is configured
93+
// as their neighbor address at the remote peers.
94+
// this prevents the controller from initiating connection to its peers with a different IP address
95+
// when multiple L3 interfaces are active.
9296
n := &config.Neighbor{
9397
Config: config.NeighborConfig{
9498
NeighborAddress: nodeIP.String(),
9599
PeerAs: nrc.nodeAsnNumber,
96100
},
97101
Transport: config.Transport{
98102
Config: config.TransportConfig{
99-
RemotePort: nrc.bgpPort,
103+
LocalAddress: nrc.nodeIP.String(),
104+
RemotePort: nrc.bgpPort,
100105
},
101106
},
102107
}
@@ -259,7 +264,7 @@ func connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*config.
259264
}
260265

261266
// Does validation and returns neighbor configs
262-
func newGlobalPeers(ips []net.IP, ports []uint16, asns []uint32, passwords []string) (
267+
func newGlobalPeers(ips []net.IP, ports []uint16, asns []uint32, passwords []string, localAddress string) (
263268
[]*config.Neighbor, error) {
264269
peers := make([]*config.Neighbor, 0)
265270

@@ -294,14 +299,19 @@ func newGlobalPeers(ips []net.IP, ports []uint16, asns []uint32, passwords []str
294299
asns[i])
295300
}
296301

302+
// explicitly set neighbors.transport.config.local-address with nodeIP which is configured
303+
// as their neighbor address at the remote peers.
304+
// this prevents the controller from initiating connection to its peers with a different IP address
305+
// when multiple L3 interfaces are active.
297306
peer := &config.Neighbor{
298307
Config: config.NeighborConfig{
299308
NeighborAddress: ips[i].String(),
300309
PeerAs: asns[i],
301310
},
302311
Transport: config.Transport{
303312
Config: config.TransportConfig{
304-
RemotePort: options.DEFAULT_BGP_PORT,
313+
LocalAddress: localAddress,
314+
RemotePort: options.DEFAULT_BGP_PORT,
305315
},
306316
},
307317
}

pkg/controllers/routing/network_routes_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ func (nrc *NetworkRoutingController) startBgpServer() error {
812812
}
813813

814814
// Create and set Global Peer Router complete configs
815-
nrc.globalPeerRouters, err = newGlobalPeers(peerIPs, peerPorts, peerASNs, peerPasswords)
815+
nrc.globalPeerRouters, err = newGlobalPeers(peerIPs, peerPorts, peerASNs, peerPasswords, nrc.nodeIP.String())
816816
if err != nil {
817817
nrc.bgpServer.Stop()
818818
return fmt.Errorf("Failed to process Global Peer Router configs: %s", err)
@@ -969,7 +969,7 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
969969
}
970970

971971
nrc.globalPeerRouters, err = newGlobalPeers(kubeRouterConfig.PeerRouters, peerPorts,
972-
peerASNs, peerPasswords)
972+
peerASNs, peerPasswords, nrc.nodeIP.String())
973973
if err != nil {
974974
return nil, fmt.Errorf("Error processing Global Peer Router configs: %s", err)
975975
}

0 commit comments

Comments
 (0)