<div dir="ltr">Andrey & Pavel -- Thanks for the clarification. I'll update the patch and send out for review once it's ready.<div><br></div><div>Thanks,</div><div>Amey</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 9, 2015 at 1:15 AM, Pavel Emelyanov <span dir="ltr"><<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/06/2015 10:10 PM, Amey Deshpande wrote:<br>
> For an established TCP connection, the send queue is restored in two<br>
> steps: in step (1), we retransmit the data that was sent before but not<br>
> yet acknowledged, and in step (2), we transmit the data that was never<br>
> sent outside before. The TCP_REPAIR option is disabled before step (2)<br>
> and re-enabled after step (2) (without this patch).<br>
<br>
</span>Yes, as Andrey pointed out this was done deliberately. Otherwise we introduce<br>
delays in send queue processing.<br>
<span class=""><br>
> If the amount of data to be sent in step (2) is large, the TCP_REPAIR<br>
> flag on the socket can remain off for some time (O(milliseconds)). If a<br>
> listen() is called on another socket bound to the same port during this<br>
> time window, it fails. This is because -- turning TCP_REPAIR off clears<br>
> the SO_REUSEADDR flag on the socket.<br>
><br>
> There are several possible ways to prevent this problem from happening:<br>
> - The simplest option is to *not* toggle TCP_REPAIR option while<br>
> restoring the TCP queues.<br>
> - Another way would be to explicitly enable SO_REUSEADDR on the<br>
> socket after turning TCP_REPAIR off. This still leaves a small time<br>
> window, and such race could still occur.<br>
> - A more involved solution would use a mutex per port number, so<br>
> that a listen() on a port number does not happen while SO_REUSEADDR for<br>
> another socket on the same port is off.<br>
<br>
</span>I vote for this way. We already have the per-socket inet_port object that<br>
is shared between processes and new lock can be safely put there.<br>
<span class=""><br>
> This patch removes the toggling of TCP_REPAIR option during restoring<br>
> TCP send queues.<br>
><br>
> Signed-off-by: Amey Deshpande <<a href="mailto:ameyd@google.com">ameyd@google.com</a>><br>
<br>
</span>Thanks,<br>
Pavel<br>
<br>
<br>
</blockquote></div><br></div>