Resolve some timing issues caused by calling net_breaklock to release netlock in the function NET_BUFPOOL_TRYALLOC
Signed-off-by: wangchen <wangchen41@xiaomi.com>
If the NET_TCPBACKLOG configuration is not enabled, no I/O event will be
triggered for the socket file descriptor in poll/epoll. As a result, the
connection will not be accepted, leading to a failure in the TCP handshake.
The problem is that users may not have noticed this configuration,
no event will be received when polling the socket fd.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The TCP keep-alive implementation would send the probes and abort the
connection correctly, but without waking up the affected socket and
marking the connection as aborted. This patch from zhhyu7 in #16447
resolves the issue.
Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
for tcp_listener(). fixed potential conflict between implicit
binding and port conflict detection.
Implicit binding automatically allocates an interface address during
connection,but port conflict detection occurs before binding/connecting.
This can cause issues when creating multiple TCP connections in succession.
If the first connection uses a random port via implicit binding, subsequent
connections might reuse the same port under current filtering rules,
leading to connect() failures.
Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
In a recent patch the socketcan timestamp generation was moved
to add it also when there is an active reader (previously the timestamp
was only added before storing the CAN frame in the read-ahead list).
It was working fine but I realized that the can_callback function is
also called when sending frames. In this case, the IO block is not allocated
yet and the code breaks.
This PR is to only generate the timestamp if the IO block is not NULL
(reading path) and skip it when it is NULL (sending path)
Signed-off-by: Javier Casas <javiercasas@geotab.com>
When a udp frame is processed without a listener a icmp frame is
returned indicating that there is no listener. The PR enables
sending this icmpv6 response over sixlowpan.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Fix timestamp in socket CAN. Right now the timestamp is only generated
if there is no reader and the frame is stored in the read ahead list.
This is solved by moving the timestamp generation before the code flow
branch.
Signed-off-by: Javier Casas <javiercasas@geotab.com>
Update the handling of tcp packets over sixlowpan. `tcp_ipv6_input()`
can update the dev->d_iob. Assigning ipv6 to IPv6BUF makes sure that
the correct buffer is used.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
can_datahandler returns an unsigned value that represent the
number of bytes actually bufffered, but the call to iob_tryadd_queue
returns a negative value when it fails so that value can't be used as
can_datahandler return value because it is interpreted as unsigned so
a big number is wrongly returned when iob_tryadd_queue fails.
The fix is just setting the return value to zero when iob_tryadd_queue
fails, reflecting the actual meaning that no bytes have been buffered.
Add support for network statistics for CAN.
It includes counters for receive, sent
and drop frames.
Signed-off-by: Javier Casas <javiercasas@geotab.com>
when accept conn timeout, only accept conn itself should handle the event
(send TCP_RESET), 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>
This commit cleans up redundant header file includes throughout the codebase.
The changes include:
- Removing duplicate #include directives that were present in the same file
- Consolidating includes that were split across multiple lines unnecessarily
- Removing unused includes that were no longer needed
- Fixing some formatting issues with includes
The changes improve code organization and maintainability by:
- Reducing unnecessary dependencies
- Making include dependencies more explicit
- Following consistent include patterns
- Removing dead code
No functional changes are made - this is purely a code cleanup commit.
Signed-off-by: Huang Qi <huangqi3@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>