From 796593098c81a0672208e6fe66b38735082d3843 Mon Sep 17 00:00:00 2001 From: Tomas Hruby <49207409+tomastigera@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:08:58 -0800 Subject: [PATCH] regexp.QuoteMate special devices and simplify the final regexp Co-authored-by: Shaun Crampton --- felix/dataplane/linux/bpf_ep_mgr.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/felix/dataplane/linux/bpf_ep_mgr.go b/felix/dataplane/linux/bpf_ep_mgr.go index 1b7a3de4669..15cdb03b55d 100644 --- a/felix/dataplane/linux/bpf_ep_mgr.go +++ b/felix/dataplane/linux/bpf_ep_mgr.go @@ -550,12 +550,11 @@ func newBPFEndpointManager( specialInterfaces = append(specialInterfaces, config.RulesConfig.WireguardInterfaceNameV6) } - exp := "(" + config.BPFDataIfacePattern.String() + ")|(" - for _, d := range specialInterfaces { - exp += "^" + d + "$|" + for i, d := range specialInterfaces { + specialInterfaces[i] = "^" + regexp.QuoteMeta(d) + "$" } + exp := "(" + config.BPFDataIfacePattern.String() + "|" + strings.Join(specialInterfaces, "|") + ")" - exp = exp[:len(exp)-1] + ")" log.WithField("dataIfaceRegex", exp).Debug("final dataIfaceRegex") m.dataIfaceRegex = regexp.MustCompile(exp)