Skip to content

Commit

Permalink
add check for subnet cidr (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Dec 12, 2022
1 parent c627468 commit 755a46a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/daemon/gateway.go
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 755a46a

Please sign in to comment.