Tunnel inbound: Share the fake UDP reply socket address on OpenBSD - #6624
Open
adsdevdoo wants to merge 1 commit into
Open
Tunnel inbound: Share the fake UDP reply socket address on OpenBSD#6624adsdevdoo wants to merge 1 commit into
adsdevdoo wants to merge 1 commit into
Conversation
Every reply to a client is sent from a socket bound to the original destination with SO_BINDANY, and one such socket is created per session. Two clients talking to the same destination, two phones resolving over the same DNS server for instance, therefore bind the same address and port twice, and the second bind fails with EADDRINUSE, leaving that session without answers. SO_REUSEADDR does not help here: on OpenBSD it is only promoted to allow a duplicate binding for multicast addresses, so a unicast address needs SO_REUSEPORT on both sockets. The Linux implementation of FakeUDP already sets both options.
Member
|
6546晾了三个星期为什么刚好合并两天才发现。。 |
Contributor
Author
|
Fair point. It only shows up when two sessions reach the same destination The fix was already sitting in my IPv6 branch. I split it out into its own |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6546.
On OpenBSD every UDP reply to a client is sent from a socket bound to the
original destination with
SO_BINDANY, andFakeUDPcreates one such socketper session. Two clients talking to the same destination at the same time, two
phones resolving over the same DNS server for instance, therefore bind the same
address and port twice. The second bind fails with
EADDRINUSE, surfacing asfake: bind ...: address already in use, and that session never gets an answer.SO_REUSEADDRalone does not cover this. Inin_pcbaddrisavail_lock()thereuse flag starts as
so->so_options & SO_REUSEPORTand is only widened toaccept
SO_REUSEADDRfor multicast addresses, so a duplicate binding on aunicast address needs
SO_REUSEPORTon both sockets:proxy/dokodemo/fakeudp_linux.goalready sets both options, this brings theOpenBSD implementation in line.
Tested on OpenBSD 7.7/7.8/7.9 amd64 on a live router with several LAN clients.