From 029a16a1ebd85efc8c66abe431b657e6cad06540 Mon Sep 17 00:00:00 2001 From: m1093782566 Date: Mon, 14 May 2018 16:07:13 +0800 Subject: [PATCH] fix review comments --- pkg/proxy/iptables/proxier.go | 18 +++++++----------- pkg/proxy/ipvs/proxier.go | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/pkg/proxy/iptables/proxier.go b/pkg/proxy/iptables/proxier.go index 73b7b27d9de..a4338f62d35 100644 --- a/pkg/proxy/iptables/proxier.go +++ b/pkg/proxy/iptables/proxier.go @@ -968,23 +968,19 @@ func (proxier *Proxier) syncProxyRules() { lps := make([]utilproxy.LocalPort, 0) for address := range addresses { - if utilproxy.IsZeroCIDR(address) { - lp := utilproxy.LocalPort{ - Description: "nodePort for " + svcNameString, - IP: "", - Port: svcInfo.NodePort, - Protocol: protocol, - } - lps = append(lps, lp) - // If we encounter a zero CIDR, then there is no point in processing the rest of the addresses. - break - } lp := utilproxy.LocalPort{ Description: "nodePort for " + svcNameString, IP: address, Port: svcInfo.NodePort, Protocol: protocol, } + if utilproxy.IsZeroCIDR(address) { + // Empty IP address means all + lp.IP = "" + lps = append(lps, lp) + // If we encounter a zero CIDR, then there is no point in processing the rest of the addresses. + break + } lps = append(lps, lp) } diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index 1c067a24d4f..8bcd30103be 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -993,23 +993,19 @@ func (proxier *Proxier) syncProxyRules() { lps := make([]utilproxy.LocalPort, 0) for address := range addresses { - if utilproxy.IsZeroCIDR(address) { - lp := utilproxy.LocalPort{ - Description: "nodePort for " + svcNameString, - IP: "", - Port: svcInfo.NodePort, - Protocol: protocol, - } - lps = append(lps, lp) - // If we encounter a zero CIDR, then there is no point in processing the rest of the addresses. - break - } lp := utilproxy.LocalPort{ Description: "nodePort for " + svcNameString, IP: address, Port: svcInfo.NodePort, Protocol: protocol, } + if utilproxy.IsZeroCIDR(address) { + // Empty IP address means all + lp.IP = "" + lps = append(lps, lp) + // If we encounter a zero CIDR, then there is no point in processing the rest of the addresses. + break + } lps = append(lps, lp) }