From 5856fca2e0bc697d5ff5e15aca4c8b17a224e74b Mon Sep 17 00:00:00 2001 From: bobz965 Date: Wed, 11 Sep 2024 16:30:51 +0800 Subject: [PATCH] fix: err log (#4507) Signed-off-by: bobz965 --- pkg/util/net.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/util/net.go b/pkg/util/net.go index bf59009a5be..4c8565aec69 100644 --- a/pkg/util/net.go +++ b/pkg/util/net.go @@ -417,11 +417,15 @@ func ExpandExcludeIPs(excludeIPs []string, cidr string) []string { } } else { for _, cidrBlock := range strings.Split(cidr, ",") { - if CIDRContainIP(cidrBlock, excludeIP) && excludeIP != SubnetNumber(cidrBlock) && excludeIP != SubnetBroadcast(cidrBlock) { - rv = append(rv, excludeIP) - break + // exclude ip should be the same protocol with cidr + if CheckProtocol(cidrBlock) == CheckProtocol(excludeIP) { + // exclude ip should be in the range of cidr and not cidr addr and broadcast addr + if CIDRContainIP(cidrBlock, excludeIP) && excludeIP != SubnetNumber(cidrBlock) && excludeIP != SubnetBroadcast(cidrBlock) { + rv = append(rv, excludeIP) + break + } + klog.Errorf("CIDR %s not contains the exclude ip %s", cidrBlock, excludeIP) } - klog.Errorf("CIDR %s not contains the exclude ip %s", cidrBlock, excludeIP) } } }