Browse Source

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>
pull/71356/head
Marcin Niestroj 1 year ago committed by David Leach
parent
commit
424ea9f5e4
  1. 6
      drivers/wifi/esp_at/esp_offload.c

6
drivers/wifi/esp_at/esp_offload.c

@ -110,8 +110,14 @@ static int esp_bind(struct net_context *context, const struct sockaddr *addr, @@ -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;
}

Loading…
Cancel
Save