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>
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>
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>
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>
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>
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>
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>
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>