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 split tunnel on ipv4 only networks #9982

Merged
merged 2 commits into from
Oct 29, 2024
Merged

Conversation

strseb
Copy link
Collaborator

@strseb strseb commented Oct 24, 2024

Description

Valentina notes on some "hotspot" networks split tunnel breaks.
From valentinas logs:

[23.10.2024 17:53:21.923] (WindowsSplitTunnel) Debug: Getting adapter info for: MozillaVPN
[23.10.2024 17:53:21.930] (WindowsSplitTunnel) Debug: Getting adapter info for: Wi-Fi
[23.10.2024 17:53:21.930] (WindowsSplitTunnel) Debug: Ipv6 Conversation error 0
[23.10.2024 17:53:21.930] (WindowsSplitTunnel) Error: Failed to set Network Config
[23.10.2024 17:53:21.930] (WindowsSplitTunnel) Debug: Pushing new Ruleset for Split-Tunnel  3
[23.10.2024 17:53:21.930] (WindowsSplitTunnel) Debug: \Device\HarddiskVolume4\Program Files\Mozilla Firefox\firefox.exe
[23.10.2024 17:53:21.934] (WindowsSplitTunnel) Debug: New Configuration applied:  STATE_RUNNING

Currently we assume the local network adapter contains an ipv6. If not we bubble the error up the stack:
-> if not InetPtonW(AF_INET6,..) will return false
-> WindowsSplitTunnel::getAddress will return false
-> WindowsSplitTunnel::generateIPConfiguration will return {} so 0 bytes
-> this will cause the driver call DeviceIoControl(m_driver, IOCTL_REGISTER_IP_ADDRESSES,..) to error as we don't send a valid blob
-> this will cause this error message logger.error() << "Failed to set Network Config";

So let's bail the ipv6 conversation if there is none and send the info we have to the driver.

@strseb strseb marked this pull request as ready for review October 24, 2024 08:30
@@ -484,6 +484,9 @@ bool WindowsSplitTunnel::getAddress(int adapterIndex, IN_ADDR* out_ipv4,
logger.debug() << "Ipv4 Conversation error" << WSAGetLastError();
return false;
}
if (ipv6.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I can tell, there is nothing that explicitly initializes the contents of out_ipv6 when we follow this code path. It probably works in a debug build because it defaults to all zeros, but that may not be true when compiled for release. I would recommend setting some kind of value here to ensure we are not passing uninitialized data to the caller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Did that.

@strseb strseb requested a review from oskirby October 28, 2024 11:42
@strseb strseb merged commit 86c5853 into main Oct 29, 2024
117 checks passed
@strseb strseb deleted the basti/maybe_fix_split_tunnel branch October 29, 2024 09:03
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.

2 participants