@@ -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
@@ -182,7 +187,7 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
182
187
}
183
188
}
184
189
185
- // connectToExternalBGPPeers adds all the configured eBGP peers (global or node specific) as neighbours// connectToExternalBGPPeers adds all the configured eBGP peers (global or node specific) as neighbours
190
+ // connectToExternalBGPPeers adds all the configured eBGP peers (global or node specific) as neighbours
186
191
func connectToExternalBGPPeers (server * gobgp.BgpServer , peerNeighbors []* gobgpapi.Peer , bgpGracefulRestart bool , bgpGracefulRestartDeferralTime time.Duration ,
187
192
bgpGracefulRestartTime time.Duration , peerMultihopTTL uint8 ) error {
188
193
for _ , n := range peerNeighbors {
@@ -238,7 +243,7 @@ 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 ) (
246
+ func newGlobalPeers (ips []net.IP , ports []uint32 , asns []uint32 , passwords []string , holdtime float64 , localAddress string ) (
242
247
[]* gobgpapi.Peer , error ) {
243
248
peers := make ([]* gobgpapi.Peer , 0 )
244
249
@@ -272,14 +277,19 @@ func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []str
272
277
asns [i ])
273
278
}
274
279
280
+ // explicitly set neighbors.transport.config.local-address with nodeIP which is configured
281
+ // as their neighbor address at the remote peers.
282
+ // this prevents the controller from initiating connection to its peers with a different IP address
283
+ // when multiple L3 interfaces are active.
275
284
peer := & gobgpapi.Peer {
276
285
Conf : & gobgpapi.PeerConf {
277
286
NeighborAddress : ips [i ].String (),
278
287
PeerAs : asns [i ],
279
288
},
280
289
Timers : & gobgpapi.Timers {Config : & gobgpapi.TimersConfig {HoldTime : uint64 (holdtime )}},
281
290
Transport : & gobgpapi.Transport {
282
- RemotePort : options .DefaultBgpPort ,
291
+ LocalAddress : localAddress ,
292
+ RemotePort : options .DefaultBgpPort ,
283
293
},
284
294
}
285
295
0 commit comments