From 7bf874da0b5618637ba10bf8396be4285219537f Mon Sep 17 00:00:00 2001 From: Sridhar Gaddam Date: Thu, 1 Sep 2022 14:19:37 +0530 Subject: [PATCH] OVN Globalnet: Fix missing default route in table 150 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. Fixes: https://github.com/submariner-io/submariner/issues/1982 Signed-off-by: Sridhar Gaddam --- pkg/routeagent_driver/handlers/ovn/host_networking.go | 8 ++++++-- pkg/routeagent_driver/handlers/ovn/south_rules.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/routeagent_driver/handlers/ovn/host_networking.go b/pkg/routeagent_driver/handlers/ovn/host_networking.go index 838e71c10..720ce770f 100644 --- a/pkg/routeagent_driver/handlers/ovn/host_networking.go +++ b/pkg/routeagent_driver/handlers/ovn/host_networking.go @@ -134,12 +134,16 @@ func (ovn *Handler) getNextHopOnK8sMgmtIntf() (*net.IP, error) { continue } - for _, subnet := range ovn.localEndpoint.Spec.Subnets { + // 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 ovn.config.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", ovn.localEndpoint.Spec.Subnets, OVNK8sMgmntIntfName) + return nil, fmt.Errorf("could not find the route to %v via %q", ovn.config.ClusterCidr, OVNK8sMgmntIntfName) } diff --git a/pkg/routeagent_driver/handlers/ovn/south_rules.go b/pkg/routeagent_driver/handlers/ovn/south_rules.go index 1b05c06f5..749147155 100644 --- a/pkg/routeagent_driver/handlers/ovn/south_rules.go +++ b/pkg/routeagent_driver/handlers/ovn/south_rules.go @@ -29,10 +29,10 @@ import ( // handleSubnets builds ip rules, and passes them to the specified netlink function // for provided subnet list -func (ovn *Handler) handleSubnets(subnets []string, ruleFunc func(rule *netlink.Rule) error, +func (ovn *Handler) handleSubnets(remoteSubnets []string, ruleFunc func(rule *netlink.Rule) error, ignoredErrorFunc func(error) bool, ) error { - for _, subnetToHandle := range subnets { + for _, subnetToHandle := range remoteSubnets { for _, localSubnet := range ovn.localEndpoint.Spec.Subnets { rule, err := ovn.getRuleSpec(localSubnet, subnetToHandle, constants.RouteAgentInterClusterNetworkTableID) if err != nil {