-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
SCTP connect could return error even if the connect is ongoing #1592
SCTP connect could return error even if the connect is ongoing #1592
Conversation
Can you describe the error case a bit more, from an API point of view? Are you calling The code has gotten its shape from the TCP connect code, and when you say it, suppose you have an association and then connect to (associate with) another endpoint, then while that association is in progress (you need to use If state INET_STATE_CONNECTED should be sensible for 1 -> N sockets then it should go INET_STATE_CONNECTING -> INET_STATE_CONNECTED for the first association, and then stay there until the last association goes down. Or the socket should be in INET_STATE_OPEN or INET_STATE_LISTENING after birth and stay there. Maybe not INET_STATE_LISTENING... If your change is correct, then |
I was hit by the issue when adding code to diameter_sctp for sharing port between connects.
And the code later on treats any
But the connet_init may return I was trying this by adding a transport where the remote endpoint have two addreses. I have done some testing. It solves the problem I encountered, Small example below.
I agree that fix is incomplete, |
Do you have an idea of how a late failure would look with your change? You would return I am thinking about how the new working semantics should be. |
I will throw it into our daily tests let's see what happens... |
Just to be clear. Below example is how it behaves without the fix.
With the fix, it would return |
And with the fix, I don't think diameter_sctp needs to be changed. |
Well, man It might be so that Linux return double error codes by both returning I have seen a wide spread in semantics between SCTP implementations and have found no good resource that clarifies how it should work. Maybe this is just another platform dependent quirk you will have to (the diameter code will have to) be prepared for. We'll see if something breaks in our daily tests... |
I agree that doing And since the socket is ready for writing at any time, geting the Lets see what your daily tests will find. |
@falkevik wrote:
I would really like to get another source for that fact/guess. |
Your PR has been running for a week now in our daily tests, and I see no negative effects. I have read RFC 6458: Sockets API Extencion for SCTP, to try to find anything about non-blocking connect. The closest I can find are sections 3.1.6 and 3.2, but none of them talk about non-blocking connect. However, they talk about creating associations through Those sections also recommend caution when using So it seems you can go ahead and remove the redundant states and callback functions in |
Sorry for my late reply. But that is good news that you have not found any issues so far. As a side note, I have added some experimental support for sctp on MacOS. |
Well, that a socket is ready for write is no surprise. That it is so before connect might be. The interesting question is whether the ready for write status means anything after getting EINPROGRESS after I think my indirect conclusion via non-blocking Regarding experimental support for SCTP on MacOS: sure, we are interested. Make a separate pull request and we can run it in our daily tests where we have a few Macs with different OS versions. |
379340a
to
0bcc564
Compare
gen_sctp:connect_init/4 could return error even though the connect are in progress. I.e. connect on socket returned "in progress". The error can come from packet_inet_output() which is checking the socket for errors. The issue here is that from erlang you don't think the connect is still ongoing. But you will receive a sctp_assoc_change message later on.
0bcc564
to
4eb3df5
Compare
I have removed the unused callback |
I think this will be just fine. An SCTP socket will only use INET_STATE_{CLOSED,OPEN,LISTENING} where LISTENING may be today incorrect and ignored. E.g SCTP_REQ_BINDX i think should |
Again, I see no negative effects in our daily tests. I will write release notes and merge it shortly... |
sounds good, thanks. |
gen_sctp:connect_init/4 could return error even though the OS had
initiated the connection.
I.e. connect returned "in progress".
Then an error could come from packet_inet_output() which is checking the socket
and return error if peer_sock returned any error.
The misleading here is that from erlang you don't think the connect is still ongoing.
And you will receive a sctp_assoc_change message later on.
What problem did the code in packet_inet_output solve? What am I breaking when not calling it?
Remove the code in packet_inet_output?
Does it make sense to have INET_STATE_CONNECTING, INET_STATE_CONNECTED on a 1<->M SCTP socket?