Skip to content

Commit

Permalink
handle the case of error node cidr (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyd1988 committed May 10, 2022
1 parent 1285b03 commit 5158dd9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1287,8 +1287,11 @@ func (c Client) SetPrivateLogicalSwitch(ls, cidr string, allow []string) error {
protocol := util.CheckProtocol(cidrBlock)
if protocol == kubeovnv1.ProtocolIPv4 {
allowArgs = append(allowArgs, "--", MayExist, "acl-add", ls, "to-lport", util.SubnetAllowPriority, fmt.Sprintf(`ip4.src==%s && ip4.dst==%s`, cidrBlock, cidrBlock), "allow-related")
} else {
} else if protocol == kubeovnv1.ProtocolIPv6 {
allowArgs = append(allowArgs, "--", MayExist, "acl-add", ls, "to-lport", util.SubnetAllowPriority, fmt.Sprintf(`ip6.src==%s && ip6.dst==%s`, cidrBlock, cidrBlock), "allow-related")
} else {
klog.Errorf("the cidrBlock: %s format is error in subnet: %s", cidrBlock, ls)
continue
}

for _, nodeCidrBlock := range strings.Split(c.NodeSwitchCIDR, ",") {
Expand All @@ -1298,7 +1301,7 @@ func (c Client) SetPrivateLogicalSwitch(ls, cidr string, allow []string) error {

if protocol == kubeovnv1.ProtocolIPv4 {
allowArgs = append(allowArgs, "--", MayExist, "acl-add", ls, "to-lport", util.NodeAllowPriority, fmt.Sprintf("ip4.src==%s", nodeCidrBlock), "allow-related")
} else {
} else if protocol == kubeovnv1.ProtocolIPv6 {
allowArgs = append(allowArgs, "--", MayExist, "acl-add", ls, "to-lport", util.NodeAllowPriority, fmt.Sprintf("ip6.src==%s", nodeCidrBlock), "allow-related")
}
}
Expand Down

0 comments on commit 5158dd9

Please sign in to comment.