@@ -89,14 +89,19 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
89
89
90
90
currentNodes = append (currentNodes , nodeIP .String ())
91
91
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.
92
96
n := & config.Neighbor {
93
97
Config : config.NeighborConfig {
94
98
NeighborAddress : nodeIP .String (),
95
99
PeerAs : nrc .nodeAsnNumber ,
96
100
},
97
101
Transport : config.Transport {
98
102
Config : config.TransportConfig {
99
- RemotePort : nrc .bgpPort ,
103
+ LocalAddress : nrc .nodeIP .String (),
104
+ RemotePort : nrc .bgpPort ,
100
105
},
101
106
},
102
107
}
@@ -259,7 +264,7 @@ func connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*config.
259
264
}
260
265
261
266
// 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 ) (
263
268
[]* config.Neighbor , error ) {
264
269
peers := make ([]* config.Neighbor , 0 )
265
270
@@ -294,14 +299,19 @@ func newGlobalPeers(ips []net.IP, ports []uint16, asns []uint32, passwords []str
294
299
asns [i ])
295
300
}
296
301
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.
297
306
peer := & config.Neighbor {
298
307
Config : config.NeighborConfig {
299
308
NeighborAddress : ips [i ].String (),
300
309
PeerAs : asns [i ],
301
310
},
302
311
Transport : config.Transport {
303
312
Config : config.TransportConfig {
304
- RemotePort : options .DEFAULT_BGP_PORT ,
313
+ LocalAddress : localAddress ,
314
+ RemotePort : options .DEFAULT_BGP_PORT ,
305
315
},
306
316
},
307
317
}
0 commit comments