wgengine/filter/filtertype: make Match.IPProto a view
I noticed we were allocating these every time when they could just share the same memory. Rather than document ownership, just lock it down with a view. I was considering doing all of the fields but decided to just do this one first as test to see how infectious it became. Conclusion: not very. Updates #cleanup (while working towards tailscale/corp#20514) Change-Id: I8ce08519de0c9a53f20292adfbecd970fe362de0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
bfb775ce62
commit
bd93c3067e
@@ -126,7 +126,7 @@ func NewAllowAllForTest(logf logger.Logf) *Filter {
|
||||
any6 := netip.PrefixFrom(netip.AddrFrom16([16]byte{}), 0)
|
||||
ms := []Match{
|
||||
{
|
||||
IPProto: []ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv4},
|
||||
IPProto: views.SliceOf([]ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv4}),
|
||||
Srcs: []netip.Prefix{any4},
|
||||
Dsts: []NetPortRange{
|
||||
{
|
||||
@@ -139,7 +139,7 @@ func NewAllowAllForTest(logf logger.Logf) *Filter {
|
||||
},
|
||||
},
|
||||
{
|
||||
IPProto: []ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv6},
|
||||
IPProto: views.SliceOf([]ipproto.Proto{ipproto.TCP, ipproto.UDP, ipproto.ICMPv6}),
|
||||
Srcs: []netip.Prefix{any6},
|
||||
Dsts: []NetPortRange{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user