Skip to content

Commit

Permalink
fix(bgp_peers): adv. AfiSafi based on capabability
Browse files Browse the repository at this point in the history
Advertise IPv4 / IPv6 AfiSafi capability based upon node's capabilities
rather than limiting to the node's configured protocol.
  • Loading branch information
aauren committed Oct 7, 2023
1 parent c491bcb commit 67abc4b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pkg/controllers/routing/bgp_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
LocalRestarting: true,
}

if neighborIsIPv4 {
if nrc.isIPv4Capable {
n.AfiSafis = []*gobgpapi.AfiSafi{
{
Config: &gobgpapi.AfiSafiConfig{
Expand All @@ -253,20 +253,20 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
},
},
}
} else {
n.AfiSafis = []*gobgpapi.AfiSafi{
{
Config: &gobgpapi.AfiSafiConfig{
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP6, Safi: gobgpapi.Family_SAFI_UNICAST},
}
if nrc.isIPv6Capable {
afiSafi := gobgpapi.AfiSafi{
Config: &gobgpapi.AfiSafiConfig{
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP6, Safi: gobgpapi.Family_SAFI_UNICAST},
Enabled: true,
},
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
Config: &gobgpapi.MpGracefulRestartConfig{
Enabled: true,
},
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
Config: &gobgpapi.MpGracefulRestartConfig{
Enabled: true,
},
},
},
}
n.AfiSafis = append(n.AfiSafis, &afiSafi)
}
}
if peerMultihopTTL > 1 {
Expand Down Expand Up @@ -335,6 +335,8 @@ func newGlobalPeers(ips []net.IP, ports []uint32, asns []uint32, passwords []str
},
Timers: &gobgpapi.Timers{Config: &gobgpapi.TimersConfig{HoldTime: uint64(holdtime)}},
Transport: &gobgpapi.Transport{
// localAddress defaults to the node's primary IP, but can be overridden below on a peer-by-peer basis
// below via the kube-router.io/peer.localips annotation
LocalAddress: localAddress,
RemotePort: options.DefaultBgpPort,
},
Expand Down

0 comments on commit 67abc4b

Please sign in to comment.