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

VPN-6523: Fix Android LAN exclusions #9757

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

oskirby
Copy link
Collaborator

@oskirby oskirby commented Jul 31, 2024

Description

In PR #9674 we tried to improve the LAN exclusion implementation for Windows and Linux. However, this introduced a bug in Android where the LAN exclusion calculation would cause routes to the internal Mulvad network to get lost. This causes the VPN's connectivity checks to fail, and results in the client entering the No Signal state shortly after connecting.

The cause of the bug is that IPAddress::excludeAddresses() doesn't handle routes nested inside an excluded route. For example, excludeAddresses({"0.0.0.0/0", "10.64.0.1/32"},{"10.0.0.0/8"}) will ignore the route to 10.64.0.1 because it is excluded by 10.0.0.0/8 despite having a longer prefix length.

Reference

JIRA issue: VPN-6523
Previous PR: #9674

Checklist

  • My code follows the style guidelines for this project
  • I have not added any packages that contain high risk or unknown licenses (GPL, LGPL, MPL, etc. consult with DevOps if in question)
  • I have performed a self review of my own code
  • I have commented my code PARTICULARLY in hard to understand areas
  • I have added thorough tests where needed

@oskirby oskirby marked this pull request as ready for review July 31, 2024 23:36
@oskirby oskirby force-pushed the vpn-6523-fix-android-lan-exclusions branch from 7913e85 to b6c3b51 Compare July 31, 2024 23:40
const auto localRoutes = Controller::getExcludedIPAddressRanges().flatten();
const auto fullAllowedIPs =
IPAddress::excludeAddresses(config.m_allowedIPAddressRanges, localRoutes);
// This could be done better with VpnService.Builder.excludeRoute()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually went down the rabbit hole of implementing this with VpnService.Builder.excludeRoute() and it worked great, and only afterwards did I realize that it requires a higher API level than we ship with. So this implementation here is just crudely working around the issue, but in a way that doesn't require a change to our minimum Android version.

Copy link
Collaborator

@mcleinman mcleinman left a comment

Choose a reason for hiding this comment

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

Questions answered via real time convo. Thanks!

@oskirby oskirby enabled auto-merge (squash) August 1, 2024 19:10
@github-actions github-actions bot added the 🛬 Landing This PR is marked as "auto-merge" label Aug 1, 2024
@oskirby oskirby merged commit f459608 into main Aug 1, 2024
112 of 117 checks passed
@oskirby oskirby deleted the vpn-6523-fix-android-lan-exclusions branch August 1, 2024 19:31
oskirby added a commit that referenced this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛬 Landing This PR is marked as "auto-merge"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants