Skip to content

Commit

Permalink
Fix check eip in dual stack
Browse files Browse the repository at this point in the history
  • Loading branch information
lou-lan committed Dec 6, 2023
1 parent 467deb2 commit 7833c50
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/controller/webhook/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func checkEGWIppools(client client.Client, cfg *config.Config, ctx context.Conte
return nil
}

func checkEIP(client client.Client, ctx context.Context, ipv4, ipv6, egwName string) (bool, error) {
func checkEIP(client client.Client, ctx context.Context, ipv4, ipv6, egwName string, cfg *config.Config) (bool, error) {

eipIPV4 := ipv4
eipIPV6 := ipv6
Expand All @@ -276,9 +276,11 @@ func checkEIP(client client.Client, ctx context.Context, ipv4, ipv6, egwName str
return false, err
}

if eipIPV4 == egw.Spec.Ippools.Ipv4DefaultEIP || eipIPV6 == egw.Spec.Ippools.Ipv6DefaultEIP {
if eipIPV4 != egw.Spec.Ippools.Ipv4DefaultEIP || eipIPV6 != egw.Spec.Ippools.Ipv6DefaultEIP {
return false, fmt.Errorf("%v egw Ipv4DefaultEIP=%v Ipv6DefaultEIP=%v, they can only be used together", egwName, egw.Spec.Ippools.Ipv4DefaultEIP, egw.Spec.Ippools.Ipv6DefaultEIP)
if cfg.FileConfig.EnableIPv4 && cfg.FileConfig.EnableIPv6 {
if eipIPV4 == egw.Spec.Ippools.Ipv4DefaultEIP || eipIPV6 == egw.Spec.Ippools.Ipv6DefaultEIP {
if eipIPV4 != egw.Spec.Ippools.Ipv4DefaultEIP || eipIPV6 != egw.Spec.Ippools.Ipv6DefaultEIP {
return false, fmt.Errorf("%v egw Ipv4DefaultEIP=%v Ipv6DefaultEIP=%v, they can only be used together", egwName, egw.Spec.Ippools.Ipv4DefaultEIP, egw.Spec.Ippools.Ipv6DefaultEIP)
}
}
}

Expand Down

0 comments on commit 7833c50

Please sign in to comment.