Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgengine/filter/filtertype: make Match.IPProto a view #12526

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

bradfitz
Copy link
Member

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)

@bradfitz bradfitz requested a review from maisem June 18, 2024 19:25
} else {
m.IPProto = make([]ipproto.Proto, 0, len(r.IPProto))
filtered := make([]ipproto.Proto, 0, len(r.IPProto))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess we don't have a views.Filter or equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and we have slicex.Partition but it allocates a lot and doesn't support append. I'd like an AppendFilterFunc or something.

@@ -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}),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd love a variant which could take variadic elements return a slice. like views.SliceFrom(ipproto.TCP, ipproto.UDP, ipproto.ICMPv4) (with a better name)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. I can't think of a good name. And renaming SliceOf to SliceFrom would be too invasive, especially to third party code that might be using it.

Copy link
Collaborator

@maisem maisem Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like SliceOf for handing it an already existing slice. For variadic, SliceFrom kinda fits

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>
@bradfitz bradfitz merged commit bd93c30 into main Jun 18, 2024
48 checks passed
@bradfitz bradfitz deleted the bradfitz/ipproto_view branch June 18, 2024 20:30
bradfitz added a commit that referenced this pull request Jun 19, 2024
Fix regression from bd93c30 where I didn't notice the
32-bit test failure was real and not its usual slowness-related
regression. Yay failure blindness.

Updates #12526

Change-Id: I00e33bba697e2cdb61a0d76a71b62406f6c2eeb9
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz added a commit that referenced this pull request Jun 19, 2024
Fix regression from bd93c30 where I didn't notice the
32-bit test failure was real and not its usual slowness-related
regression. Yay failure blindness.

Updates #12526

Change-Id: I00e33bba697e2cdb61a0d76a71b62406f6c2eeb9
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants