zephyr/subsys
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
..
bindesc bindesc: Add support for the build version values 2024-09-04 07:03:47 -04:00
bluetooth Bluetooth: CSIP: Add bonding requirement for set lock/release 2024-09-26 03:31:47 -04:00
canbus lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h 2024-09-07 11:19:05 -05:00
console
dap kconfig: replace known integer constants with variables 2024-07-27 20:49:15 +03:00
debug debug: coredump: dump privileged stack 2024-09-21 11:29:39 +02:00
demand_paging demand_paging: add a semihosting based backing store for on-demand sections 2024-09-11 20:18:51 -04:00
dfu
disk disk: disk_access: changed mutex for a spinlock 2024-08-26 17:26:36 -04:00
dsp
emul emul: Support UART device emulation 2024-07-30 18:28:17 +01:00
fb fb: cfb: Fix CID 394240 2024-07-05 18:39:22 +02:00
fs fs: nvs: fix nvs static analysis error 2024-09-04 12:51:14 +02:00
input input: double tap 2024-08-19 09:56:26 -04:00
ipc ipc: icmsg & icbmsg: Add support for POSIX arch targets 2024-09-26 03:34:26 -04:00
jwt mbedtls: do not set PSA_WANT_KEY_TYPE_[RSA/ECC]_KEY_PAIR_BASIC 2024-09-12 10:02:40 +02:00
llext llext: export DT devices to extensions 2024-09-25 12:59:13 +02:00
logging logging: log_output: timestamp_print uses gmtime_r, a POSIX function 2024-09-24 14:29:02 -05:00
lorawan
mem_mgmt
mgmt mgmt: mcumgr: Add SMP SVC and CHR UUIDs to header 2024-09-23 18:10:49 -04:00
modbus
modem modem: ubx: fix incoming byte processing 2024-08-02 03:29:18 -04:00
net net: tcp: Make sure that connection failure is propagated to app 2024-09-26 10:58:37 +01:00
pm pm: policy: change the policy event handling 2024-09-09 13:56:04 -04:00
portability kconfig: replace known integer constants with variables 2024-07-27 20:49:15 +03:00
profiling style: subsys: comply with MISRA C:2012 Rule 15.6 2024-09-11 07:40:35 -04:00
random
retention
rtio rtio: Split the rx and tx buffer unions 2024-08-17 08:55:01 -04:00
sd sd: resend CMD0 before each CMD8 2024-08-27 15:14:23 -04:00
sensing
settings kconfig: replace known integer constants with variables 2024-07-27 20:49:15 +03:00
shell style: subsys: adjust return usage in void functions 2024-09-20 11:06:55 +02:00
sip_svc
stats
storage
task_wdt
testsuite Ztest: Ztest_param fix 2024-09-19 03:25:17 -04:00
timing
tracing style: subsys: comply with MISRA C:2012 Rule 15.6 2024-08-20 10:33:51 +02:00
usb usb: device_next: uac2: Support multiple sample rates 2024-09-13 09:21:58 +02:00
zbus lib: net_buf: rename header file from zephyr/net/buf.h to zephyr/net_buf.h 2024-09-07 11:19:05 -05:00
CMakeLists.txt lib: net_buf: move the network buffer implementation to lib 2024-09-07 11:19:05 -05:00
Kconfig profiling: Add perf tool 2024-08-13 18:28:44 -04:00