chao an
4068b2eccc
net/procfs: add entry mapping table
...
add entry mapping table to simplify new component registration
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 09:03:34 +08:00
chao an
3913ef2f2f
net/inet: invalid addrlen length should return EINVAL
...
https://www.freebsd.org/cgi/man.cgi?connect
[EINVAL] The namelen argument is not a valid length for the address family.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 09:02:30 +08:00
zhanghongyu
9bff29d7e7
udp: add IPVx_PKTINFO related support
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-09-07 10:49:47 +08:00
chao an
54dba40f87
net/netdev/ioctl: correct the argument length of ioctl MII/PHY
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-07 03:33:41 +08:00
Xiang Xiao
9726be616a
fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 23:16:15 +08:00
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
chao an
0978dcf88d
net/mld/route: fix build warning
...
In file included from route/net_del_ramroute.c:30:
route/net_del_ramroute.c: In function ‘net_match_ipv4’:
route/net_del_ramroute.c:93:9: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
93 | ninfo(" target=%08lx netmask=%08lx\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
route/net_del_ramroute.c:93:23: note: format string is defined here
93 | ninfo(" target=%08lx netmask=%08lx\n",
| ~~~~^
| |
| long unsigned int
| %08x
mld/mld_timer.c: In function ‘mld_gendog_work’:
mld/mld_timer.c:118:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
118 | ifindex = (int)arg;
| ^
mld/mld_timer.c: In function ‘mld_v1dog_work’:
mld/mld_timer.c:237:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
237 | ifindex = (int)arg;
| ^
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-06 18:24:20 +08:00
chao an
63cd44e5e1
net/usrsock: forward FIONBIO to socket level
...
fix usrsock nonblock connect test break:
apps/examples/usrsocktest/usrsocktest_noblock_connect.c:
...
157 TEST(no_block_connect, delayed_connect)
158 {
...
190 ret = fcntl(sd, F_SETFL, flags | O_NONBLOCK);
...
204 ret = connect(sd, (FAR const struct sockaddr *)&addr, sizeof(addr));
205 TEST_ASSERT_EQUAL(-1, ret);
206 TEST_ASSERT_EQUAL(EINPROGRESS, errno);
should goahead to socket level:
nuttx/net/netdev/netdev_ioctl.c:
...
1755 int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
1756 {
...
1771 ret = netdev_ioctl(psock, cmd, arg);
...
1775 if (ret == -ENOTTY)
1776 {
1777 ret = netdev_file_ioctl(psock, cmd, arg);
1778 }
...
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 14:44:50 +08:00
Masayuki Ishikawa
aaae317d0c
Revert "net/usrsock: read from the closed remote should return EOF"
...
This reverts commit 3a653c1d5e
.
2022-09-01 13:16:46 +09:00
chao an
5d4c774352
net/usrsock: allow usrsock *DATA_ACK with no-preload data
...
allow usrsock USRSOCK_MESSAGE_RESPONSE_DATA_ACK with no-preload data
so addrlen could be updated to valuelen_nontrunc of usrsock_message_datareq_ack_s
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 09:09:25 +09:00
chao an
3a653c1d5e
net/usrsock: read from the closed remote should return EOF
...
fix usrsock remote_disconnect fail:
nsh> usrsocktest
...
Testing group "remote_disconnect" =>
[TEST ASSERT FAILED!]
In function "receive":
line 497: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "remote_disconnect": [FAILED]
...
Reference:
RECV(2)
NAME
recv, recvfrom, recvmsg - receive a message from a socket
...
RETURN VALUE
...
When a stream socket peer has performed an orderly shutdown,
the return value will be 0 (the traditional "end-of-file" return).
Datagram sockets in various domains (e.g., the UNIX and Internet domains)
permit zero-length datagrams. When such a datagram is received, the return value is 0.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 08:48:26 +09:00
chao an
fe7badf2ac
net/getsockname: small addrlen should be a valid value
...
fix usrsock getsockname fail
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
...
Reference:
GETSOCKNAME(2)
NAME
getsockname - get socket name
...
DESCRIPTION
...
The returned address is truncated if the buffer provided is too small;
in this case, addrlen will return a value greater than was supplied to the call.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 01:19:09 +08:00
chao an
6f27c29ce5
net/usrsock: Change xid from uint64_t to uint32_t
...
follow the below change:
-----------------------------------------------
commit 0334819742
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Mon Aug 22 05:10:47 2022 +0800
net/usrsock: Change xid from uint64_t to uint32_t
by generating the new xid for each transaction
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2022-08-31 19:01:29 +02:00
chao.an
bf6cbbca5d
net/tcp: fix devif callback list corruption on tcp_close()
...
devif_conn_event() will be called recursively in the psock_send_eventhandler(),
if the tcp event tcp_close_eventhandler() is marked as "next" in first devif_conn_event()
and released from sencond recursive call, the "next" event in the first devif_conn_event()
will become a wild pointer.
479 uint16_t devif_conn_event(FAR struct net_driver_s *dev, uint16_t flags,
480 FAR struct devif_callback_s *list)
481 {
482 FAR struct devif_callback_s *next;
...
488 net_lock();
489 while (list && flags)
490 {
...
496 next = list->nxtconn; <------------------ event tcp_close_eventhandler() on next
...
500 if (list->event != NULL && devif_event_trigger(flags, list->flags))
501 {
...
507 flags = list->event(dev, list->priv, flags); <---------------- perform psock_send_eventhandler(), event tcp_close_eventhandler() will be remove from tcp_lost_connection()
508 }
...
512 list = next; <---------------- event tcp_close_eventhandler() has been released, wild pointer
513 }
514
515 net_unlock();
516 return flags;
517 }
The callstack as below:
Breakpoint 1, tcp_close_eventhandler (dev=0x56607d80 <g_sim_dev>, pvpriv=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_close.c:83
(gdb) bt
| #0 tcp_close_eventhandler (dev=0x56607d80 <g_sim_dev>, pvpriv=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_close.c:83
| #1 0x5658bb57 in devif_conn_event (dev=0x56607d80 <g_sim_dev>, flags=65, list=0x56609498 <g_cbprealloc+312>) at devif/devif_callback.c:507
----------------> devif_conn_event() recursively
| #2 0x56589f8c in tcp_callback (dev=0x56607d80 <g_sim_dev>, conn=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_callback.c:169
| #3 0x565c55e4 in tcp_shutdown_monitor (conn=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_monitor.c:211
| #4 0x565c584b in tcp_lost_connection (conn=0x566084a0 <g_tcp_connections>, cb=0x566094b0 <g_cbprealloc+336>, flags=65) at tcp/tcp_monitor.c:391
| #5 0x565c028a in psock_send_eventhandler (dev=0x56607d80 <g_sim_dev>, pvpriv=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_send_buffered.c:544
----------------> call psock_send_eventhandler() before tcp_close_eventhandler()
| #6 0x5658bb57 in devif_conn_event (dev=0x56607d80 <g_sim_dev>, flags=65, list=0x566094b0 <g_cbprealloc+336>) at devif/devif_callback.c:507
| #7 0x56589f8c in tcp_callback (dev=0x56607d80 <g_sim_dev>, conn=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_callback.c:169
| #8 0x5658e8cc in tcp_input (dev=0x56607d80 <g_sim_dev>, domain=2 '\002', iplen=20) at tcp/tcp_input.c:1059
| #9 0x5658ed77 in tcp_ipv4_input (dev=0x56607d80 <g_sim_dev>) at tcp/tcp_input.c:1355
| #10 0x5658c0a2 in ipv4_input (dev=0x56607d80 <g_sim_dev>) at devif/ipv4_input.c:358
| #11 0x56577017 in netdriver_recv_work (arg=0x56607d80 <g_sim_dev>) at sim/up_netdriver.c:182
| #12 0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #13 0x5655983f in nxtask_start () at task/task_start.c:129
(gdb) c
Continuing.
Breakpoint 1, tcp_close_eventhandler (dev=0x56607d80 <g_sim_dev>, pvpriv=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_close.c:83
(gdb) bt
| #0 tcp_close_eventhandler (dev=0x56607d80 <g_sim_dev>, pvpriv=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_close.c:83
----------------------> "next" corrupted, invaild call tcp_close_eventhandler()
| #1 0x5658bb57 in devif_conn_event (dev=0x56607d80 <g_sim_dev>, flags=65, list=0x56609498 <g_cbprealloc+312>) at devif/devif_callback.c:507
| #2 0x56589f8c in tcp_callback (dev=0x56607d80 <g_sim_dev>, conn=0x566084a0 <g_tcp_connections>, flags=65) at tcp/tcp_callback.c:169
| #3 0x5658e8cc in tcp_input (dev=0x56607d80 <g_sim_dev>, domain=2 '\002', iplen=20) at tcp/tcp_input.c:1059
| #4 0x5658ed77 in tcp_ipv4_input (dev=0x56607d80 <g_sim_dev>) at tcp/tcp_input.c:1355
| #5 0x5658c0a2 in ipv4_input (dev=0x56607d80 <g_sim_dev>) at devif/ipv4_input.c:358
| #6 0x56577017 in netdriver_recv_work (arg=0x56607d80 <g_sim_dev>) at sim/up_netdriver.c:182
| #7 0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #8 0x5655983f in nxtask_start () at task/task_start.c:129
(gdb) c
Continuing.
[ 2.680000] up_assert: Assertion failed at file:devif/devif_callback.c line: 85 task: lpwork
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-30 19:41:18 +08:00
chao.an
162fcd10ca
net: cleanup pvconn reference to avoid confuse
...
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
chao.an
ea621599fd
net: remove pvconn reference from all devif callback
...
Do not use 'pvconn' argument to get the connection pointer since
pvconn is normally NULL for some events like NETDEV_DOWN.
Instead, the connection pointer can be reliably obtained from the
corresponding private pointer.
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
chao.an
77a99acc98
net/icmpv6: fix build break "duplicate macro parameter"
...
Error: net/icmpv6/icmpv6.h:442:33: error: duplicate macro parameter "d"
# define icmpv6_setaddresses(d,d,p,p) (0)
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
zhanghongyu
cc421e43e4
icmpv6: add NTOHL when parse ICMPV6 option MTU
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
luojun1
00cf3e559d
update IPv6 NIC parameters unconditionally when ICMPv6 RA is received
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
luojun1
7c2986bb34
finetune the RA parsing procedure
...
Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 10:00:22 +02:00
Fotis Panagiotopoulos
9bc47ecdce
Added lock in ifr ioctl calls.
2022-08-25 14:02:20 +02:00
chao.an
9cb17841d8
net/sockopt: move BINDTODEVICE to socket level
...
rename the UDP_BINDTODEVICE to SO_BINDTODEVICE to follow the linux
style to be compatible with non-UDP protocol binding requirements
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-25 17:56:52 +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
chengkai
841d8f5b37
net:add btsnoop and snoop
...
Signed-off-by: chengkai <chengkai@xiaomi.com>
2022-08-24 21:42:30 +08:00
Xiang Xiao
0334819742
net/usrsock: Change xid from uint64_t to uint32_t
...
by generating the new xid for each transaction
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-23 12:16:33 -03:00
Xiang Xiao
697e2a333b
net/usrsock: Remove dev field from usrsockdev_s
...
since this field isn't really used at all
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-22 17:49:51 +03:00
zhanghongyu
e03c2c321a
tcp: reset conn->nrtx when ack received
...
Otherwise, when a long test triggers multiple timeout retransmissions,
the late timeout retransmissions are always delayed between 24 and 48 seconds
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-08-17 21:35:09 +03:00
Xiang Xiao
ba9486de4a
iob: Remove iob_user_e enum and related code
...
since it is impossible to track producer and consumer
correctly if TCP/IP stack pass IOB directly to netdev
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-15 08:41:20 +03: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
Jiuzhu Dong
fe17f747a7
fs/directory: move private directory information to filesystem
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Jiuzhu Dong
90db4daca9
fs/directory: update readdir interface for all filesystem
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
田昕
20b9cc37d5
net/local:Make local send multi-thread safe
...
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-08-08 22:45:44 +08:00
Petro Karashchenko
b3cd9090d1
drivers/net: make sure that net driver d_buf is 16-bit aligned
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-05 22:21:37 +08:00
Peter van der Perk
013a562478
Net thread-safe ntoa functions
...
Apply suggestions from code review
Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-02 21:04:19 +08:00
Peter van der Perk
26dbdba5d8
[TCP] Close RAM usage optimization
2022-07-29 23:51:06 +08:00
liyi
b232508bd9
make sure conn's domain is match with addr's family
2022-07-29 13:53:19 +08:00
ligd
8a3683fb9f
rptun: add ns_match callback to resolve rptun deadlock
...
thread A: accept -> net_lock -> socket_rpmsg_accept
-> rpmsg_register_callabck -> rptun_lock
thread B: ns_bind -> rpmsg_socket_ns_bind -> get_tx_payload_buffer
-> rptun_wait_tx -> usrsock_rpmsg_ept_cb -> usrsockdev_write
-> net_lock -> deadlock
fix:
add ns_match callback
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
zhanghongyu
fc35cf4737
udp: Use s_sndtimeo as the actual timeout time
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-26 12:06:14 +03:00
zhanghongyu
ef660083c8
tcp: check option length before d_len update
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-26 12:05:06 +03:00
Peter van der Perk
b3590f00b3
NXStyle and preprocessor fixes
...
Co-authored-by: Jari van Ewijk <jari.vanewijk@nxp.com>
2022-07-25 23:47:05 +08:00
Jari van Ewijk
51a845ce54
SocketCAN: add non-blocking write
...
Co-authored-by: Peter van der Perk <peter.vanderperk@nxp.com>
2022-07-25 23:47:05 +08:00
zhanghongyu
51a262150d
wifi: clear IFF_RUNNING flag when ifdown
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
zhanghongyu
7467586d55
netdev: add return value for ifup / ifdown
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
ligd
79952163c1
rpmsg_socket: use sendto_nocopy() instead of send_nocopy().
...
only wait ept ready after ept_create, not after ept_destroy
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
9c106c1bdc
rpmsg_socket: defalut set POLLERR POLLHUP to events
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
ba990619ed
socket_rpmsg: set poll err instead return err
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
630ca45a50
rpmsg_socket: connect addrlen can bigger then expect
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
Jiuzhu Dong
fab2f6d3d8
net/rpmsg: fix minor issue on strncpy
...
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-23 08:16:48 +03: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