From 38adddac00d0ec9a786e0f8efd982d2d289518c2 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 1 Jul 2020 15:34:30 +0200 Subject: [PATCH] net: lwm2m: Reinitialize address length before recvfrom is called `addrlen` parameter is updated on each `recvfrom` call, indicating the actual address length returned. In case both, IPv4 and IPv6 are used on different sockets (i. e. on regular LWM2M socket and FOTA socket), the returned address length will differ. In case `from_addr_len` is not reinitialized on each iteration, the value stored in the `from_addr_len` variable will eventually indicate the smaller IPv4 address size, therefore resulting in a failure in a consecutive call on an IPv6 socket. Signed-off-by: Robert Lubos --- subsys/net/lib/lwm2m/lwm2m_engine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index 4c2357d25d4..f5c4659a84c 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -4124,7 +4124,6 @@ static void socket_receive_loop(void) ssize_t len; int i; - from_addr_len = sizeof(from_addr); while (1) { /* wait for sockets */ if (sock_nfds < 1) { @@ -4161,6 +4160,7 @@ static void socket_receive_loop(void) continue; } + from_addr_len = sizeof(from_addr); sock_fds[i].revents = 0; len = recvfrom(sock_ctx[i]->sock_fd, in_buf, sizeof(in_buf) - 1, 0,