Skip to content

Commit

Permalink
networks: sep check of masklen only for start,end type creation
Browse files Browse the repository at this point in the history
  • Loading branch information
yousong committed Jun 9, 2020
1 parent 232077b commit f27e177
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/compute/models/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,9 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred
// 根据掩码得到合法的GuestIpPrefix
input.GuestIpPrefix = prefix.String()
} else {
if !isValidMaskLen(input.GuestIpMask) {
return input, httperrors.NewInputParameterError("Invalid masklen %d", input.GuestIpMask)
}
ipStart, err := netutils.NewIPV4Addr(input.GuestIpStart)
if err != nil {
return input, httperrors.NewInputParameterError("Invalid start ip: %s %s", input.GuestIpStart, err)
Expand All @@ -1311,10 +1314,6 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred
ipRange = netutils.NewIPV4AddrRange(ipStart, ipEnd)
}

if !isValidMaskLen(input.GuestIpMask) {
return input, httperrors.NewInputParameterError("Invalid masklen %d", input.GuestIpMask)
}

if len(input.GuestDns) == 0 {
input.GuestDns = options.Options.DNSServer
}
Expand Down

0 comments on commit f27e177

Please sign in to comment.