Skip to content

Commit

Permalink
add err log for gateway check
Browse files Browse the repository at this point in the history
Signed-off-by: zcq98 <[email protected]>
  • Loading branch information
zcq98 committed May 22, 2024
1 parent 3c14f48 commit 8c9c337
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/util/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ import (
)

func ValidateSubnet(subnet kubeovnv1.Subnet) error {
if subnet.Spec.Gateway != "" && (!CIDRContainIP(subnet.Spec.CIDRBlock, subnet.Spec.Gateway) || ValidateNetworkBroadcast(subnet.Spec.CIDRBlock, subnet.Spec.Gateway) != nil) {
if subnet.Spec.Gateway != "" && !CIDRContainIP(subnet.Spec.CIDRBlock, subnet.Spec.Gateway) {
return fmt.Errorf("gateway %s is not in cidr %s", subnet.Spec.Gateway, subnet.Spec.CIDRBlock)
}
if err := ValidateNetworkBroadcast(subnet.Spec.CIDRBlock, subnet.Spec.Gateway); err != nil {
return fmt.Errorf("validate gateway %s for cidr %s failed: %v", subnet.Spec.Gateway, subnet.Spec.CIDRBlock, err)
}
if err := CIDRGlobalUnicast(subnet.Spec.CIDRBlock); err != nil {
return err
}
Expand Down

0 comments on commit 8c9c337

Please sign in to comment.