Skip to content

Commit

Permalink
regexp.QuoteMate special devices and simplify the final regexp
Browse files Browse the repository at this point in the history
Co-authored-by: Shaun Crampton <[email protected]>
  • Loading branch information
tomastigera and fasaxc committed Nov 22, 2024
1 parent e37d9ac commit 096dfcd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions felix/dataplane/linux/bpf_ep_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 096dfcd

Please sign in to comment.