From cbd48c23aab75a9576c7d470a181b9bf94e4feee Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 5 May 2022 23:56:24 +0200 Subject: [PATCH] gnrc_sock: implicitly set netif if there is only a single one --- sys/net/gnrc/sock/include/gnrc_sock_internal.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/net/gnrc/sock/include/gnrc_sock_internal.h b/sys/net/gnrc/sock/include/gnrc_sock_internal.h index 9392315a35..6365bf16ec 100644 --- a/sys/net/gnrc/sock/include/gnrc_sock_internal.h +++ b/sys/net/gnrc/sock/include/gnrc_sock_internal.h @@ -125,13 +125,15 @@ static inline void gnrc_ep_set(sock_ip_ep_t *out, const sock_ip_ep_t *in, size_t in_size) { memcpy(out, in, in_size); - if (gnrc_netif_highlander() && (out->netif == 0)) { - /* set interface implicitly */ - gnrc_netif_t *netif = gnrc_netif_iter(NULL); + if (out->netif != SOCK_ADDR_ANY_NETIF) { + return; + } - if (netif != NULL) { - out->netif = netif->pid; - } + /* set interface implicitly */ + gnrc_netif_t *netif = gnrc_netif_iter(NULL); + if ((netif != NULL) && + (gnrc_netif_highlander() || (gnrc_netif_iter(netif) == NULL))) { + out->netif = netif->pid; } }