Notes:
1. This commit do the same thing as TCP did: https://github.com/apache/nuttx/pull/10627
2. UDP uses `iob_navail(false)` but TCP uses `iob_navail(true)`, this is because of a problem related to TCP recv window (https://github.com/apache/nuttx/pull/4142), so we don't need to change UDP now.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
when accept conn receives TCP_RESET, only accept conn itself should handle
the event, and there is no need to notify the listening conn. otherwise,
the server's poll will return with POLLERR and POLLHUP. this may cause
some applications to execute incorrect logic in the future.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
the same variable type in linux is char, in order to avoid modifying
the third-party library code when porting the third-party library code.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Our net socket connection allocations are powerful but redundant
because they're implemented once in each protocol. This is not good for
further optimizing and extending to other allocations, so maybe we can
add a common implementation for the usage.
Impact:
1. We add a `struct net_bufpool_s` as pool descriptor, which may use a
little bit more memory than previous implementation (~28Bytes).
2. We share same functions between pools, so code size may shrink under
some scenarios.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
In libuv, if the real_timeout in the uv__io_poll is less than 0, the poll logic will be entered directly by the uv__run_timers, which will trigger the ASSERT.
It seems that the situation of first epoll and then poll for the same fd is used in libuv.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
when tcp retransmission only double conn->timer in Karn(tcp_timer.c L602), after retransmission in Jacobson
M is is now rtt test will become a negative value.
```
signed char m;
m = conn->rto - conn->timer; // M is now rtt test
/* This is taken directly from VJs original code in his paper */
m = m - (conn->sa >> 3);
conn->sa += m; //conn->sa is a negative value
if (m < 0)
{
m = -m;
}
m = m - (conn->sv >> 2);
conn->sv += m;
conn->rto = (conn->sa >> 3) + conn->sv; //rto
```
For example,we lost one ack packet, we will set conn->timer = 6 by backoff,conn->rto still 3.
After retransmission we will Do RTT estimation, then will get
```
conn->sa = 253
conn->rto = 46
```
Then if any packets lost it will wait for a long time before triggering a retransmission.
Test method.
We can reproduce this issue by adding drop ACK packets in tcp_input, and debug conn->rto after Jacobson.
Signed-off-by: meijian <meijian@xiaomi.com>
Now the HAVE_PFINET(6)_SOCKETS depends on NET_TCP/UDP_HAVE_STACK, which
is previously defined in net/ folder and cannot be included.
Considering many places use this check, maybe moving them to netconfig.h
could be better.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
assert: tcp conn and didn't recv ack, tcp_free will assert in L909
and no need to tcp free because tcp close will free by lpwork.
Signed-off-by: meijian <meijian@xiaomi.com>
Problem Description:
Problem occurrence when Thread1 creat connect/recv socket and Thread2 cancel Thread1.
1. Thread2 cancel when Thread1 connect event, will cause DEBUGASSERT in devif_callback_free.Because cb in g_cbfreelist.
2. Thread2 cancel when Thread1 recvfrom sem-wait, when the FIN packet input and will trigger tcp_recvhandler and will crash.Becuase some thread stack data was freed.
Signed-off-by: meijian <meijian@xiaomi.com>
The current receive data needs to be handled by following
tcp_recvhandler or tcp_data_event. Notify driver to send the
message and marked as rexmit
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Fixes psock_socket: ERROR: socket address family unsupported: 2
When using the minimal CONFIG_NET configuration typically used for
SocketCAN
Update net/inet/inet.h
Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
Update net/inet/inet.h
Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
This patch fixed userspace headers conflict. Architecture-related definition and API should not be exposed to users.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
we will drop packet when tcp_close_eventhandler
is register and invoke by tcp_input. then we will always early return and
never stop, the peer will only close the connection if we send reset packet.
precondition:
close -> register tcp_close_eventhandler;
tcp_input -> tcp_callback(TCP_NEWDATA) -> devif_conn_event -> tcp_close_eventhandler
-> flags &= ~TCP_NEWDATA -> NOT entry tcp_data_event -> conn->recvreq NOT increase
old flow:
tcp_input -> tcp->seqno greater than conn->rcvseq -> tcp_send(TCP_ACK)
with this patch:
tcp_input -> tcp->seqno greater than conn->rcvseq -> !TCP_ESTABLISHED
-> case TCP_FIN_WAIT_1 -> dev->d_len greater than 0 -> tcp_reset
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
supports the usrsock client to subscribe netlink events,
so that it can detect events such as link connection changes.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
now the lc_path of the client will not be the same as that of the server.
therefore, accept->peer = NULL will not be set when the client release
the conn, then when release accept conn, set
client->peer(accept->peer->peer) = NULL will cause used after free
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This has been broken at some point. Just fix it by copying the can frame and
the cmsg data into IOB, and fix devif_poll to copy out the full data.
The can drivers expect to find the timeout timestamp in the end of the frame.
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
reason:
We can utilize percpu storage to hold information about the
current running task. If we intend to implement this feature, we would
need to define two macros that help us manage this percpu information
effectively.
up_this_task: This macro is designed to read the contents of the percpu
register to retrieve information about the current
running task.This allows us to quickly access
task-specific data without having to disable interrupts,
access global variables and obtain the current cpu index.
up_update_task: This macro is responsible for updating the contents of
the percpu register.It is typically called during
initialization or when a context switch occurs to ensure
that the percpu register reflects the information of the
newly running task.
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
-machine virt,virtualization=on,gic-version=3 \
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx
Signed-off-by: hujun5 <hujun5@xiaomi.com>
According to RFC793, Section 3.4, Page 33. In the SYN_SENT state, if receive a ACK without the SYN, we should reset the connection and retransmit the SYN.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
1.Simplify the message process in rpmsg_socket_send_single
2.Add more lock protection in rpmsg socket
3.Fix the style issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Referring to Linux,if there is only a loopback network device and the destination address does not belong to the loopback address, then the loopback network devices is not selected
Signed-off-by: wangchen <wangchen41@xiaomi.com>