<div dir="ltr">Hi, <div>yes, tcp is free to discard receive buffer on receiving RST</div><div>however after looking through the source code of linux kernel, it seems that  process just set state of socket, not discard data in receive buffer.<br></div><div>1. tcp_validate_incoming</div><div><br></div><div><div>5184         /* Step 2: check RST bit */</div><div>5185         if (th->rst) {</div><div>5186                 tcp_reset(sk);</div><div>5187                 goto discard;</div><div>5188         }</div></div><div><br></div><div>2. tcp_reset</div><div><br></div><div><div>4055         if (!sock_flag(sk, SOCK_DEAD))</div><div>4056                 sk->sk_error_report(sk);</div><div>4057</div><div>4058         tcp_done(sk);</div></div><div><br></div><div>3. tcp_done</div><div><div>3183 void tcp_done(struct sock *sk)</div><div>3184 {</div><div>3185         if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV)</div><div>3186                 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_ATTEMPTFAILS);</div><div>3187</div><div>3188         tcp_set_state(sk, TCP_CLOSE);</div><div>3189         tcp_clear_xmit_timers(sk);</div><div>3190</div><div>3191         sk->sk_shutdown = SHUTDOWN_MASK;</div><div>3192</div><div>3193         if (!sock_flag(sk, SOCK_DEAD))</div><div>3194                 sk->sk_state_change(sk);</div><div>3195         else</div><div>3196                 inet_csk_destroy_sock(sk);</div><div>3197 }</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 3, 2015 at 7:53 AM, Michael Wojcik <span dir="ltr"><<a href="mailto:Michael.Wojcik@microfocus.com" target="_blank">Michael.Wojcik@microfocus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Just to amplify on Jakob's response: the reason that sometimes you see the reply is that sometimes your application manages to get it from the stack before
 the stack receives and processes the RST from the peer. In the example you provided, there was a 52ms window in which you could have read that response before the RST told the stack to throw it away.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">If the conversation is aborting for cause - for example because the peer process exited without reading some received data - then this is the correct behavior.
 If the peer is causing the RST by mucking around with the SO_LINGER socket option, then the peer application is probably broken. (There are cases where an application might legitimately want to send an RST rather than a FIN, but they're few and far between.)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">In any event, you're at the mercy of TCP's semantics. When the conversation is aborted, rather than terminated normally, unprocessed data goes away. That's
 a Good Thing, because the peer has no way of knowing whether you received it.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">As is usually the case with this sort of issue, the real question is what problem are you actually trying to solve? "How can I make TCP behave differently?"
 is not the right question.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">Michael Wojcik</span><span style="font-size:9.0pt;color:#1f497d">
<br>
</span><span style="font-size:9.0pt;font-family:"Courier New"">Technology Specialist</span><span style="font-size:9.0pt;font-family:"Courier New"">, Micro Focus</span><span style="font-size:9.0pt;color:#1f497d">
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p align="center" style="text-align:center"><span style="border:none windowtext 1.0pt;padding:0in;background:white"><u></u> <u></u></span></p>
</div>
</font></span></div>
</div>

<br>_______________________________________________<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Anty Rao</div>
</div>