Skip to content

Commit 767e102

Browse files
authored
fix underlay access to node through ovn0 (#2846)
1 parent ae226e3 commit 767e102

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/controller/subnet.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err
21462146
prio 31000 match: "ip4.dst == underlay subnet cidr && ip4.dst != node ips" action: allow
21472147
21482148
policy2:
2149-
prio 31000 match: "ip4.dst == node ips && ip4.src == underlay subnet cidr" action: allow
2149+
prio 31000 match: "ip4.dst == node ips && ip4.src == underlay subnet cidr" action: reoute physical gw
21502150
21512151
policy3:
21522152
prio 29000 match: "ip4.src == underlay subnet cidr" action: reroute physical gw
@@ -2161,8 +2161,8 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err
21612161
return err
21622162
}
21632163

2164-
klog.Infof("add u2o interconnection policy for router: %s, match %s, action %s", subnet.Spec.Vpc, match2, "allow")
2165-
if err := c.ovnLegacyClient.AddPolicyRoute(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match2, "allow", "", externalIDs); err != nil {
2164+
klog.Infof("add u2o interconnection policy for router: %s, match %s, action %s, nexthop %s", subnet.Spec.Vpc, match2, "reroute", nextHop)
2165+
if err := c.ovnLegacyClient.AddPolicyRoute(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match2, "reroute", nextHop, externalIDs); err != nil {
21662166
klog.Errorf("failed to add u2o interconnection policy2 for subnet %s %v", subnet.Name, err)
21672167
return err
21682168
}

test/e2e/kube-ovn/underlay/underlay.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,13 @@ func checkU2OItems(isEnableU2O bool, subnet *apiv1.Subnet, underlayPod, overlayP
608608
}
609609
agName := strings.Replace(fmt.Sprintf("%s.u2o_exclude_ip.%s", subnet.Name, protocolStr), "-", ".", -1)
610610
ginkgo.By(fmt.Sprintf("checking underlay subnet's policy1 route %s", protocolStr))
611-
hitPolicyStr := fmt.Sprintf("%d %s.dst == $%s && %s.src == %s allow", util.SubnetRouterPolicyPriority, protocolStr, agName, protocolStr, cidr)
611+
612+
hitPolicyStr := fmt.Sprintf("%d %s.dst == %s && %s.dst != $%s allow", util.SubnetRouterPolicyPriority, protocolStr, cidr, protocolStr, agName)
612613
checkPolicy(hitPolicyStr, isEnableU2O)
613614

614615
ginkgo.By(fmt.Sprintf("checking underlay subnet's policy2 route %s", protocolStr))
615-
hitPolicyStr = fmt.Sprintf("%d %s.dst == %s && %s.dst != $%s allow", util.SubnetRouterPolicyPriority, protocolStr, cidr, protocolStr, agName)
616+
hitPolicyStr = fmt.Sprintf("%d %s.dst == $%s && %s.src == %s reroute %s", util.SubnetRouterPolicyPriority, protocolStr, agName, protocolStr, cidr, gw)
617+
616618
checkPolicy(hitPolicyStr, isEnableU2O)
617619

618620
ginkgo.By(fmt.Sprintf("checking underlay subnet's policy3 route %s", protocolStr))

0 commit comments

Comments
 (0)