Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pkg/controllers/routing/bgp_peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
},
},
},
{
Config: config.AfiSafiConfig{
AfiSafiName: config.AFI_SAFI_TYPE_IPV6_UNICAST,
Enabled: true,
},
MpGracefulRestart: config.MpGracefulRestart{
Config: config.MpGracefulRestartConfig{
Enabled: true,
},
},
},
}
}

Expand Down Expand Up @@ -204,6 +215,17 @@ func connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*config.
},
},
},
{
Config: config.AfiSafiConfig{
AfiSafiName: config.AFI_SAFI_TYPE_IPV6_UNICAST,
Enabled: true,
},
MpGracefulRestart: config.MpGracefulRestart{
Config: config.MpGracefulRestartConfig{
Enabled: true,
},
},
},
}
}
if peerMultihopTtl > 1 {
Expand Down
43 changes: 34 additions & 9 deletions pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,43 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
cidrStr := strings.Split(cidr, "/")
subnet := cidrStr[0]
cidrLen, _ := strconv.Atoi(cidrStr[1])
attrs := []bgp.PathAttributeInterface{
bgp.NewPathAttributeOrigin(0),
bgp.NewPathAttributeNextHop(nrc.nodeIP.String()),
}
if nrc.isIpv6 {
prefixes := []bgp.AddrPrefixInterface{bgp.NewIPv6AddrPrefix(uint8(cidrLen), subnet)}
attrs := []bgp.PathAttributeInterface{
bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_IGP),
// This requires some research.
// For ipv6 what should be next-hop value? According to this https://www.noction.com/blog/bgp-next-hop
// using the link-local address may be more appropriate.
bgp.NewPathAttributeMpReachNLRI(nrc.nodeIP.String(), prefixes),
&bgp.PathAttributeNextHop{
PathAttribute: bgp.PathAttribute{
Flags: bgp.PathAttrFlags[bgp.BGP_ATTR_TYPE_NEXT_HOP],
Type: bgp.BGP_ATTR_TYPE_NEXT_HOP,
Length: 16,
},
Value: nrc.nodeIP,
},
}

glog.V(2).Infof("Advertising route: '%s/%s via %s' to peers using attribute: %+q", subnet, strconv.Itoa(cidrLen), nrc.nodeIP.String(), attrs)

if _, err := nrc.bgpServer.AddPath("", []*table.Path{table.NewPath(nil, bgp.NewIPv6AddrPrefix(uint8(cidrLen),
subnet), false, attrs, time.Now(), false)}); err != nil {
return fmt.Errorf(err.Error())
}
} else {
attrs := []bgp.PathAttributeInterface{
bgp.NewPathAttributeOrigin(0),
bgp.NewPathAttributeNextHop(nrc.nodeIP.String()),
}

glog.V(2).Infof("Advertising route: '%s/%s via %s' to peers", subnet, strconv.Itoa(cidrLen), nrc.nodeIP.String())
glog.V(2).Infof("Advertising route: '%s/%s via %s' to peers", subnet, strconv.Itoa(cidrLen), nrc.nodeIP.String())

if _, err := nrc.bgpServer.AddPath("", []*table.Path{table.NewPath(nil, bgp.NewIPAddrPrefix(uint8(cidrLen),
subnet), false, attrs, time.Now(), false)}); err != nil {
return fmt.Errorf(err.Error())
if _, err := nrc.bgpServer.AddPath("", []*table.Path{table.NewPath(nil, bgp.NewIPAddrPrefix(uint8(cidrLen),
subnet), false, attrs, time.Now(), false)}); err != nil {
return fmt.Errorf(err.Error())
}
}

return nil
}

Expand Down