diff --git a/net/arp/arp_notify.c b/net/arp/arp_notify.c index 4326d23c17..86427e232e 100644 --- a/net/arp/arp_notify.c +++ b/net/arp/arp_notify.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,7 @@ /* List of tasks waiting for ARP events */ -static struct arp_notify_s *g_arp_waiters; +static FAR struct arp_notify_s *g_arp_waiters; /**************************************************************************** * Private Functions @@ -176,6 +177,7 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout) { struct timespec abstime; irqstate_t flags; + int errcode; int ret; /* And wait for the ARP response (or a timeout). Interrupts will be re- @@ -193,11 +195,21 @@ int arp_wait(FAR struct arp_notify_s *notify, FAR struct timespec *timeout) abstime.tv_nsec -= 1000000000; } - /* REVISIT: If net_timedwait() is awakened with signal, we will return - * the wrong error code. - */ + /* Wait to get either the correct response or a timeout. */ + + do + { + /* The only errors that we expect would be if the abstime timeout + * expires or if the wait were interrupted by a signal. + */ + + ret = net_timedwait(¬ify->nt_sem, &abstime); + errcode = ((ret < 0) ? errno : 0); + } + while (ret < 0 && errcode == EINTR); + + /* Then get the real result of the transfer */ - (void)net_timedwait(¬ify->nt_sem, &abstime); ret = notify->nt_result; /* Remove our wait structure from the list (we may no longer be at the diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 107cdd525f..1e5ed4ab16 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -293,7 +293,7 @@ int arp_send(in_addr_t ipaddr) state.snd_cb = arp_callback_alloc(dev); if (!state.snd_cb) { - ndbg("ERROR: Failed to allocate a cllback\n"); + ndbg("ERROR: Failed to allocate a callback\n"); ret = -ENOMEM; goto errout_with_lock; } @@ -373,6 +373,7 @@ int arp_send(in_addr_t ipaddr) { /* Break out on a send failure */ + ndbg("ERROR: Send failed: %d\n", ret); break; } @@ -390,7 +391,7 @@ int arp_send(in_addr_t ipaddr) * is received. Otherwise, it will return -ETIMEDOUT. */ - if (ret == OK) + if (ret >= OK) { /* Break out if arp_wait() fails */ @@ -400,6 +401,7 @@ int arp_send(in_addr_t ipaddr) /* Increment the retry count */ state.snd_retries++; + ndbg("ERROR: arp_wait failed: %d\n", ret); } sem_destroy(&state.snd_sem); diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c index 997d81ac70..db8d4e4fe3 100644 --- a/net/devif/devif_callback.c +++ b/net/devif/devif_callback.c @@ -134,8 +134,8 @@ FAR struct devif_callback_s * return NULL; } - ret->nxtdev = dev->d_devcb; - dev->d_devcb = ret; + ret->nxtdev = dev->d_devcb; + dev->d_devcb = ret; } /* Add the newly allocated instance to the head of the specified list */ diff --git a/net/socket/sendto.c b/net/socket/sendto.c index 679fdf74e9..3332f57916 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -226,7 +226,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, if (nsent < 0) { - ndbg("ERROR: Unix domain sendto() failed: %ld\n", (long)nsent); + ndbg("ERROR: UDP or Unix domain sendto() failed: %ld\n", (long)nsent); err = -nsent; goto errout; } diff --git a/net/udp/udp_sendto.c b/net/udp/udp_sendto.c index 67ac8dcd16..e1463f7fee 100644 --- a/net/udp/udp_sendto.c +++ b/net/udp/udp_sendto.c @@ -303,61 +303,6 @@ static uint16_t sendto_interrupt(FAR struct net_driver_s *dev, FAR void *conn, return flags; } -/**************************************************************************** - * Function: sendto_txnotify - * - * Description: - * Notify the appropriate device driver that we are have data ready to - * be send (UDP) - * - * Parameters: - * psock - Socket state structure - * conn - The UDP connection structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void sendto_txnotify(FAR struct socket *psock, - FAR struct udp_conn_s *conn) -{ -#ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NET_IPv6 - /* If both IPv4 and IPv6 support are enabled, then we will need to select - * the device driver using the appropriate IP domain. - */ - - if (psock->s_domain == PF_INET) -#endif - { - /* Notify the device driver that send data is available */ - -#ifdef CONFIG_NETDEV_MULTINIC - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif - } -#endif /* CONFIG_NET_IPv4 */ - -#ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NET_IPv4 - else /* if (psock->s_domain == PF_INET6) */ -#endif /* CONFIG_NET_IPv4 */ - { - /* Notify the device driver that send data is available */ - - DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC - netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_txnotify(conn->u.ipv6.raddr); -#endif - } -#endif /* CONFIG_NET_IPv6 */ -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -430,7 +375,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, if (ret < 0) { - ndbg("ERROR: Not reachable\n"); + ndbg("ERROR: Peer not reachable\n"); return -ENETUNREACH; } #endif /* CONFIG_NET_ARP_SEND || CONFIG_NET_ICMPv6_NEIGHBOR */ @@ -474,6 +419,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, ret = udp_connect(conn, to); if (ret < 0) { + ndbg("ERROR: udp_connect failed: %d\n", ret); goto errout_with_lock; } @@ -484,6 +430,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, dev = udp_find_raddr_device(conn); if (dev == NULL) { + ndbg("ERROR: udp_find_raddr_device failed\n"); ret = -ENETUNREACH; goto errout_with_lock; } @@ -499,7 +446,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf, /* Notify the device driver of the availability of TX data */ - sendto_txnotify(psock, conn); + netdev_txnotify_dev(dev); /* Wait for either the receive to complete or for an error/timeout to occur. * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c index 8c49cbf788..1469387278 100644 --- a/net/utils/net_lock.c +++ b/net/utils/net_lock.c @@ -218,7 +218,7 @@ int net_timedwait(sem_t *sem, FAR const struct timespec *abstime) } else { - /* Wait as long as necessary to get the lot */ + /* Wait as long as necessary to get the lock */ ret = sem_wait(sem); }