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

Fix prefix length comparison bug in AutoApprovers route evaluation #862

Merged
merged 3 commits into from
Nov 1, 2022

Conversation

tsujamin
Copy link
Contributor

@tsujamin tsujamin commented Oct 15, 2022

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

Fixes a bug raised by @samcday in #763 where a subprefix (10.0.1.0/24) of an autoApproved route (10.0.0.0/8) wasn't being approved due to an incorrect comparison of their prefix lengths. The corresponding unit test has been modified to capture this regression.

@tsujamin tsujamin force-pushed the autoapprovers-prefix-approval-bug branch from 6e2b6f8 to ef5fe7f Compare October 15, 2022 11:31
@tsujamin tsujamin mentioned this pull request Oct 15, 2022
6 tasks
@@ -125,7 +125,7 @@ func (autoApprovers *AutoApprovers) GetRouteApprovers(
return nil, err
}

if autoApprovedPrefix.Bits() >= prefix.Bits() &&
if prefix.Bits() >= autoApprovedPrefix.Bits() &&
Copy link

Choose a reason for hiding this comment

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

Is this check even necessary, given the Contains check below?

Copy link

Choose a reason for hiding this comment

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

Never mind I see, Contains operates on a single IP, hence the need for this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah that makes sense, I'd forgotten entirely and it's pretty late here 😅

samcday
samcday previously approved these changes Oct 15, 2022
@tsujamin
Copy link
Contributor Author

tsujamin commented Nov 1, 2022

@juanfont @kradalby any chance this can make it into the next 0.17 beta? :)

@samcday
Copy link

samcday commented Nov 1, 2022

+1, I've been soaking this change in my personal tailnet for a week now, LGTM 👍

kradalby
kradalby previously approved these changes Nov 1, 2022
@kradalby kradalby dismissed stale reviews from samcday and themself via 348ffdf November 1, 2022 10:00
@kradalby kradalby merged commit 8a07381 into juanfont:main Nov 1, 2022
@tsujamin
Copy link
Contributor Author

tsujamin commented Nov 1, 2022

ty! my mistakes are undone 😂

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.

3 participants