-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aswin Suryanarayanan <[email protected]>
- Loading branch information
1 parent
9bdc5ca
commit 984fe4a
Showing
4 changed files
with
91 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ovn | ||
|
||
import ( | ||
"fmt" | ||
"github.com/pkg/errors" | ||
"github.com/submariner-io/admiral/pkg/log" | ||
"github.com/vishvananda/netlink" | ||
"net" | ||
"syscall" | ||
) | ||
|
||
func getNextHopOnK8sMgmtIntf(clusterCidr []string) (*net.IP, error) { | ||
|
||
link, err := netlink.LinkByName(OVNK8sMgmntIntfName) | ||
|
||
if err != nil && !errors.Is(err, netlink.LinkNotFoundError{}) { | ||
return nil, errors.Wrapf(err, "error retrieving link by name %q", OVNK8sMgmntIntfName) | ||
} | ||
|
||
currentRouteList, err := netlink.RouteList(link, syscall.AF_INET) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "error retrieving routes on the link %s", OVNK8sMgmntIntfName) | ||
} | ||
|
||
for i := range currentRouteList { | ||
logger.V(log.DEBUG).Infof("Processing route %v", currentRouteList[i]) | ||
|
||
if currentRouteList[i].Dst == nil || currentRouteList[i].Gw == nil { | ||
continue | ||
} | ||
|
||
// To support hostNetworking use-case the route-agent handler programs default route in table 150 | ||
// with nexthop matching the nexthop on the ovn-k8s-mp0 interface. Basically, we want the Submariner | ||
// managed traffic to be forwarded to the ovn_cluster_router and pass through the CNI network so that | ||
// it reaches the active gateway node in the cluster via the submariner pipeline. | ||
for _, subnet := range clusterCidr { | ||
if currentRouteList[i].Dst.String() == subnet { | ||
return ¤tRouteList[i].Gw, nil | ||
} | ||
} | ||
} | ||
|
||
return nil, fmt.Errorf("could not find the route to %v via %q", clusterCidr, OVNK8sMgmntIntfName) | ||
} |