@@ -91,13 +91,18 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
91
91
92
92
currentNodes = append (currentNodes , nodeIP .String ())
93
93
nrc .activeNodes [nodeIP .String ()] = true
94
+ // explicitly set neighbors.transport.config.local-address with nodeIP which is configured
95
+ // as their neighbor address at the remote peers.
96
+ // this prevents the controller from initiating connection to its peers with a different IP address
97
+ // when multiple L3 interfaces are active.
94
98
n := & gobgpapi.Peer {
95
99
Conf : & gobgpapi.PeerConf {
96
100
NeighborAddress : nodeIP .String (),
97
101
PeerAs : nrc .nodeAsnNumber ,
98
102
},
99
103
Transport : & gobgpapi.Transport {
100
- RemotePort : nrc .bgpPort ,
104
+ LocalAddress : nrc .nodeIP .String (),
105
+ RemotePort : nrc .bgpPort ,
101
106
},
102
107
}
103
108
@@ -238,8 +243,8 @@ func connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*gobgpap
238
243
}
239
244
240
245
// Does validation and returns neighbor configs
241
- func newGlobalPeers (ips []net.IP , ports []uint32 , asns []uint32 , passwords []string , holdtime float64 ) (
242
- []* gobgpapi.Peer , error ) {
246
+ func newGlobalPeers (ips []net.IP , ports []uint32 , asns []uint32 , passwords []string , holdtime float64 ,
247
+ localAddress string ) ( []* gobgpapi.Peer , error ) {
243
248
peers := make ([]* gobgpapi.Peer , 0 )
244
249
245
250
// Validations
@@ -269,14 +274,19 @@ func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []str
269
274
asns [i ])
270
275
}
271
276
277
+ // explicitly set neighbors.transport.config.local-address with nodeIP which is configured
278
+ // as their neighbor address at the remote peers.
279
+ // this prevents the controller from initiating connection to its peers with a different IP address
280
+ // when multiple L3 interfaces are active.
272
281
peer := & gobgpapi.Peer {
273
282
Conf : & gobgpapi.PeerConf {
274
283
NeighborAddress : ips [i ].String (),
275
284
PeerAs : asns [i ],
276
285
},
277
286
Timers : & gobgpapi.Timers {Config : & gobgpapi.TimersConfig {HoldTime : uint64 (holdtime )}},
278
287
Transport : & gobgpapi.Transport {
279
- RemotePort : options .DefaultBgpPort ,
288
+ LocalAddress : localAddress ,
289
+ RemotePort : options .DefaultBgpPort ,
280
290
},
281
291
}
282
292
0 commit comments