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

control/controlclient: fix sending peer capmap changes #11457

Merged
merged 1 commit into from Mar 19, 2024

Conversation

clairew
Copy link
Member

@clairew clairew commented Mar 19, 2024

Instead of just checking if a peer capmap is nil, also check if the previous state's capmap was nil.
Updates tailscale/corp#17516

Copy link
Member

@sailorfrag sailorfrag left a comment

Choose a reason for hiding this comment

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

I believe this is safe because it only applies to patchifying PeerChanged and MapCap is unused in peers for all previous versions. It fixes the integration test that was failing. Please wait for @maisem to also review before merge.

@maisem maisem requested a review from bradfitz March 19, 2024 16:30
Comment on lines 667 to 668
if n.CapMap != nil {
pc().CapMap = n.CapMap
Copy link
Member

Choose a reason for hiding this comment

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

But now that I see this code, this is wrong. If these are equal, it shouldn't be a diff.

@bradfitz
Copy link
Member

Let's try to find a better word than "improve" ... all changes are improvements or we wouldn't be making them :)

Maybe "fix CapMap handling in peerChangeDiff"

@clairew clairew force-pushed the clairew/peerchangediff-capmap branch 3 times, most recently from a5d2cdf to 9dfe21b Compare March 19, 2024 19:05
@clairew clairew requested a review from sailorfrag March 19, 2024 19:05
@clairew clairew changed the title control/controlclient: improve sending peer capmap changes control/controlclient: fix sending peer capmap changes Mar 19, 2024
Copy link
Member

@sailorfrag sailorfrag left a comment

Choose a reason for hiding this comment

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

The change is doing more than checking for nil now, let's update the commit message but otherwise I think this should be good

Instead of just checking if a peer capmap is nil, compare the previous
state peer capmap with the new peer capmap.
Updates tailscale/corp#17516
Co-authored-by: Adrian Dewhurst <adrian@tailscale.com>

Signed-off-by: Claire Wang <claire@tailscale.com>
@clairew clairew force-pushed the clairew/peerchangediff-capmap branch from 9dfe21b to 6dbb67b Compare March 19, 2024 20:32
@clairew clairew requested a review from bradfitz March 19, 2024 20:42
if n.CapMap == nil {
pc().CapMap = make(tailcfg.NodeCapMap)
} else {
pc().CapMap = n.CapMap
Copy link
Member

Choose a reason for hiding this comment

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

looks like all the other return paths returning a diff don't alias memory provided by the caller

(line 678 too)

Copy link
Member

Choose a reason for hiding this comment

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

Can I make that a follow on PR to unblock Claire? The existing code was already aliasing memory.

Copy link
Member

Choose a reason for hiding this comment

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

k

Copy link
Member Author

Choose a reason for hiding this comment

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

@sailorfrag pointed out that since the value type for NodeCapMap is of type tailcfg.RawMessage, which is a string thus immutable. So - aliasing memory is ok?

Copy link
Member

Choose a reason for hiding this comment

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

The RawMessage yes, the map itself, no

@clairew clairew merged commit 221de01 into main Mar 19, 2024
46 checks passed
@clairew clairew deleted the clairew/peerchangediff-capmap branch March 19, 2024 22:56
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

3 participants