-
-
Notifications
You must be signed in to change notification settings - Fork 869
[client] Use native windows sock opts to avoid routing loops #4314
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors networking code by moving core networking utilities from util/net
to client/net
and implements Windows-specific socket options to prevent routing loops. The refactor consolidates networking functionality within the client package structure while adding native Windows support for advanced routing.
- Moves networking utilities from
util/net
toclient/net
for better organization - Implements Windows-specific socket options using IP_UNICAST_IF and IPV6_UNICAST_IF
- Extracts hook functionality into a separate
hooks
package for better modularity
Reviewed Changes
Copilot reviewed 55 out of 70 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
client/net/net_windows.go | Implements Windows-specific socket options and interface selection logic |
client/net/env_windows.go | Adds Windows environment configuration and VPN interface management |
client/net/hooks/hooks.go | Extracts hook functionality into dedicated package |
util/net/*.go | Removes old networking utility files |
Multiple files | Updates import paths from util/net to client/net |
Comments suppressed due to low confidence (1)
|
// 1. Longest prefix match (most specific route) | ||
// 2. Lowest route metric | ||
// 3. Lowest interface metric | ||
func GetBestInterface(dest netip.Addr, vpnIntf string) (*net.Interface, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we call this on every network change (e.g Wifi-> Ethernet) ? If we don't refresh the best iface we might keep pinning to a non-best interface as i understand.
return &interfaceSelection{iface4: iface}, nil | ||
} | ||
|
||
func setIPv4UnicastIF(fd uintptr, iface *net.Interface) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to fallback NB_USE_LEGACY_ROUTING
if sth goes wrong here?
Describe your changes
util/grpc
andutil/net
toclient
sointernal
packages can be accessedIP_UNICAST_IF
sock opt to force the outgoing interface for the NetBirdnet.Dialer
andnet.ListenerConfig
to avoid routing loops. The interface is picked by the new route lookup method.NB_USE_LEGACY_ROUTING=true
env varIssue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Interal routing change, no user facing code change
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__