This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new c08ccbef02 Usrsock fallback with ENETDOWN c08ccbef02 is described below commit c08ccbef029baedf4268756b5e221dae9a08ec65 Author: daniellizewski <daniellizew...@geotab.com> AuthorDate: Tue Oct 31 12:55:28 2023 -0400 Usrsock fallback with ENETDOWN --- net/socket/socket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/socket/socket.c b/net/socket/socket.c index 964274b6e0..d6623137ad 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -104,9 +104,11 @@ int psock_socket(int domain, int type, int protocol, /* When usrsock daemon returns -ENOSYS or -ENOTSUP, it means to use * kernel's network stack, so fallback to kernel socket. + * When -ENETDOWN is returned, it means the usrsock daemon was never + * launched or is no longer running, so fallback to kernel socket. */ - if (ret == 0 || (ret != -ENOSYS && ret != -ENOTSUP)) + if (ret == 0 || (ret != -ENOSYS && ret != -ENOTSUP && ret != -ENETDOWN)) { return ret; } @@ -119,6 +121,14 @@ int psock_socket(int domain, int type, int protocol, if (sockif == NULL) { nerr("ERROR: socket address family unsupported: %d\n", domain); +#ifdef CONFIG_NET_USRSOCK + + /* We tried to fallback to kernel socket, but one is not available, + * so use the return code from usrsock. + */ + + return ret; +#endif return -EAFNOSUPPORT; }