fix(bgp_peers): do peer only if IP protos match

For configured BGP peers only attempt peering if IP protos match,
otherwise skip and log warning
This commit is contained in:
Aaron U'Ren 2023-01-01 16:38:52 -06:00 committed by Aaron U'Ren
parent 0023dedc4d
commit c491bcb48d

View File

@ -216,12 +216,18 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
neighborIPStr) neighborIPStr)
continue continue
} }
peeringAddressForNeighbor := net.ParseIP(n.Transport.LocalAddress)
if peeringAddressForNeighbor == nil {
klog.Errorf("unable to parse our local address for peer (%s), not peering with this peer (%s)",
n.Transport.LocalAddress, neighborIPStr)
}
neighborIsIPv4 := neighborIP.To4() != nil neighborIsIPv4 := neighborIP.To4() != nil
primaryIsIPv4 := nrc.primaryIP.To4() != nil peeringAddressIsIPv4 := peeringAddressForNeighbor.To4() != nil
if neighborIsIPv4 != primaryIsIPv4 { if neighborIsIPv4 != peeringAddressIsIPv4 {
klog.Warningf("Not peering with configured peer as it's primary IP (%s) uses a different "+ klog.Warningf("Not peering with configured peer as it's primary IP (%s) uses a different "+
"protocol than our primary IP (%s)", neighborIP, nrc.primaryIP) "protocol than our configured local-address (%s). Its possible that this can be resolved by setting "+
"the local address appropriately", neighborIP, peeringAddressForNeighbor)
continue continue
} }