Skip to content

Commit

Permalink
fix failed
Browse files Browse the repository at this point in the history
  • Loading branch information
changluyi committed Jun 21, 2023
1 parent e8c1b6c commit addb3b0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/controller/ovn-ic.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,14 @@ func stripPrefix(policyMatch string) (string, error) {
matches := strings.Split(policyMatch, "==")
if strings.Trim(matches[0], " ") == util.MatchV4Dst {
return strings.Trim(matches[1], " "), nil
} else if strings.Trim(matches[0], " ") == util.MatchV6Dst {
return strings.Trim(matches[1], " "), nil
} else {
return "", fmt.Errorf("policy %s is mismatched", policyMatch)
}
}

func (c *Controller) syncOneRouteToPolicy(key, value string) {
cidr, err := c.ovnLegacyClient.GetTsSubnet(util.InterconnectionSwitch)
if err != nil {
klog.Errorf("failed to get ts subnet: %v", err)
return
}

lr, err := c.ovnClient.GetLogicalRouter(c.config.ClusterRouter, false)
if err != nil {
klog.Errorf("logical router does not exist %v at %v", err, time.Now())
Expand Down Expand Up @@ -481,14 +477,14 @@ func (c *Controller) syncOneRouteToPolicy(key, value string) {
delete(policyMap, lrRoute.IPPrefix)
} else {
var matchFiled string
if util.CheckProtocol(cidr) == kubeovnv1.ProtocolIPv4 || util.CheckProtocol(cidr) == kubeovnv1.ProtocolDual {
if util.CheckProtocol(lrRoute.IPPrefix) == kubeovnv1.ProtocolIPv4 {
matchFiled = util.MatchV4Dst + " == " + lrRoute.IPPrefix
if err := c.ovnClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil {
klog.Errorf("adding router policy failed %v", err)
}
}

if util.CheckProtocol(cidr) == kubeovnv1.ProtocolIPv6 || util.CheckProtocol(cidr) == kubeovnv1.ProtocolDual {
if util.CheckProtocol(lrRoute.IPPrefix) == kubeovnv1.ProtocolIPv6 {
matchFiled = util.MatchV6Dst + " == " + lrRoute.IPPrefix
if err := c.ovnClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil {
klog.Errorf("adding router policy failed %v", err)
Expand Down

0 comments on commit addb3b0

Please sign in to comment.