Zhe Weng
3e4d847f42
net/netdev: Support managing multiple IPv6 addresses by ioctl
...
1. Supporting `SIOCSIFADDR` and `SIOCDIFADDR` with Linux in6_ifreq struct to manage ipv6 addresses.
Ref: https://man7.org/linux/man-pages/man7/netdevice.7.html
2. Supporting alias like 'eth0:0' for multiple IPv6 addresses, to keep previous ioctl `SIOCGLIFADDR`, `SIOCSLIFADDR`, `SIOCGLIFNETMASK` and `SIOCSLIFNETMASK` working.
Ref: https://man7.org/linux/man-pages/man8/ifconfig.8.html
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
Xiang Xiao
21beb284bc
net/usersock: Return -ENOSUPP directly if domain isn't equal to PF_INET/PF_INET6
...
regression by https://github.com/apache/nuttx/pull/9647
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-09 18:04:29 -04:00
SPRESENSE
011d45e956
net/usrsock: Can enable TCP/UDP IP stack with Usrsock enabled
...
Some use cases, such as VPN, use both the device's network
stack with the Usrsock daemon and the Kernel's network stack.
Therefore, remove NET_TCP_NO_STACK/NET_UDP_NO_STACK select
from Usrsock's Kconfig.
2023-09-21 01:08:11 +08:00
chao an
7d1763a57c
net/assert: remove all unnecessary check for psock/conn
...
Since inet/socket layer already contains sanity checks, so remove unnecessary lower half checks
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 20:36:49 +08:00
chao an
6ee9ec7656
build: add initial cmake build system
...
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
------------------
How to test
From within nuttx/. Configure:
cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja
(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
--------------------------
2. cmake/build: reformat the cmake style by cmake-format
https://github.com/cheshirekow/cmake_format
$ pip install cmakelang
$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done
Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Xiang Xiao
75ecbd4382
net/local: Return the unblock handle correctly in local_accept
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-09 09:17:19 +01:00
Fotis Panagiotopoulos
5e625b9cdb
Performance optimizations in connection allocations.
2023-02-28 14:23:16 +01:00
Xiang Xiao
2c5f653bfd
Remove the tail spaces from all files except Documentation
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-26 13:24:24 -08:00
Zhe Weng
31b65844a2
usrsock: Do not return error when conn not found for an event
...
There might be some cases that we receive an event after socket is closed because of out-of-ordered rpmsg, since it may not cause problem, we may omit the error.
Also change log level to err when returning negated errno, because if we return negated errno, we'll directly trigger RPMSG_ASSERT outside, so we need at least an error message to indicate the reason.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-02-22 01:42:14 +08:00
Fotis Panagiotopoulos
f207072121
Improvements in usrsock connections allocation.
2023-02-20 09:06:46 +08:00
Xiang Xiao
0ef073573a
net: Remove protocol argument from si_setup callback
...
since the implementor could get the same value from socket::s_proto
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-13 22:41:19 +08:00
chao an
e942a7c55e
build/Kconfig: fix warnings detected by kconfiglib
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:07:46 +08:00
chao an
3a0fdb019d
nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
zhanghongyu
e7d1ba157c
usrsock: Don't clear recvfrom available flag
...
Don't clear available flag if the response indicate there is more data
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-02-04 20:52:56 +09:00
zhanghongyu
01fe37206a
usrsock: optimize send case
...
Don't clear available flag if the response indicate there is more space
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-02-04 20:52:56 +09:00
Zhe Weng
d3dd349649
net: Implement shutdown() for usrsock
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
Zhe Weng
8819eeaf15
net: Implement shutdown() interface and tcp shutdown
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
lilei19
1d8af7e105
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-31 12:08:05 +09:00
liangchaozhong
7e80879f88
usrsock: Output the log if usrsock_request return error
...
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
liangchaozhong
cc940e8f69
net_lock:fix deadlock issue when running iperf tx test on usrsock
...
Issue Description:
deadlock happens when runnging iperf TCP tx on usrsock with the
following commands:
device command: iperf2 -c <PC IP address> -u -i 1 -p 1122 -t 10
PC command: iperf -s -u -i 1 -p 1122
iperf's thread holds net_lock before call usrsock_setup_request_callback
and waits for conn->resp.sem by calling
nxsem_wait_uninterruptible(&conn->resp.sem), while conn->resp.sem
can only be signaled in usrsock_response, who is waiting for net_lock in
tptun's thread.
Solution:
call net_lockedwait_uninterruptible to make sure net_lock can be
released when conn->resp.sem is not available.
Here's the backtrace:
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
nxsem_wait_uninterruptible
nuttx/sched/semaphore/sem_wait.c:223 (discriminator 1)
usrsock_setup_request_callback
nuttx/net/usrsock/usrsock_conn.c:228
usrsock_setup_data_request_callback
nuttx/net/usrsock/usrsock_conn.c:257
usrsock_getsockopt
nuttx/net/usrsock/usrsock_getsockopt.c:202
psock_getsockopt
nuttx/net/socket/getsockopt.c:448
getsockopt
nuttx/net/socket/getsockopt.c:515
getsock_tcp_windowsize
external/iperf2/iperf2/src/tcp_window_size.c:165
reporter_reportsettings
external/iperf2/iperf2/src/ReportDefault.c:384
reporter_print
external/iperf2/iperf2/src/Reporter.c:1402
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:860
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:828
reporter_spawn
external/iperf2/iperf2/src/Reporter.c:720
thread_run_wrapper
external/iperf2/iperf2/compat/Thread.c:270
pthread_startup
nuttx/libs/libc/pthread/pthread_create.c:59 (discriminator 2)
pthread_start
nuttx/sched/pthread/pthread_create.c:182 (discriminator 4)
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
sem_wait
nuttx/sched/semaphore/sem_wait.c:271
nxmutex_lock
nuttx/include/nuttx/mutex.h:165
nxrmutex_lock
nuttx/include/nuttx/mutex.h:369
usrsock_handle_req_response
nuttx/net/usrsock/usrsock_devif.c:466
usrsockdev_write
nuttx/drivers/usrsock/usrsock_dev.c:304
file_write
nuttx/fs/vfs/fs_write.c:90
usrsock_rpmsg_default_handler
apps/netutils/usrsock_rpmsg/usrsock_rpmsg_client.c:137
rpmsg_virtio_rx_callback
nuttx/openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:371
virtqueue_notification
nuttx/openamp/open-amp/lib/virtio/virtqueue.c:706
rproc_virtio_notified
nuttx/openamp/open-amp/lib/remoteproc/remoteproc_virtio.c:337 (discriminator 2)
remoteproc_get_notification
nuttx/openamp/open-amp/lib/remoteproc/remoteproc.c:999
rptun_worker
nuttx/drivers/rptun/rptun.c:333
rptun_thread
nuttx/drivers/rptun/rptun.c:364 (discriminator 1)
nxtask_start
nuttx/sched/task/task_start.c:144
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
Masayuki Ishikawa
dc454765fb
Revert "add holder for mutex"
...
This reverts commit fc176addeb
.
2023-01-19 06:04:48 +09:00
lilei19
fc176addeb
add holder for mutex
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-18 17:40:58 +08:00
Xiang Xiao
a851ad84c3
net: consistent the net sem wait naming conversion
...
to prepare the new mutex wait function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-15 12:31:30 -03:00
梁超众
aca1a065a8
move usrsock to kernel space
...
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-11 15:14:03 +08:00
Xiang Xiao
c38d6f1ae4
net: Remove usrsock specific process from common code as much as possible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-28 16:32:41 +09:00
dongjiuzhu1
d5b08a7ef1
net/usrsock: fix get/setsockopt issue about usrsock protocol
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 21:27:15 +09:00
dongjiuzhu1
e6f8ccda4a
net/get/setsockopt: add si_get/setsockopt interface to simply get/setsockopt
...
move private option to protocol sockif
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08:00
Xiang Xiao
b170e4cc9f
net/usrsock: Split NET_USRSOCK_OTHER to NET_USRSOCK_ICMP[v6]
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
Xiang Xiao
8bbb477316
net/usrsock: Should select NET_[UDP|TCP]_NO_STACK instead NET_[UDP|TCP]
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
Xiang Xiao
c2f566afcb
net/usrsock: Remove NET_USRSOCK_NO_INET[6]
...
let the remote peer do all final decision
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
zhanghongyu
ae46cd4fa1
usrsock: add REMOTE_CLOSED event handler to connect
...
when usrsock client try to connect usrsock server local_loop
socket with an invalid port, server cannot find a listener conn
to handle this connet request, then it will response a TCP_RESET
packet via nuttx existing processing, when before conn recv this
RESET packet, it will trigger usrsock_rpmsg_server poll return
and send REMOTE_CLOSE event to usrsock client.
so usrsock connect_event fucntion need handle this event.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-22 15:18:15 +09:00
anjiahao
e1ca516488
use SEM_INITIALIZER inside of NXSEM_INITIALIZER
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao
5724c6b2e4
sem:remove sem default protocl
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-10-22 14:50:48 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
zhanghongyu
403c657f42
usrsock: combine response and events when socket setup case
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-14 12:29:21 +09:00
liangchaozhong
c75253623d
usrsock:fix blocking socket connect operation hang issue
...
Issue description:
usrsock will wait for state.recvsem forever because no event triggers
state.recvsem post operation when connect operation in server side is
non-blocking.
Solution:
trigger state.recvsem post operation after receive USRSOCK_EVENT_SENDTO_READY.
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-10-14 12:29:21 +09:00
zhanghongyu
be06d00f85
usrsock: update state to connected when recv sento ready under connecting
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-14 12:29:21 +09:00
liangchaozhong
cc426f8539
usrsock:add done flag in usrsock_iovec_do
...
set done to true if all data in iovec array is copied
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-10-11 00:57:49 +08:00
Xiang Xiao
40ef5bc6db
libc: Move queue.h from include to include/nuttx
...
to avoid the conflict with libuv's queue.h
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-26 08:04:58 +02:00
wangbowen6
344c8be049
poll: add poll_notify() api and call it in all drivers
...
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-09-26 12:06:32 +08:00
Xiang Xiao
b400b99001
net/usrsock: Simplify the return value process of net_timedwait
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
77823415ed
net/usrsock: Remove the unnecessary blank line
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
3269c1a102
net/usrsock: Remove the unnecessary label
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
Xiang Xiao
3d0985df39
net/usrsock: Remove the unnecessary extra space
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-11 10:08:04 +09:00
liangchaozhong
5ec4296553
move usrsock_dev.c to driver folder
...
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-09-10 13:08:22 +08:00
liangchaozhong
644c4afeed
usrsock:refine usrsock's architecture
...
Seperate usrsock device driver with usrsock core function layer
to make it more flexiable to adopt other kind of usrsock interface driver
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-09-09 20:56:12 +09: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
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