Skip to content

Commit

Permalink
Revert "net: tcp: Fix ref counting for the net_pkt"
Browse files Browse the repository at this point in the history
This reverts commit 9cd547f.

The commit we are reverting, fixed originally the issue that was
seen with zperf. There we freed the net_pkt too early while it was
still waiting for a TCP ACK. The commit 9cd547f seemd to fix that
issue but it was causing issues in dump_http_server sample app which
then started to leak memory. No issues were seen with echo-server
with or without the commit 9cd547f.

So the lessons learned here is that one needs to test with multiple
network sample apps like dump_http_server, echo_server and zperf
before considering TCP fixes valid, especially fixes that touch
ref counting issues.

Fixes #15031

The next commit will fix the zperf free memory access patch.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and nashif committed Apr 1, 2019
1 parent 366ed11 commit 30d3193
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,10 @@ static void tcp_retry_expired(struct k_work *work)
pkt = CONTAINER_OF(sys_slist_peek_head(&tcp->sent_list),
struct net_pkt, sent_list);

/* In the retry case, the original ref (when the packet
* was created) is set to 1. That original ref was
* decremented when the packet was sent by the driver.
* We need to restore that original ref so that the
* device driver will not remove the retry packet that
* we just sent. Earlier we also checked net_pkt_sent(pkt)
* here but that is not correct as then the packet that was
* sent first time, was removed by the driver and we got
* access to memory already freed.
*/
do_ref_if_needed(tcp, pkt);
if (net_pkt_sent(pkt)) {
do_ref_if_needed(tcp, pkt);
net_pkt_set_sent(pkt, false);
}

net_pkt_set_queued(pkt, true);

Expand Down

0 comments on commit 30d3193

Please sign in to comment.