Skip to content
Snippets Groups Projects
Commit fa3ad468 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

net/udp: In sendto(), return EHOSTUNREACH if if the network is down.

parent fef255e5
No related branches found
No related tags found
No related merge requests found
......@@ -384,6 +384,14 @@ static int sendto_next_transfer(FAR struct socket *psock,
return -ENETUNREACH;
}
/* Make sure that the device is in the UP state */
if ((dev->d_flags & IFF_UP) == 0)
{
nwarn("WARNING: device is DOWN\n");
return -EHOSTUNREACH;
}
/* If this is not the same device that we used in the last call to
* udp_callback_alloc(), then we need to release and reallocate the old
* callback instance.
......
......@@ -424,6 +424,15 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
goto errout_with_lock;
}
/* Make sure that the device is in the UP state */
if ((dev->d_flags & IFF_UP) == 0)
{
nwarn("WARNING: device is DOWN\n");
ret = -EHOSTUNREACH;
goto errout_with_lock;
}
/* Set up the callback in the connection */
state.st_cb = udp_callback_alloc(dev, conn);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment