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