zephyr/subsys/net/ip
Jukka Rissanen a41f625fab net: tcp: Make sure that connection failure is propagated to app
It is possible that TCP connect() will fail if for example network
interface does not have IP address set. In this case we close
the connection during net_tcp_connect() but do not set the return
code properly. This looks in the application like the connection
succeeded even if it was not.

As the tcp_in() call in net_tcp_connect() might close the connection,
we just take extra ref count while calling tcp_in(). Otherwise we
might access already freed connection.

Before the fix:

net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp_connect: conn: 0x8087320, ret=0

After the fix:

net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_conn_ref: conn: 0x8087320, ref_count: 2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=2
net_tcp: tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp: net_tcp_connect: conn: 0x8087320, ret=-128

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-26 10:58:37 +01:00
..
6lo_private.h
6lo.c
6lo.h
canbus_socket.c
canbus_socket.h
CMakeLists.txt net: ipv4: Implement IPv4 address conflict detection 2024-06-10 00:59:28 -07:00
connection.c net: ip: fix typo 2024-06-25 21:19:00 -04:00
connection.h everywhere: replace double words 2024-06-22 05:40:22 -04:00
icmp.c
icmpv4.c net: Support partial checksum offloading 2024-06-14 17:10:43 -04:00
icmpv4.h
icmpv6.c net: Support partial checksum offloading 2024-06-14 17:10:43 -04:00
icmpv6.h
igmp.c
ipv4_acd.c net: ipv4: Implement IPv4 address conflict detection 2024-06-10 00:59:28 -07:00
ipv4_autoconf.c net: ipv4: autoconf: Integrate with the ACD module 2024-06-10 00:59:28 -07:00
ipv4_fragment.c net: ipv4: Fix tx_pkts slab leak in send_ipv4_fragment 2024-07-27 10:45:14 +03:00
ipv4.c net: ip: fix typo 2024-06-25 21:19:00 -04:00
ipv4.h net: ipv4: Implement IPv4 address conflict detection 2024-06-10 00:59:28 -07:00
ipv6_fragment.c
ipv6_mld.c
ipv6_nbr.c net: Add onlink and forwarding check to IPv6-prepare 2024-09-17 20:11:32 -04:00
ipv6_pe.c net: ipv6-pe: Verify that hmac calculation was ok 2024-07-03 15:25:58 +02:00
ipv6.c net: ipv6: Allow incoming DAD NS message 2024-08-26 11:07:59 -04:00
ipv6.h net: ip: fix typo 2024-06-25 21:19:00 -04:00
Kconfig net: shell: Allow user to disable not used commands 2024-09-23 14:10:15 +01:00
Kconfig.debug
Kconfig.ipv4 net: ipv4: Make native IPv4 options dependent on NET_NATIVE_IPV4 2024-09-23 14:08:34 +01:00
Kconfig.ipv6 net: ipv6: Setting Router Solication Packet timeout 2024-09-23 12:00:35 +02:00
Kconfig.mgmt
Kconfig.stack
Kconfig.stats net: stats: dns: Collect DNS statistics 2024-09-25 13:52:15 -05:00
Kconfig.tcp kconfig: replace known integer constants with variables 2024-07-27 20:49:15 +03:00
nbr.c
nbr.h
net_context.c net: context: Set IPv4 address properly for sendmsg() 2024-09-17 05:22:48 -04:00
net_core.c net: tracing: Add net_send_data function tracing 2024-08-19 21:50:21 -04:00
net_if.c net: if: Check chksum offloading properly for VLAN interfaces 2024-09-24 10:11:33 +02:00
net_mgmt.c net: mgmt: Fix build error when event direct enabled without event info 2024-07-09 11:49:47 +02:00
net_pkt.c lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h 2024-09-07 11:19:05 -05:00
net_private.h net: sockets: Update msg_controllen in recvmsg properly 2024-08-23 15:50:37 +01:00
net_stats.c
net_stats.h net: stats: dns: Collect DNS statistics 2024-09-25 13:52:15 -05:00
net_tc_mapping.h
net_tc.c
net_timeout.c everywhere: replace double words 2024-06-22 05:40:22 -04:00
packet_socket.c
packet_socket.h
promiscuous.c
route.c net: ipv6: route: get nexthop's LL address only if relevant 2024-08-08 15:37:32 +02:00
route.h net: ipv6: mcast_routing: hop limit handling 2024-06-13 05:44:30 -04:00
tcp_internal.h
tcp_private.h net: tcp: Keep track of recv window size change since last ACK 2024-07-31 12:56:52 +02:00
tcp.c net: tcp: Make sure that connection failure is propagated to app 2024-09-26 10:58:37 +01:00
tcp.h
tp_priv.h net: change controlling expressions in while to Boolean 2024-06-11 20:03:16 +03:00
tp.c net: change controlling expressions in while to Boolean 2024-06-11 20:03:16 +03:00
tp.h
udp_internal.h
udp.c net: Support partial checksum offloading 2024-06-14 17:10:43 -04:00
utils.c net: ip: utils: revise data type declarations in z_impl_net_addr_ntop 2024-08-06 17:15:50 -04:00