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
Work around linux DGRAM reconnect misbehaviour #5120
Work around linux DGRAM reconnect misbehaviour #5120
Conversation
05d8d89
to
40d5209
Compare
I wrote a test case. It turns out Linux does more fishy stuff... If I bind to the wildcard address with port 0 (requesting an ephemeral port), check which port I got, then connect to 127.0.0.0:53 using a clear with AF_UNSPEC length 0 first, the source port can actually be changed by the Linux network stack. But if I bind to the wildcard address with an explicit port number, the source port does not change during clearing destination reconnect... |
40d5209
to
ef4271f
Compare
I don't think this a bug, the behavior is documented in
There is also a old bug report about this in the kernels bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=6646
|
@RoadRunnr: Bummer! I just spent a few hours on registering myself at the appropriate Linux mailing list, and writing a pretty enough C program that demonstrates the bug. On my Ubuntu 18 the phrasing is:
So, nothing in that about "thereafter, the socket can be connected to another address". It seems they have chosen to classify their queer behaviour as a documentation bug. |
ef4271f
to
d8d70be
Compare
b259495
to
b11c2de
Compare
Check that all fields in the sockaddr() value are part of the address for the address family. I have myself once too many used #{family =>inet, address => loopback} and then gotten #{family => inet, addr => any} since the address field is named 'addr' so 'address' is ignored and the default for 'addr' is 'any' ({0,0,0,0}).
b11c2de
to
aebf963
Compare
Also, adjust some inconsistent error returns / exceptions.
aebf963
to
b8f6206
Compare
In
inet_drv.c
I have added a simple connect call with AF_UNSPEC to clear the socket address before connecting.For
socket.erl
I have added the possibility to use "native" addresses, so the same can be done from the compatibility modulegen_udp_socket.erl
.To be committed...