zephyr/subsys/net/ip
Jukka Rissanen 9cd547f53b net: tcp: Fix ref counting for the net_pkt
The network packet ref count was not properly increased when
the TCP was retried. This meant that the second time the packet
was sent, the device driver managed to release the TCP frame even
if we had not got ACK to it.

Somewhat long debug log follows:

The net_pkt 0x08072d5c is created, we write 1K data into it, initial ref
count is 1.

net_pkt_write: pkt 0x08072d5c data 0x08075d40 length 1024
net_tcp_queue_data: Queue 0x08072d5c len 1024
net_tcp_trace: pkt 0x08072d5c src 5001 dst 5001
net_tcp_trace:    seq 0x15d2aa09 (366127625) ack 0x7f67d918
net_tcp_trace:    flags uAPrsf
net_tcp_trace:    win 1280 chk 0x0bea
net_tcp_queue_pkt: pkt 0x08072d5c new ref 2 (net_tcp_queue_pkt:850)

At this point, the ref is 2. Then the packet is sent as you see below.

net_pkt_ref_debug: TX [13] pkt 0x08072d5c ref 2 net_tcp_queue_pkt():850
net_tcp_send_data: Sending pkt 0x08072d5c (1084 bytes)
net_pkt_unref_debug: TX [13] pkt 0x08072d5c ref 1 (ethernet_send():597)

Ref is still correct, packet is still alive. We have not received ACK,
so the packet is resent.

tcp_retry_expired: ref pkt 0x08072d5c new ref 2 (tcp_retry_expired:233)
net_pkt_ref_debug: TX [10] pkt 0x08072d5c ref 2 tcp_retry_expired():233
net_pkt_unref_debug: TX [10] pkt 0x08072d5c ref 1 ... (net_if_tx():173)
net_pkt_unref_debug: TX [10] pkt 0x08072d5c ref 0 ... (net_if_tx():173)

Reference count is now wrong, it should have been 1. This is because we
did not increase the ref count when packet was placed first time into
sent list in tcp.c:tcp_retry_expired().

The fix is quite simple as you can see from this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-26 07:29:26 -05:00
..
6lo_private.h net: Convert raw timeout values to use K_MSEC() macro 2018-05-28 17:20:11 -04:00
6lo.c net/6lo: Add a way to get the difference of hdr size after uncompression 2019-02-23 07:44:59 -05:00
6lo.h net/6lo: Add a way to get the difference of hdr size after uncompression 2019-02-23 07:44:59 -05:00
canbus_socket.c net: can: Add CAN handling to net_context 2019-02-07 18:08:27 +02:00
canbus_socket.h net: can: Add CAN handling to net_context 2019-02-07 18:08:27 +02:00
CMakeLists.txt net: can: Add CAN handling to net_context 2019-02-07 18:08:27 +02:00
connection.c net: connection: Allow same port number for dest and source 2019-03-25 22:44:43 -04:00
connection.h net: can: Add CAN handling to net_context 2019-02-07 18:08:27 +02:00
dhcpv4.c net/pkt: Remove _new suffix to net_pkt_write functions 2019-03-20 10:27:14 -05:00
dhcpv4.h net: dhcpv4: Introduce config option for max delay 2019-03-05 08:29:02 -05:00
icmpv4.c net/pkt: Remove _new suffix to net_pkt_get_data_new function 2019-03-20 10:27:14 -05:00
icmpv4.h net/icmpv4: Remove unused net_icmpv4_set_checksum function 2019-03-20 10:27:14 -05:00
icmpv6.c net/pkt: Remove _new suffix to net_pkt_write functions 2019-03-20 10:27:14 -05:00
icmpv6.h net/icmpv6: Remove useless net_icmpv6_set_chksum 2019-02-12 20:24:02 -05:00
ipv4_autoconf_internal.h net: IPv4 link local support 2018-07-31 16:34:28 +03:00
ipv4_autoconf.c net/ipv4: Move autoconf to new net_pkt API 2019-02-01 14:34:38 +02:00
ipv4.c net/ip: fix input packet filtering criteria 2019-03-20 16:37:12 -05:00
ipv4.h net/ipv4: Replace legacy net_ipv4_create by the new one 2019-03-20 10:27:14 -05:00
ipv6_fragment.c net/pkt: Remove _new suffix to net_pkt_write functions 2019-03-20 10:27:14 -05:00
ipv6_mld.c net/pkt: Remove _new suffix to net_pkt_write functions 2019-03-20 10:27:14 -05:00
ipv6_nbr.c net: ipv6: Fix IPv6 neighbor table 2019-03-25 22:49:52 -04:00
ipv6.c net: Move the chksum offload verification to relevant places 2019-03-20 11:34:14 -05:00
ipv6.h net: ipv6: Fix IPv6 neighbor table 2019-03-25 22:49:52 -04:00
Kconfig net/context: Add an option so set/unset packet timestamping 2019-03-09 10:09:33 -05:00
Kconfig.debug doc: fix docs, include, and Kconfig misspellings 2019-02-28 09:32:12 +01:00
Kconfig.ipv4 kconfig: subsys: net: Remove redundant dependencies 2019-03-09 09:49:59 -05:00
Kconfig.ipv6 net: Convert core IP stack to use log levels 2018-10-04 14:13:57 +03:00
Kconfig.mgmt net: Convert core IP stack to use log levels 2018-10-04 14:13:57 +03:00
Kconfig.stack net: rpl: Remove the deprecated code 2019-01-13 09:40:36 -05:00
Kconfig.stats net: rpl: Remove the deprecated code 2019-01-13 09:40:36 -05:00
nbr.c net: Clarify logging in networking code 2018-12-07 12:00:04 +02:00
nbr.h net: Convert core IP stack to use log levels 2018-10-04 14:13:57 +03:00
net_context.c net: context: Check if we run out of mem 2019-03-20 16:32:16 -05:00
net_core.c net/pkt: Remove superfluous total_pkt_len attribute 2019-03-20 10:27:14 -05:00
net_if.c net/pkt: Remove superfluous total_pkt_len attribute 2019-03-20 10:27:14 -05:00
net_mgmt.c net: Clarify logging in networking code 2018-12-07 12:00:04 +02:00
net_pkt.c net/pkt: Remove unused legacy net_pkt allocator 2019-03-20 10:27:14 -05:00
net_private.h net/pkt: Remove useless net_pkt_set_appdata_values() function 2019-02-12 20:24:02 -05:00
net_shell.c net/context: Remove token parameter from net_context_send/sendto 2019-03-20 10:27:14 -05:00
net_shell.h net: shell: Migrate to new shell API 2018-10-15 11:14:02 +03:00
net_stats.c net: rpl: Remove the deprecated code 2019-01-13 09:40:36 -05:00
net_stats.h net: rpl: Remove the deprecated code 2019-01-13 09:40:36 -05:00
net_tc_mapping.h net: Fix credit-based shaper typos 2018-08-08 13:01:37 +03:00
net_tc.c net: rpl: Remove the deprecated code 2019-01-13 09:40:36 -05:00
packet_socket.c net: sockets: Add socket api to support AF_PACKET 2019-02-07 14:43:30 +02:00
packet_socket.h net: core: Handle packets when packet sockets are enabled 2019-02-07 14:43:30 +02:00
promiscuous.c net: Clarify logging in networking code 2018-12-07 12:00:04 +02:00
route.c net: route: Do not access null neighbor 2019-02-21 09:23:53 -05:00
route.h net: Fix the function API documentation generation 2019-02-15 16:39:06 -05:00
tcp_internal.h net/context: Remove token parameter from net_context_send/sendto 2019-03-20 10:27:14 -05:00
tcp.c net: tcp: Fix ref counting for the net_pkt 2019-03-26 07:29:26 -05:00
trickle.c net: Clarify logging in networking code 2018-12-07 12:00:04 +02:00
udp_internal.h net/udp: Remove net_udp_insert legacy function 2019-03-20 10:27:14 -05:00
udp.c net: Move the chksum offload verification to relevant places 2019-03-20 11:34:14 -05:00
utils.c net/utils: Use the right IPv4 header length for checksum calculation 2019-03-11 20:57:29 -07:00