Skip to content

Commit

Permalink
fix(bgp_peers): do peer only if IP protos match
Browse files Browse the repository at this point in the history
For configured BGP peers only attempt peering if IP protos match,
otherwise skip and log warning
  • Loading branch information
aauren committed Oct 7, 2023
1 parent 0023ded commit c491bcb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/controllers/routing/bgp_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,18 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
neighborIPStr)
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
primaryIsIPv4 := nrc.primaryIP.To4() != nil
if neighborIsIPv4 != primaryIsIPv4 {
peeringAddressIsIPv4 := peeringAddressForNeighbor.To4() != nil
if neighborIsIPv4 != peeringAddressIsIPv4 {
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
}

Expand Down

0 comments on commit c491bcb

Please sign in to comment.