lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [task #7675] Enable to refuse data on a TCP_EVENT_RECV call


From: Frédéric Bernon
Subject: [lwip-devel] [task #7675] Enable to refuse data on a TCP_EVENT_RECV call
Date: Sun, 13 Jan 2008 13:24:22 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11

Follow-up Comment #2, task #7675 (project lwip):

>In my opinion, the best solution would be to first call TCP_EVENT_RECV and
only acknowledge the data if it returned ERR_OK. In case of an error, the data
could be deleted and would eventually be retransmitted by the other side. 

This would be the best solution, but it need lot of changes in tcp_in.c.

>While this produces more traffic, I think it would be better than keeping
pbufs allocated in a case where the application doesn't process (and free)
them fast enough: that could easily lead to running out of memory. 

If the lwIP application can't read fast enought the incoming data, it seems
normal we drop next packets, and, of course, tcp source will retransmit them,
producing more traffic. Just, I don't suggest to keep ALL pbufs, but just one
per pcb (struct pbuf *last_recv_data). It will give (most of changes are in
tcp_input):

in tcp_new, add "last_recv_data = NULL;"

t1:
(in tcp_input)
TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err);
if (err!=ERR_OK) {
  pbuf_ref(recv_data);
  pcb->last_recv_data = recv_data;
}

t2:
(in tcp_input, just before "err = tcp_process(pcb);" )
if (pcb->last_recv_data != NULL) {
  TCP_EVENT_RECV(pcb, pcb->last_recv_data, ERR_OK, err);
  if (err == ERR_OK) {
    pbuf_free(pcb->last_recv_data);
    pcb->last_recv_data = NULL;
  } else {
    /* drop incoming packets, pcb is "full" */
    LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: drop incoming packets, pcb is
fulln"));
    TCP_STATS_INC(tcp.drop);
    snmp_inc_tcpinerrs();
    pbuf_free(p);
    return;
  }
}

It's not the nicest solution, but I think it fix the problem for 1.3.0.

Thoughts?



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7675>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

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