[bug #57525] [TCP][RST] request to call tcp send callback if pcb->acked >= 0 when tcp client received last tcp rst segment

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #57525] [TCP][RST] request to call tcp send callback if pcb->acked >= 0 when tcp client received last tcp rst segment

Simon Goldschmidt
URL:
  <https://savannah.nongnu.org/bugs/?57525>

                 Summary: [TCP][RST] request to call tcp send callback if
pcb->acked >= 0 when tcp client received last tcp rst segment
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: chenwu
            Submitted on: Fri 03 Jan 2020 08:10:50 AM UTC
                Category: TCP
                Severity: 3 - Normal
              Item Group: Feature Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 1.4.1

    _______________________________________________________

Details:

Dear lwip maintainers:
  Please consider a situation like the following:

lwip version: all v1.4.1+
the tcp packets in the attachment.

1. WiFi device runs lwip as the tcp client, and connected to remote tcp
server.
2. tcp client send n-bytes data to tcp server, server echos the same n-bytes
data to tcp client.
3. data transmit OK for several times
4. tcp client send n-bytes data to tcp server, server reply a TCP RST segment,
in RST segment, including n-bytes data and valid sequence and ack.
5. We expect tcp client will call tcp send callback, and then, abort the
connection and goes to the CLOSED state.
// actually in lwip, tcp client does not call tcp send callback,
// it leads to tcp client mis-understand that last n-bytes does not send OK.


A workaround in our side, with lwip v1.4.1:
http://git.savannah.nongnu.org/cgit/lwip.git/tree/src/core/tcp_in.c?h=DEVEL-1_4_1,
Line 308- LIne 316


      if (recv_flags & TF_RESET) {
        TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);
        tcp_pcb_remove(&tcp_active_pcbs, pcb);
        memp_free(MEMP_TCP_PCB, pcb);
      }

Could we modify it to the following:

      if (recv_flags & TF_RESET) {
        if (pcb->acked > 0) {
          TCP_EVENT_SENT(pcb, pcb->acked, err);
          if (err == ERR_ABRT) {
            goto aborted;
          }
        }
        TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);
        tcp_pcb_remove(&tcp_active_pcbs, pcb);
        memp_free(MEMP_TCP_PCB, pcb);
      }


I am not sure the modification whether it will affect other lwip functions,
but at least, it looks like solve the tcp send callback problem.


Look forward to your reply.

Thanks.
Best regards,
Chen Wu 陈武 | [hidden email]
Software Engineer| Espressif Systems

www.espressif.com
Floor 4, Block 6, 899 Zhenze Road,
Tech Park, Wuxi, China



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 03 Jan 2020 08:10:50 AM UTC  Name: tcp-rst.pkt  Size: 70KiB   By:
chenwu

<http://savannah.nongnu.org/bugs/download.php?file_id=48160>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57525>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #57525] [TCP][RST] request to call tcp send callback if pcb->acked >= 0 when tcp client received last tcp rst segment

Simon Goldschmidt
Follow-up Comment #1, bug #57525 (project lwip):

In RFC 793, Part 3.4 tail, here is a Reset Processing description.
Please take a look if there is a function conflict.
Thanks.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57525>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #57525] [TCP][RST] request to call tcp send callback if pcb->acked >= 0 when tcp client received last tcp rst segment

Simon Goldschmidt
Update of bug #57525 (project lwip):

                  Status:                    None => Invalid                
             Assigned to:                    None => goldsimon              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #2:

A RST segment never ACKs new data, nor does it contain data (as you suggested
in 4).

The recv_acked variable (I assume you mean this one, since pcb->acked does not
exist) is not even updated for a RST.

Closing as invalid.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57525>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #57525] [TCP][RST] request to call tcp send callback if pcb->acked >= 0 when tcp client received last tcp rst segment

Simon Goldschmidt
Follow-up Comment #3, bug #57525 (project lwip):


[comment #2 comment #2:]
> A RST segment never ACKs new data, nor does it contain data (as you
suggested in 4).
>
> The recv_acked variable (I assume you mean this one, since pcb->acked does
not exist) is not even updated for a RST.
>
> Closing as invalid.

thanks for your information.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57525>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel