Commit Graph

2557 Commits

Author SHA1 Message Date
wangbowen6
c37d90c194 net/local: support FIONWRITE for domain socket ioctl
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-11-24 19:47:08 +08:00
liangchaozhong
0ec4b0a149 tcp: recv returns 0 without set errno
Issue:
recv return 0  means peer side has already closed the connection according to
man page's description.
0 is returned without set errno when TCP rx timeout happens with current
design.

Solution:
return result instead of ir_result when ir_result is 0, then -1 will be
returned with errno set to EAGAIN for tcp rx buffer empty case.

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2022-11-23 23:23:44 +08: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
ccf0c3566e net/local: support cmd SO_PEERCRED
the credentials of the peer process connected to this socket.
refs:https://man7.org/linux/man-pages/man7/unix.7.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08: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
c66ba22812 Fix Error: netdev/netdev_findbyindex.c:59:7: error: variable 'i' set but not used
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-23 07:27:48 +01: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
0d516c7ff6 net/tcp: Remove the dependence on SCHED_WORKQUEUE
since it isn't required in case of NET_TCP_NO_STACK

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-22 20:45:26 +09:00
Xiang Xiao
7f380533a3 net/udp: NET_BROADCAST shouldn't configurable if NET_UDP_NO_STACK enable
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
chao an
ae4b5b5f50 net/tcp: TCP_WAITALL should use state flag
The feature of MSG_WAITALL is broken since the wrong flag is used

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-21 17:21:10 +08:00
chao an
ce1c945136 net/arp: Make NET_ARP(Address Resolution Protocol) configurable
Some boards that use USRSOCK will not need this feature

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-21 13:20:55 +08:00
chao an
873023f89b net/icmp[v6]: destroy nxsem properly
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-21 01:15:48 +08:00
Xiang Xiao
19138560f4 Fix error: variable 'buflen' is uninitialized when used here
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-20 14:34:44 +01:00
chao an
6898409d04 net/icmp[v6]: ICMP[v6]_NO_STACK should not depends on NET_IPv4/6
Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-20 08:16:20 -03:00
qinwei1
8021dfece6 sched/task/task_getpid: getpid should return process id not thread id
Summary:
   implement the right semantics:
1. getpid should return the main thread id
2. gettid should return the current thread id

Refer to:
 https://github.com/apache/incubator-nuttx/issues/2499
 https://github.com/apache/incubator-nuttx/pull/2518

Signed-off-by: qinwei1 <qinwei1@xiaomi.com>
2022-11-17 17:58:08 +08:00
anjiahao
d07792a343 Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-14 09:34:04 +09:00
Alan Carvalho de Assis
8286a558c8 net/tcp: Avoid starting TCP sequence number 0 2022-11-13 09:09:36 +08:00
zhanghongyu
ab15887a0b tcp: find bound device when laddr is ANY
icmp: find bound device when s_boundto is not zero

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-12 18:36:09 +08:00
ligd
03ff9d1a94 rpmsg socket: add lock to poll & poll_notify
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-11 20:08:17 +08:00
Zhe Weng
a3a669a5f6 net/nat: Add UDP support
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
8d401db5b9 net/nat: Add ICMP ECHO (REQUEST & REPLY) support
Support ICMP ECHO REQUEST & REPLY. Id of ICMP is processed like port of TCP in NAT. However, our ICMP stack doesn't have a method to manage id allocation like tcp_selectport(), the id is set by apps (like icmp_ping.c) without conflict avoidance, so not adding such conflict avoidance logic to ICMP stack when implementing NAT.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
f498102512 net: select NAT external port by tcp_selectport for TCP
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
8239ddeef4 net/nat: Add TCP entry expiration logic
Add TCP entry expiration logic for NAT, with entries changed from sq to dq for fast removal.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
0a4e01d712 net: verify NAT port usage in tcp_selectport
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
b595430578 net: add basic NAT workflow
Add basic functions for NAT (NAPT), remaining some logic unimplemented (UDP, ICMP, port assignment, etc). NAT for TCP can work now (unless port conflicts).
Outbound: LAN ->  Forward  ->  NAT(only if targeting at WAN)  -> WAN
Inbound:  WAN ->  NAT(only from WAN, change dest) -> Forward  -> LAN

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Xiang Xiao
a446b5816f mm/circbuf: Remove MM_CIRCBUF option from Kconfig
since the linker can remove the unused object file from the final image

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-08 10:18:27 -03:00
Xiang Xiao
a7e99346a1 net/tcp: Make TCP_MAXRTX and TCP_MAXSYNRTX configurable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-07 10:05:57 +01:00
yinshengkai
85f727f232 tools: replace INCDIR to Makefile variable
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables

In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-11-03 19:59:55 +08:00
Zhe Weng
66bc2ffbe6 net/utils: add net_chksum_adjust defined by RFC3022
net_chksum_adjust is used for fast checksum adjustment after modifying some fields in a network packet. Will be used in NAT.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-02 21:25:01 +01:00
Xiang Xiao
3b060bad34 Fix error: format specifies type 'unsigned short' but the argument has type 'int'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-01 17:12:42 +01:00
chao an
b353d84742 net/tcp: fix build break if enable NET_TCP_NO_STACK
devif/ipv6_input.c: In function 'ipv6_input':
devif/ipv6_input.c:59:33: error: 'TCPIPv6BUF' undeclared (first use in this function); did you mean 'IPv6BUF'?
   59 | #define PAYLOAD ((FAR uint8_t *)TCPIPv6BUF)
      |                                 ^~~~~~~~~~
devif/ipv6_input.c:302:14: note: in expansion of macro 'PAYLOAD'
  302 |   payload  = PAYLOAD;     /* Assume payload starts right after IPv6 header */
      |

Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-31 15:31:31 +08:00
Xiang Xiao
4051fcd42b include/endian.h: Fix format specifies type 'unsigned long' but the argument has type 'unsigned int'
Error: route/net_del_ramroute.c:94:9: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
        HTONL(match->target), HTONL(match->netmask));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/github/workspace/sources/nuttx/include/debug.h:232:23: note: expanded from macro 'ninfo'
                      ^
/github/workspace/sources/nuttx/include/debug.h:102:43: note: expanded from macro '_none'
    do { if (0) syslog(LOG_ERR, format, ##__VA_ARGS__); } while (0)
                                ~~~~~~    ^~~~~~~~~~~
/github/workspace/sources/nuttx/include/netinet/in.h:233:17: note: expanded from macro 'HTONL'
                ^
/github/workspace/sources/nuttx/include/endian.h:63:25: note: expanded from macro '__swap_uint32'
                        ^
Error: route/net_del_ramroute.c:94:31: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
        HTONL(match->target), HTONL(match->netmask));
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/github/workspace/sources/nuttx/include/debug.h:232:23: note: expanded from macro 'ninfo'
                      ^
/github/workspace/sources/nuttx/include/debug.h:102:43: note: expanded from macro '_none'
    do { if (0) syslog(LOG_ERR, format, ##__VA_ARGS__); } while (0)
                                ~~~~~~    ^~~~~~~~~~~
/github/workspace/sources/nuttx/include/netinet/in.h:233:17: note: expanded from macro 'HTONL'
                ^
/github/workspace/sources/nuttx/include/endian.h:63:25: note: expanded from macro '__swap_uint32'

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-30 16:03:35 +01:00
zhanghongyu
f00c11aec4 socket: separation error code EBADF and ENOTSOCK
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-29 08:18:02 +02:00
Xiang Xiao
1047b65ab5 net: Remove the unused nx_[send|recv]msg
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-28 08:27:29 +02:00
chao an
a8d3286258 net: move device buffer define to common header
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-28 00:32:16 -04:00
Xiang Xiao
05d40eeeff net: Remove the unused nx_recv[from] to prefer psock_recv[from] for kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
Xiang Xiao
3e982b6556 net: Remove the unused nx_send to prefer psock_send for kernel
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
chao an
b60b48411c net/ipforward: correct application data offset
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-26 14:33:56 +02: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
raiden00pl
2b0ce033d7 net/can/can_xxxsockopt.c: correct the code alignment 2022-10-21 16:24:13 -03:00
zhanghongyu
2a6a869962 tcp: Update conn laddr after select device
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 18:47:13 +08:00
zhanghongyu
ae3e1d8ec5 setsockopt: Change return errno to EFAULT when value is NULL
behavior alignment to Linux for some testsuite

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
dc577b66e4 psock_socket: Add type field check
behavior alignment to Linux
Return EINVAL when type field include nonsupport bit

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
2be529121a socketpair: Add SOCK_NONBLOCK support into type field
behavior alignment to Linux

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
85ffa4bcf3 inet_sockif: errno alignment to Linux
cunittest error case: protocol invalid need return 123(EPROTONOSUPPORT)
now return 106(EAFNOSUPPORT)

inet_setup will check type ande protocol

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
6b955b0ef0 inet_bind: errno alignment to Linux
cunittest error case: addr length is short.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00