lwIP - A Lightweight TCP/IP stack - Patches: patch #6865, SO_REUSEADDR for TCP
You are not allowed to post comments on this tracker with your current authentication level.
patch #6865: SO_REUSEADDR for TCP
Submitter: | Jeff Barber <jeffbabar> | ||
Submitted: | Tue 14 Jul 2009 03:22:04 PM UTC | ||
Category: | None | Priority: | 5 - Normal |
Status: | Done | Privacy: | Public |
Assigned to: | goldsimon | Open/Closed: | Closed |
Planned Release: | 1.4.0 |
Jump to the original submission
Wed 12 May 2010 10:33:26 PM UTC, comment #18: |
Simon Goldschmidt <goldsimon> |
Tue 16 Feb 2010 12:22:13 PM UTC, comment #17: Sorry, when syn packet is not sent, local ip address is not defined,
|
Oleg Tyshev <olegreen> |
Tue 16 Feb 2010 12:15:45 PM UTC, comment #16: If we miss out that check, let's replace it with an assertion that the local port is not ANY.
|
Kieran Mansley <kieranm> |
Tue 16 Feb 2010 12:09:37 PM UTC, comment #15: I see tcp_bind() and it always used
|
Oleg Tyshev <olegreen> |
Sat 13 Feb 2010 11:07:57 PM UTC, comment #14:
|
Simon Goldschmidt <goldsimon> |
Sat 13 Feb 2010 10:10:49 PM UTC, comment #13: I agree about SO_REUSEPORT. It seems pretty much the same thing with differences too tiny to bother with.
|
Jeff Barber <jeffbabar> |
Sat 13 Feb 2010 11:25:57 AM UTC, comment #12: Agree about TIME_WAIT, especially as it doesn't hurt: when allocating a new pcb and running out of resources, TIME_WAIT pcbs are killed anyway.
|
Simon Goldschmidt <goldsimon> |
Fri 12 Feb 2010 07:52:49 PM UTC, comment #11: On linux, the rule is that the same port can be re-used if the endpoints are on different interfaces (different IP addresses) OR if all existing endpoints are not in LISTEN state and all have the REUSEADDR flag set (and the to-be-created endpoint has to match the same criteria).
|
Jeff Barber <jeffbabar> |
Fri 12 Feb 2010 04:37:09 PM UTC, comment #10: I slightly change the patch to use pcb.so_options and SOF_REUSEADDR instead of pcb.flags and TF_REUSEADDR (which I removed). This way it will be easier to integrate with socket options in the future.
|
Simon Goldschmidt <goldsimon> |
Fri 12 Feb 2010 03:35:08 PM UTC, comment #9: Checked in.
|
Simon Goldschmidt <goldsimon> |
Wed 21 Oct 2009 03:06:17 PM UTC, comment #8: That's of course OK for me. |
Simon Goldschmidt <goldsimon> |
Wed 21 Oct 2009 11:42:41 AM UTC, comment #7: Unless there's a strong case for this I'd rather leave it for 1.4.0 - it's a feature rather than a bug fix. |
Kieran Mansley <kieranm> |
Fri 16 Oct 2009 09:17:05 PM UTC, comment #6: Anything against this going in to 1.3.2? It's still not a full support for SO_REUSEADDR (on the socket level), but nevertheless seems like a good start for it... |
Simon Goldschmidt <goldsimon> |
Thu 27 Aug 2009 02:22:47 AM UTC, comment #5: The only way I think that could happen (concurrent transfers with different endpoints bound to the same local port) is when a listening endpoint accepts two different connection requests. In that case, both derive from the same listening endpoint but the two are distinguishable because the remote address/port is unique in each.
|
Jeff Barber <jeffbabar> |
Wed 26 Aug 2009 09:27:15 PM UTC, comment #4: What about 2 concurrent transfers where the first hasn't reached TIME_WAIT yet? Does that work already or do we need to change something for that, too? |
Simon Goldschmidt <goldsimon> |
Tue 14 Jul 2009 03:55:44 PM UTC, comment #3: This happens in tcp_bind prior to the tcp_listen or tcp_connect so there isn't yet a remote address or port to check.
|
Jeff Barber <jeffbabar> |
Tue 14 Jul 2009 03:38:14 PM UTC, comment #2: Rather than just bypassing the checking of the PCBs in TIME_WAIT, shouldn't we test that if we're going to try and re-use one from the TIME_WAIT state that the remote address/port/protocol differs from the earlier value? |
Kieran Mansley <kieranm> |
Tue 14 Jul 2009 03:37:44 PM UTC, comment #1: I should have mentioned that I also included a fairly trivial bug fix in the patch: I duplicated the traversal code used in checking the other PCB lists for the time-wait list. The previous code checking the time-wait list did not explicitly check for ipaddr_is_any() which originally caused my code to crash because I was using a NULL pointer rather than &ip_addr_any.
|
Jeff Barber <jeffbabar> |
Tue 14 Jul 2009 03:22:04 PM UTC, original submission:
In developing an FTP server (for example) it is necessary to bind each outgoing PORT connection to the well-known FTP-data port (20). Back-to-back transfers usually mean that the second and subsequent connections need to be bound to port 20 while the previous PCB is still in TIME_WAIT. Hence, the equivalent of SO_REUSEADDR required in order to implement the server.
|
Jeff Barber <jeffbabar> |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follow 7 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2010-05-12 | goldsimon | Status | Need Info | Done | |
Open/Closed | Open | Closed | |||
2010-02-12 | goldsimon | Status | Done | Need Info | |
2010-02-12 | goldsimon | Status | None | Done | |
Assigned to | None | goldsimon | |||
2009-08-20 | kieranm | Planned Release | None | 1.4.0 | |
2009-07-14 | jeffbabar | Attached File | - | Added tcp_reuseaddr.patch, #18422 |
Powered by Savane 3.13-f8d8.
Corresponding source code
Done. tcp_bind() now virtually allows any combination of double-used ports/addresses since there is no way to check it at that point (since the remote IP/port is unknown at that point).
Instead, tcp_connect() checks for a unique 5-tuple for active connections, passive connections rely on the remote IP/port being unique.
I did it this way after checking what linux allows and what it doesn't, so it's a bit different to other OSes (especially windows, I guess), but since the (opengroup-)spec doesn't say much about the details, that's OK with me.
Please reopen if there are still problems with SO_REUSEADDR.