Commit Graph

173 Commits

Author SHA1 Message Date
Xiang Xiao
e0bb281e7a net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
Huang Qi
e4e3208180 Replace all strncpy with strlcpy for safety
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08:00
Xiang Xiao
838690fc9f net/local: Remove the sync preamble from datagram
since pipe is a reliable transport, the sync just waste the space and time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-10 09:50:25 +03:00
田昕
20b9cc37d5 net/local:Make local send multi-thread safe
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-08-08 22:45:44 +08:00
ligd
5b9a953381 local: fix nx_style
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
390de249a0 local: connect operation should jump self's connection
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
cd5ab80f2f local: server accept should wait client connect done
server:
at accept last nxsem_post(&client->lc_waitsem);

client:
connect wait(&client->lc_waitsem) then local_open_client_rx();

But if the server priority is higher then client,
and after server accept return, immediately call send().
At this time the client has no way do local_open_client_rx().
Then server send() return error.

Fix:
add lc_done sem to client

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
e489a308c8 local_socket: remove error log when use nonblock mode
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
Jiuzhu Dong
d87cf8d4ca fs/poll: change format for type pollevent_t
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-07 12:14:06 +08:00
Xiang Xiao
e4b73d90d7 net/local: change 255 to UINT8_MAX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-01 23:14:15 +08:00
zhanghu6
fb912da252 local socket: cancel assert about backlog exceed 255
Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>
2022-04-01 23:14:15 +08:00
ligd
ad9ba8f454 local_socket: default set block mode if accept() a new socket
reference:
https: //man7.org/linux/man-pages/man2/accept.2.html

1. default set block mode if accept() a new socket
2. local_socket support FIONBIO

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-28 23:26:34 +08:00
chao.an
b0d553a068 net/local: correct the socket flags from client socket
socket flags from connect() should used from client

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-17 23:15:40 +08:00
chao.an
40f056e92c net/local: correct the socket flags from server socket
newsock = accept(server, &addr, &addrlen);

replace the socket flags from newsock to server to ensure that
the nonblock flags is handled correctly

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-15 23:04:59 +09:00
Xiang Xiao
716e27cbeb net/local: Remove local_initialize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
Xiang Xiao
4a16cf71f9 Fix -Werror=nonnull-compare and -Werror=format-truncation=
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
  203 |   strncpy(modp->modname, modname, MODLIB_NAMEMAX);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wqueue/kwork_thread.c: In function 'work_start_lowpri':
Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=]
  212 |   snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue);

local/local_sockif.c: In function 'local_getsockname':
Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  392 |           strncpy(unaddr->sun_path, conn->lc_path, namelen);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse':
Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
   memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer));
                                     ^

stdio/lib_fputs.c: In function 'fputs':
Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
         ^
Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
                           ^

stdio/lib_vfprintf.c: In function 'vfprintf':
Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (stream)
      ^

string/lib_strdup.c: In function 'strdup':
Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strndup.c: In function 'strndup':
Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strpbrk.c: In function 'strpbrk':
Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
       ^~~~
Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
               ^~~~~~~~

string/lib_strrchr.c: In function 'strrchr':
Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                                                  ^~
time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            1900 + tp->tm_year);
            ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 15:55:38 +08:00
chao.an
99cde13a11 net/inet: move socket flags into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
af1cf5eaae net/local: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
3d62d5106d net/local: remove duplicate assert condition
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
Xiang Xiao
108a5004c5 net/local: Rename NET_LOCAL_PATH_PREFIX to NET_LOCAL_VFS_PATH
align with other similiar config which suffix with _VFS_PATH

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-06 19:42:00 +01:00
Juha Niskanen
422ceec99b Fix typos in comments and Kconfig files
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-12-21 03:26:16 -06:00
ligd
68bbcf74c4 local_socket: filename use "/var/socket/xx" instead of "/var/socketxx"
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 02:37:11 -06:00
ligd
391ccdc42b local_socket: recv should return 0 NOT -ECONNRESET if remote closed
ref:
https://man7.org/linux/man-pages/man2/recv.2.html

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
ligd
1970ce5116 local_socket: set lc_peer when accept() instead of connect()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
chao.an
1b5d6aa068 net/local: add socket message control support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
ea82a0b638 net/local: add local_peerconn helper
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
1e078795fb net/local: split the waiter node from lc_node
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
1ba922a826 net/local: replace the listener list to global
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
b991b75e87 net/local: add FIONSPACE support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-15 12:11:32 +08:00
buyuer
001eb7786b net/local: Return the partial write size.
Signed-off-by: buyuer <dingddding@163.com>
2021-08-26 13:28:11 +08:00
chao.an
efaf72a1b1 net/local: correct the return length of sendmsg
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-21 14:59:59 +08:00
chao.an
1a55d933ef net/local: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 19:18:52 -07:00
SPRESENSE
d17d877764 net/local: Fix receive data size calculation for local_recvmsg
In psock_dgram_recvfrom function, fix code logic.
2021-08-19 01:31:05 -07:00
chao.an
a48513ad65 local/stream: remove preamble header in stream mode
Preable sync header is no necessary in stream mode

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an
cc5c7ee088 net/local: remove unused client lc_remaining
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an
1dbe8de750 net/local: add AF_[UNIX|LOCAL] socketpair support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
9f3f4fb558 net/local: extern local_generate_instance_id() interface
Change-Id: I14273d11b1fe4d6bdc15b14e32da609cc7883713
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
eabe535de7 net/inet: add support of FIONREAD
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 06:20:52 -05:00
Xiang Xiao
d8769cb4f0 net/local: Remove all HAVE_LOCAL_POLL reference
since HAVE_LOCAL_POLL always hardcode to 1

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-17 07:09:10 -03:00
chao.an
805d3a2061 net/local: add local_nextconn() helper
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-10 13:57:32 -03:00
Xiang Xiao
d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
chao.an
f8e800765c net/local: correct the sendto() return length
return length should be data length

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-04-19 11:52:17 -05:00
Xiang Xiao
9523d4bea4 net/local: Remove local_send.c since nobody use it now
Forget to remove in:
commit e223f60c09
Author: Peter Bee <bijunda1@xiaomi.com>
Date:   Tue Dec 1 14:55:16 2020 +0800

    net/socket: move si_send/recv into sendmsg/recvmsg

    Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
    the other way round.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-03-12 16:42:52 -03:00
Peter Bee
6f995e377c fix local_sendmsg return length
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-03-12 21:04:39 +08:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Peter Bee
e223f60c09 net/socket: move si_send/recv into sendmsg/recvmsg
Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.

Change-Id: I7b858556996e0862df22807a6edf6d7cfe6518fc
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-03-05 04:46:13 -08:00
Jiuzhu Dong
4d5a964f29 net: unify socket into file descriptor
Change-Id: I9bcd21564e6c97d3edbb38aed1748c114160ea36
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-03 19:01:41 -08:00
Xiang Xiao
9473434587 Ensure the kernel component don't call userspace API
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-03-01 09:23:09 +09:00
Gustavo Henrique Nihei
76acb32e29 Fix typos reported by codespell 2021-02-25 11:31:49 -08:00
Alin Jerpelea
37d5c1b0d9 net: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-20 00:38:18 -08:00