drivers: wifi: esp_at: do not connect socket on bind(INADDR_ANY)

All connect() syscalls result in EISCONN error, since underlying
_sock_connect() is attempted to be called twice. Once from net_context.c'
bind_default() (with INADDR_ANY) as part of esp_bind() and second time as
part of esp_connect().

Do not call _sock_connect() from esp_bind(INADDR_ANY), which happens as
part of connect().

Fixes: dbf3d6e911 ("drivers: esp_at: implement bind() and recvfrom() for
  UDP sockets")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
This commit is contained in:
Marcin Niestroj 2024-04-08 18:13:35 +02:00 committed by David Leach
commit 424ea9f5e4

View file

@ -110,8 +110,14 @@ static int esp_bind(struct net_context *context, const struct sockaddr *addr,
}
if (IS_ENABLED(CONFIG_NET_IPV4) && addr->sa_family == AF_INET) {
struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
LOG_DBG("link %d", sock->link_id);
if (addr4->sin_addr.s_addr == INADDR_ANY) {
return 0;
}
if (esp_socket_connected(sock)) {
return -EISCONN;
}