diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 88c77fa0b31..96de2e5fce2 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -432,7 +432,7 @@ func checkAndUpdateGateway(subnet *kubeovnv1.Subnet) (bool, error) { switch { case subnet.Spec.Gateway == "": gw, err = util.GetGwByCidr(subnet.Spec.CIDRBlock) - case util.CheckProtocol(subnet.Spec.Gateway) != util.CheckProtocol(subnet.Spec.CIDRBlock): + case subnet.Spec.Protocol == kubeovnv1.ProtocolDual && util.CheckProtocol(subnet.Spec.Gateway) != util.CheckProtocol(subnet.Spec.CIDRBlock): gw, err = util.AppendGwByCidr(subnet.Spec.Gateway, subnet.Spec.CIDRBlock) default: gw = subnet.Spec.Gateway