Skip to content

Commit

Permalink
fix(NRC): error when nec. host IP not found
Browse files Browse the repository at this point in the history
If we can't find an appropriate IP to add for nextHop to injectRoute or
overlay tunnel, raise error rather than trying to continue.
  • Loading branch information
aauren committed Oct 7, 2023
1 parent 4f284be commit 0023ded
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,14 +649,18 @@ func (nrc *NetworkRoutingController) injectRoute(path *gobgpapi.Path) error {

switch {
case link != nil:
// if we setup an overlay tunnel link, then use it for destination routing
// if we set up an overlay tunnel link, then use it for destination routing
var bestIPForFamily net.IP
if dst.IP.To4() != nil {
bestIPForFamily = utils.FindBestIPv4NodeAddress(nrc.primaryIP, nrc.nodeIPv4Addrs)
} else {
// Need to activate the ip command in IPv6 mode
bestIPForFamily = utils.FindBestIPv6NodeAddress(nrc.primaryIP, nrc.nodeIPv6Addrs)
}
if bestIPForFamily == nil {
return fmt.Errorf("not able to find an appropriate configured IP address on node for destination "+
"IP family: %s", dst.String())
}
route = &netlink.Route{
LinkIndex: link.Attrs().Index,
Src: bestIPForFamily,
Expand Down Expand Up @@ -734,6 +738,10 @@ func (nrc *NetworkRoutingController) setupOverlayTunnel(tunnelName string, nextH
bestIPForFamily = utils.FindBestIPv6NodeAddress(nrc.primaryIP, nrc.nodeIPv6Addrs)
ipipMode = "ip6ip6"
}
if nil == bestIPForFamily {
return nil, fmt.Errorf("not able to find an appropriate configured IP address on node for destination "+
"IP family: %s", nextHop.String())
}

// an error here indicates that the tunnel didn't exist, so we need to create it, if it already exists there's
// nothing to do here
Expand Down

0 comments on commit 0023ded

Please sign in to comment.