From 03260d5b6703dca3d5fb01e040641d26bda9c7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 30 Jul 2026 03:38:04 +0200 Subject: [PATCH] plugin/kubernetes: short-circuit matchPortAndProtocol and fast-path string match (#8344) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel RĂ¼ger --- plugin/kubernetes/kubernetes.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go index 72d43a272..9d9c4ae02 100644 --- a/plugin/kubernetes/kubernetes.go +++ b/plugin/kubernetes/kubernetes.go @@ -683,12 +683,15 @@ func (k *Kubernetes) isMultiClusterZone(zone string) bool { // match checks if a and b are equal. func match(a, b string) bool { + if a == b { + return true + } return strings.EqualFold(a, b) } // matchPortAndProtocol matches port and protocol, permitting the 'a' inputs to be wild func matchPortAndProtocol(aPort, bPort, aProtocol, bProtocol string) bool { - return (match(aPort, bPort) || aPort == "") && (match(aProtocol, bProtocol) || aProtocol == "") + return (aPort == "" || match(aPort, bPort)) && (aProtocol == "" || match(aProtocol, bProtocol)) } const coredns = "c" // used as a fake key prefix in msg.Service