Commit Graph

2641 Commits

Author SHA1 Message Date
Zhe Weng 6222ad5764 Revert "net: downgrade iob priority of input/udp/icmp to avoid blocking devif"
This reverts commit d87620abc9.
2023-01-12 01:56:18 +08:00
zhanghongyu 48c9d10336 net_socket: add accept4 function
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
chao an 47d628d22e net/mld: fix build break of mld router
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-11 22:58:21 +08:00
梁超众 aca1a065a8 move usrsock to kernel space
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-11 15:14:03 +08:00
chengkai f864e5f657 wireless/bluetooth: add interrupt_context hander for netsnoop
Signed-off-by: chengkai <chengkai@xiaomi.com>
2023-01-10 18:08:22 +08:00
chao an 35c1e53b1a net/netdev: clear device buffer handle by default
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-06 16:33:13 +08:00
chao an ffd81e63be net/tcp: reprepare response buffer from unthrottle pool
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-06 16:33:13 +08:00
chao an 3af47d1913 net/tcp: remove unnecessary clear for device buffer
which has been cleared in tcp_datahandler()

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-06 16:33:13 +08:00
Zhe Weng d87620abc9 net: downgrade iob priority of input/udp/icmp to avoid blocking devif
When trying to use iperf2, we found it comsumes all the IOB when sending UDP packets, then devif_poll has no IOB to send the packet out, so speed drops to 0 and never recovers.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-05 22:25:19 +08:00
dongjiuzhu1 31134719e7 net/local: rename NET_LOCAL_VFS_PATH to follow linux
And skip same prefix for unix path

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-01-04 20:50:38 +08:00
chao an 1510dbee68 net/tcp: Do not trigger retransmission if the new data has not been consumed.
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-03 16:28:30 +08:00
zhanghongyu 43cc4bd7bf net_local: fix error when work with epoll
epoll_wait collects revent by checking fds->revent,
but local_socket will copy fds to the other two private pollfd shandow struct,
then the pipe_poll will not be able to update fds->revent directly,
so need local_socket save fds and implement a private poll_notify function
to passing revent to original fds->revent.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-12-31 02:23:50 +08:00
Zhe Weng 34ade7a0b6 net/devif: fix devif_poll loop logic
Previously, the devif_poll works in this flow:
devif_poll_xx -> bstop = callback -> continue if !bstop -> poll another

Now we split the polling and callback, so it should work like:
devif_poll_connections -> return true if callback need to be called
   -> bstop = callback -> loop if !bstop -> poll again

Conditions:
poll_connections == 0, d_len == 0, break, return 0
poll_connections == 1, d_len == 0, break, return 1 (other stop case,
                                                    don't callback)
poll_connections == 1, d_len > 0, callback == 1, break, return 1
poll_connections == 1, d_len > 0, callback == 0, loop

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-30 21:25:59 +08:00
Zhe Weng cbe4cb2056 net: Add set/getsockopt options compatible with iptables.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-28 22:40:53 +08:00
zhanghongyu 5d3f47c37b net: Separate IP_PKTINFO from NET_IGMP
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-12-28 00:05:57 +08:00
Zhe Weng 7f9cf184e5 net/devif_loopback: Add robustness to avoid infinite loop
When ipv4_input/ipv6_input called by devif_loopback writes wrong data into buffer (another bug we're fixing), the else block does nothing but only record the 'dropped' statistic, then infinite loop happens.

Refers to previous lo device with dropping logic:
https://github.com/apache/nuttx/blob/releases/11.0/drivers/net/loopback.c#L178-L180

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 16:20:17 +08:00
Zhe Weng cb958e5d69 net/nat: Clear entries when NAT will be disabled
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 12:05:20 +08:00
Zhe Weng 902a6dcad2 net/nat: Support isolation between multiple WAN devices by saving external ip
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 12:05:20 +08:00
Zhe Weng 0ceee72239 net/nat: modify chksum_adjust and MANIP_IPADDR macro for better readability
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 12:05:20 +08:00
Zhe Weng 7bd2195fde net/nat: Fix misused d_draddr in select_port
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-23 19:40:19 +08:00
Zhe Weng a9da1fff28 net/nat: Add auto reclaim logic for NAT entries.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-22 20:20:12 +08:00
Zhe Weng 879c337e30 net/nat: Use hashtable to optimize performance
Performance tested on simulator:

Before optimization:      -25% bandwidth @2k entries, -64% @10k entries
hashtable size=  2(1bit): -24% bandwidth @2k entries, -65% @10k entries
hashtable size=  4(2bits):-15% bandwidth @2k entries, -51% @10k entries
hashtable size= 32(5bits): -3% bandwidth @2k entries, -14% @10k entries
hashtable size=256(8bits): -1% bandwidth @2k entries,  -3% @10k entries

Note: Tested on worst performance, the earliest entry will be the worst.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-22 20:20:12 +08:00
Xiang Xiao fd0d6a9bf5 compiler.h: Add _ between format|printf|syslog|scanf|strftime and like
align with other macro naming style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-21 01:05:19 +02:00
Xiang Xiao 4d2794250f net/local: Support the abstract path
https://man7.org/linux/man-pages/man7/unix.7.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
Xiang Xiao 6b36ba0b6e net/local: Remove LOCAL_TYPE_UNTYPED
let's represent the unbound local socket as LOCAL_TYPE_UNNAMED

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
Xiang Xiao aea8f8175a net/local: Return -EINVAL if the address length passed to local_bind is too small
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-18 20:12:30 +02:00
chao an 6f15b32e34 net/tcp: rename NET_TCP_RECV_CONTIG to NET_TCP_RECV_PACK
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-19 01:32:05 +08:00
chao an 794adc5814 net/tcp: contig received data to reducing iob consumption
Fragmentation of network data will intensify iob consumption, if
the device receives a message storm of fragmented packets, the iob
cache will not be effectively used, this is not allowed on iot devices
since the resources of such devices are limited. Of course, this
also takes some disadvantages: data needs to be copied.
This option will brings some balance on resource-constrained devices,
enable this config to reduce the consumption of iob, the received iob
buffers will be merged into the contiguous iob chain.

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-18 21:15:47 +08:00
Xiang Xiao d5689e070b net/arp: Remove nuttx/net/arp.h
1.move ARPHRD_ETHER to netinet/arp.h
1.move arp_entry_s to net/arp/arp.h
2.move arp_input to nuttx/net/netdev.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-16 22:10:59 +02:00
chao an 01eb4d586b mm/iob: iob members are initialized after allocate
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-16 09:51:53 +08:00
chao an 3a50911810 net/udp: correct udp send timeout
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-16 09:51:15 +08:00
chao an 5492e961bc net/devif: replace redundant code to iob_clone_partial()
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-14 21:37:20 +08:00
wangjunfeng0 b2b014df0b Remove redundant length checking
Signed-off-by: wangjunfeng0 <wangjunfeng3@xiaomi.com>
2022-12-14 21:20:14 +08:00
zhanghongyu c74cb1aaa5 net/arp: change arptable struct from arp_entry_s to arpreq
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-12-14 21:17:08 +08:00
zhanghongyu 1a81a936df arp: add device check for arp interface
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-12-14 21:17:08 +08:00
Zhe Weng 2f3e237380 net/ipfwd: limit number of ipforward struct to be less than number of IOB
If ipforward consumes all the IOB, devif_poll will not poll any more. Without polling, ipforward will not release any IOB, then all the network stack may fail with no IOB available.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-09 11:20:16 +08:00
tangyusong1 f454dfccb2 Adjust ioctl function of cellular
Add SIOCGCELLNETDEV
Give a uint8_t[136] for cellular to save data

Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
2022-12-09 11:19:55 +08:00
tangyusong1 1c7a9d282c Add mtu set and interface name set in ioctl
Follow LinuxOS:linux-5.10.152\include\uapi\linux\sockios.h
Add SIOCSIFMTU and SIOCSIFNAME

Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
2022-12-08 13:58:26 +01:00
chao an 11de08de27 net/devif_send: replace all block send to nonblock mode
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 09:53:15 +01:00
chao an 6950b67b46 net/can: device buffer must be clear after enqueue to readahead
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 03:16:42 +08:00
chao an fc1b71b9a6 net/can: add support of iob input
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 03:16:42 +08:00
chao an d295b4e1f1 net/devif: Use the device ll header length to calculate send limit
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 03:16:42 +08:00
chao an 960b4bb2a7 net/devif: initialize d_len to 0 before polling connections
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-08 03:16:42 +08:00
chao an c738da048c net/ipforward: update IP buffer offset
Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-07 00:01:52 +08:00
Zhe Weng 6e9053265c net/ipfwd: fix `ipv4_dev_forward` after IOB offload.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-06 17:03:47 +08:00
Zhe Weng 2a780e0467 net/ipfwd: fix `devif_forward` after IOB offload.
Problem:
- `iob_copyout` to `d_buf` doesn't set `io_len` of the IOB, so `devif_poll` failed to copy the data into `buf` by `iob_copyout`

Modification:
- Just Move the IOB in `devif_forward`.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-06 17:03:47 +08:00
chao an e002edf87c net/devif: reprepare iob buffer before polling connections
Loopback device will consume the d_iob packet in upper layer protocol,
in order to avoid null pointer access, reprepare iob buffer before polling connections

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-05 17:32:07 +08:00
chao an 8fc1e524ab net/ip: return success if the packet was forwarded.
The incoming packet should not be input to ip layer if the packet has been forwarded

Signed-off-by: chao an <anchao@xiaomi.com>
2022-12-04 15:59:43 -03:00
Xiang Xiao 43bda3282f net/arp: Move arp_ipin and arp_out to private header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-04 20:39:21 +08:00
Xiang Xiao c6e9edcbb6 net: Rename arp_arpin to arp_input
align with other similar function(e.g. ipv4_input and ipv6_input)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-04 20:39:21 +08:00