mirror of
https://github.com/cloudnativelabs/kube-router.git
synced 2025-11-19 12:01:17 +01:00
start peering connection to neighbors from node's advertise-ip
This commit is contained in:
parent
61ed1849a0
commit
184976a536
@ -91,13 +91,18 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
|
||||
|
||||
currentNodes = append(currentNodes, nodeIP.String())
|
||||
nrc.activeNodes[nodeIP.String()] = true
|
||||
// explicitly set neighbors.transport.config.local-address with nodeIP which is configured
|
||||
// as their neighbor address at the remote peers.
|
||||
// this prevents the controller from initiating connection to its peers with a different IP address
|
||||
// when multiple L3 interfaces are active.
|
||||
n := &gobgpapi.Peer{
|
||||
Conf: &gobgpapi.PeerConf{
|
||||
NeighborAddress: nodeIP.String(),
|
||||
PeerAs: nrc.nodeAsnNumber,
|
||||
},
|
||||
Transport: &gobgpapi.Transport{
|
||||
RemotePort: nrc.bgpPort,
|
||||
LocalAddress: nrc.nodeIP.String(),
|
||||
RemotePort: nrc.bgpPort,
|
||||
},
|
||||
}
|
||||
|
||||
@ -238,8 +243,8 @@ func connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*gobgpap
|
||||
}
|
||||
|
||||
// Does validation and returns neighbor configs
|
||||
func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []string, holdtime float64) (
|
||||
[]*gobgpapi.Peer, error) {
|
||||
func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []string, holdtime float64,
|
||||
localAddress string) ([]*gobgpapi.Peer, error) {
|
||||
peers := make([]*gobgpapi.Peer, 0)
|
||||
|
||||
// Validations
|
||||
@ -269,6 +274,10 @@ func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []str
|
||||
asns[i])
|
||||
}
|
||||
|
||||
// explicitly set neighbors.transport.config.local-address with nodeIP which is configured
|
||||
// as their neighbor address at the remote peers.
|
||||
// this prevents the controller from initiating connection to its peers with a different IP address
|
||||
// when multiple L3 interfaces are active.
|
||||
peer := &gobgpapi.Peer{
|
||||
Conf: &gobgpapi.PeerConf{
|
||||
NeighborAddress: ips[i].String(),
|
||||
@ -276,7 +285,8 @@ func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []str
|
||||
},
|
||||
Timers: &gobgpapi.Timers{Config: &gobgpapi.TimersConfig{HoldTime: uint64(holdtime)}},
|
||||
Transport: &gobgpapi.Transport{
|
||||
RemotePort: options.DefaultBgpPort,
|
||||
LocalAddress: localAddress,
|
||||
RemotePort: options.DefaultBgpPort,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -1088,7 +1088,8 @@ func (nrc *NetworkRoutingController) startBgpServer(grpcServer bool) error {
|
||||
}
|
||||
|
||||
// Create and set Global Peer Router complete configs
|
||||
nrc.globalPeerRouters, err = newGlobalPeers(peerIPs, peerPorts, peerASNs, peerPasswords, nrc.bgpHoldtime)
|
||||
nrc.globalPeerRouters, err = newGlobalPeers(peerIPs, peerPorts, peerASNs, peerPasswords, nrc.bgpHoldtime,
|
||||
nrc.nodeIP.String())
|
||||
if err != nil {
|
||||
err2 := nrc.bgpServer.StopBgp(context.Background(), &gobgpapi.StopBgpRequest{})
|
||||
if err2 != nil {
|
||||
@ -1281,8 +1282,8 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
|
||||
}
|
||||
}
|
||||
|
||||
nrc.globalPeerRouters, err = newGlobalPeers(kubeRouterConfig.PeerRouters, peerPorts, peerASNs,
|
||||
peerPasswords, nrc.bgpHoldtime)
|
||||
nrc.globalPeerRouters, err = newGlobalPeers(kubeRouterConfig.PeerRouters, peerPorts,
|
||||
peerASNs, peerPasswords, nrc.bgpHoldtime, nrc.nodeIP.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error processing Global Peer Router configs: %s", err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user