diff --git a/pkg/daemon/gateway.go b/pkg/daemon/gateway.go index f8a1c3fedd8..a3c874575d8 100644 --- a/pkg/daemon/gateway.go +++ b/pkg/daemon/gateway.go @@ -97,6 +97,7 @@ func (c *Controller) getSubnetsNeedNAT(protocol string) ([]string, error) { subnet.Spec.NatOutgoing && (subnet.Spec.Vlan == "" || subnet.Spec.LogicalGateway) && subnet.Spec.Vpc == util.DefaultVpc && + subnet.Spec.CIDRBlock != "" && (subnet.Spec.Protocol == kubeovnv1.ProtocolDual || subnet.Spec.Protocol == protocol) { cidrBlock := getCidrByProtocol(subnet.Spec.CIDRBlock, protocol) subnetsNeedNat = append(subnetsNeedNat, cidrBlock) @@ -117,6 +118,7 @@ func (c *Controller) getSubnetsDistributedGateway(protocol string) ([]string, er if subnet.DeletionTimestamp == nil && subnet.Spec.Vlan == "" && subnet.Spec.Vpc == util.DefaultVpc && + subnet.Spec.CIDRBlock != "" && subnet.Spec.GatewayType == kubeovnv1.GWDistributedType && (subnet.Spec.Protocol == kubeovnv1.ProtocolDual || subnet.Spec.Protocol == protocol) { cidrBlock := getCidrByProtocol(subnet.Spec.CIDRBlock, protocol) @@ -148,7 +150,7 @@ func (c *Controller) getDefaultVpcSubnetsCIDR(protocol string) ([]string, error) ret = append(ret, c.config.NodeLocalDnsIP) } for _, subnet := range subnets { - if subnet.Spec.Vpc == util.DefaultVpc && (subnet.Spec.Vlan == "" || subnet.Spec.LogicalGateway) { + if subnet.Spec.Vpc == util.DefaultVpc && (subnet.Spec.Vlan == "" || subnet.Spec.LogicalGateway) && subnet.Spec.CIDRBlock != "" { cidrBlock := getCidrByProtocol(subnet.Spec.CIDRBlock, protocol) ret = append(ret, cidrBlock) }