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

Replace old waitForTunnelUp function #7155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Rawa
Copy link
Contributor

@Rawa Rawa commented Nov 11, 2024


This change is Reviewable

@Rawa Rawa added the Android Issues related to Android label Nov 11, 2024
@Rawa Rawa self-assigned this Nov 11, 2024
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Rawa)


android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt line 141 at r1 (raw file):

        val tunFd = vpnInterfaceFd.detachFd()

        waitForTunnelUp(tunFd, config.routes.any { route -> route.isIpv6 })

Were we able to find any historical reasons for adding this wait by looking in the git history? Would also be good to clarify in the git commit why we remove it as a future reference in case it causes any issues.

Code quote:

waitForTunnelUp

Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @albin-mullvad)


android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt line 141 at r1 (raw file):

Previously, albin-mullvad wrote…

Were we able to find any historical reasons for adding this wait by looking in the git history? Would also be good to clarify in the git commit why we remove it as a future reference in case it causes any issues.

💯% agree that we should try to document why this was removed. Doing so in the commit message ought to be enough

@Rawa Rawa changed the title Remove old waitForTunnelUp function Replace old waitForTunnelUp function Nov 12, 2024
After invoking VpnService.establish() we will get a tunnel file
descriptor that corresponds to the interface that was created. However,
this has no guarantee of the routing table beeing up to date, and we
might thus send traffic outside the tunnel. Previously this was done
through looking at the tunFd to see that traffic is sent to verify that
the routing table has changed. If no traffic is seen some traffic is
induced to a random IP address to ensure traffic can be seen. This new
implementation is slower but won't risk sending UDP traffic to a random
public address at the internet.
Copy link
Contributor Author

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 6 files reviewed, 1 unresolved discussion (waiting on @albin-mullvad and @pinkisemils)


android/lib/talpid/src/main/kotlin/net/mullvad/talpid/TalpidVpnService.kt line 141 at r1 (raw file):

Previously, MarkusPettersson98 (Markus Pettersson) wrote…

💯% agree that we should try to document why this was removed. Doing so in the commit message ought to be enough

I've added some documentation, but I'll be putting this on hold for a bit since we want to consider doing this in the daemon instead. I talked with @pinkisemils whom proposed that we can setup a socket with NETLINK_ROUTE and then get events for when the routing tables changes. This would possible be faster than this implementation that uses connectivityManager.registerDefaultNetworkCallback(), which seem to take at least 50ms on a debug build.

@Rawa Rawa added the On hold Means the PR is paused for some reason. No need to review it for now label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android On hold Means the PR is paused for some reason. No need to review it for now
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants