lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] How to send RST ?


From: Jeff Barber
Subject: Re: [lwip-users] How to send RST ?
Date: Fri, 10 Dec 2010 10:48:00 -0500

It looks like you made changes to cause the stack to send RST instead
of FIN when you close the socket (at least in some situations -
there's not enough context to indicate when rstClose would be set).
That might be a reasonable choice in your particular environment but
it's not a very good plan in the general case.  It risks stranding
resources in the peer in the event that the RST packet gets dropped
somewhere in the path between the two hosts.

By default, TCP connections don't time out. So, if your RST packet is
lost, the peer will just never hear from you again but will think that
the connection is still alive.  Even with TCP keepalives enabled (and
they are not enabled by default in most systems), the default
connection idle timeout is usually two hours. This is probably why the
ability to generate RST packets is not typically extended to
applications: it's not meant for ordinary session teardown; it's
intended to notify the peer of an exceptional condition.

Again, this may be fine for your environment, but someone else looking
at your suggestion should be aware of the consequences.

Jeff

On Wed, Dec 8, 2010 at 10:03 PM, yueyue papa <address@hidden> wrote:
> I try this before.  It works.
>
> in tcp.c
>
> err_t
> tcp_close(struct tcp_pcb *pcb)
> {
>  ....
>   case ESTABLISHED:
>     if( rstClose & 0x1) // rstClose is a control flag.
>     {
>         err = tcp_send_ctrl(pcb, TCP_FIN);
>         if (err == ERR_OK) {
>           snmp_inc_tcpestabresets();
>           pcb->state = FIN_WAIT_1;
>         }
>     }
>     else
>     {
>         tcp_abort(pcb);
>         err = ERR_OK;
>         pcb = NULL;
>     }
>     break;
> ...
> }
>
>
> I ask the similar question before.  For the TCP/IP standard, the FIN is a
> good solution.  But the RST is a shotcut solution in certain environment.
>
>
>
>
>
> On Wed, Dec 8, 2010 at 10:53 PM, Jeff Barber <address@hidden> wrote:
>>
>> On Tue, Dec 7, 2010 at 10:23 PM, runjin <address@hidden> wrote:
>> > I found that closesocket sends a FIN packet,
>> > How to send RST ?
>>
>> AFAIK, there is no way to send RST using the socket or netconn APIs.
>> But then this is not something that is normally available to
>> applications in other OSes like Linux or Windows either.  (If you're
>> using the raw API, you can call tcp_abort. However, that's not
>> something you can mix with the other APIs.)
>>
>> What are you trying to accomplish by sending a RST?
>>
>> Jeff
>>
>> _______________________________________________
>> lwip-users mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]