use netdev_list_lock to protect all network card traversal, registration,
and deregistration operations.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
the maximum retransmission interval allowed for car projects
cannot exceed 6 seconds, and allows for fixed retransmission intervals.
according to the previous algorithm, the retransmission interval
may be 0.5 * 2 ^ 4 = 8 seconds, which does not meet the requirements.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
CLOSE-WAIT - represents waiting for a connection termination request
from the local user.
TCP A TCP B
1. ESTABLISHED ESTABLISHED
2. (Close)
FIN-WAIT-1 --> <SEQ=100><ACK=300><CTL=FIN,ACK> --> CLOSE-WAIT
3. FIN-WAIT-2 <-- <SEQ=300><ACK=101><CTL=ACK> <-- CLOSE-WAIT
4. (Close)
TIME-WAIT <-- <SEQ=300><ACK=101><CTL=FIN,ACK> <-- LAST-ACK
5. TIME-WAIT --> <SEQ=101><ACK=301><CTL=ACK> --> CLOSED
6. (2 MSL)
CLOSED
in the current state, we can continue to send data until the user
calls shutdown or close, then directly enter the TCP_LAST_ACK state
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
According to RFC768 page 2, length feild is the length in octets of this user datagram including this header and the data.
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
According to RFC768 page2 and referring to the Linux implementation, the message with udp length of 0 is supported.
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
This interface needs to be called in the libc library, but the interface is implemented in the kernel, so this interface needs to be exposed
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
To avoid memory waste, can add support for using an independent iob buffer
The IP protocol often configures CONFIG_IOB_BUFSIZE to be relatively large,
such as 512, for higher throughput. However, the buffer required by CAN is
fixed at a length of 16 or 64. If the system's IOB is directly used,
a lot of memory will be wasted.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
there is no need to call arp_out again to perform layer 2 header filling
in the arp_send process, so we should directly call the driver's callback.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
otherwise, if the mld timers are not cancelled, an illegal address will
be accessed after timeout. to avoid this scenario, when the network card
is unregistered, all MLD timers must be attempted to be synchronously
cancelled.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
insufficient IOB during IP fragment is a normal scenario and should
not crash directly. The assert needs to be removed and corresponding
error handling needs to be added.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
When SOL_SOCKET options (e.g., SO_BINDTODEVICE via ping -I) hit ICMP sockets, icmp_{get,set}sockopt logged “Unrecognized ICMP option: 17” before fallback. Handle SOL_SOCKET explicitly by returning -ENOPROTOOPT so psock_* routes to the socket-level handler. Removes noisy logs without changing behavior (invalid devices still return -ENODEV).
Signed-off-by: wangchen <wangchen41@xiaomi.com>
when dev is down, tcp_pollsetup returns the value 'OK' and sets the connection status to 'down' and eventset to POLLERR & POLLUP
Signed-off-by: wangchen <wangchen41@xiaomi.com>
Some third-party network libraries use PACKET_ADD_MEMBERSHIP to add MAC
addresses to devices, and this patch can add support for this.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Setting group->flags to IGMP_SCHEDMSG is a possible outcome, not unacceptable. If it occurs, an error log message will be reported
Signed-off-by: wangchen <wangchen41@xiaomi.com>
After first connection refused happend,The user use the same connection failed,becasue the tcpstateflags is not TCP_ALLOCATED
Signed-off-by: wangchen <wangchen41@xiaomi.com>
According to the definitions of PF_PACKET and SOCK_DGRAM,
extend the current protocol stack pkt protocol to support SOCK_DGRAM mode.
Some third-party network libraries use AF_PACKET, SOCK_DGRAM type sockets
to construct packets and send/receive data, This patch can add support
for this.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
on some device, the wifi driver uses dev->d_len as the length of the sent packet. However, due to the lack of update in d_len, the sent packet is not considered a normal packet and is not processed by the other end
Signed-off-by: wangchen <wangchen41@xiaomi.com>
When triggering TCP retransmission through a timer, conn->unacked_q will save more packets, which may result in sndseq being equal to ackseq. Previous implementations may cause conn->nrtx to not be cleared, leading to an increase in conn->rto errors and a longer timer time
Signed-off-by: wangchen <wangchen41@xiaomi.com>
The modification is to solve the problem that the opposite end cannot receive the retransmission message, and the protocol stack no longer sends retransmission messages
Signed-off-by: wangchen <wangchen41@xiaomi.com>
since the current txnotify is executed synchronously at the location of
the current call without switching threads, resources such as d_iob need
to be cached first.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
TCP_CORK and TCP_NODELAY behave almost exactly the opposite,
so first provide simple support for TCP_CORK.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
When using usrsock to pass the network interface name, omitting "\0" will cause the host to parse extra characters. therefore, the tail section should be inspected during device binding.
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
If there is data in readahead, it needs to be released; otherwise,
it will cause the leakage of IOB resources
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Ref: https://man7.org/linux/man-pages/man7/packet.7.html
1. For `socket(AF_PACKET, int socket_type, int protocol)`: When `protocol` is set to `htons(ETH_P_ALL)`, then all protocols are received. If `protocol` is set to zero, no packets are received.
2. For `bind`: `bind` can optionally be called with a nonzero `sll_protocol` to start receiving packets for the protocols specified.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
When app send a pkt-packet, then it will read back it and case some problem. Connection should not read back the message sent by itself.
Signed-off-by: gaohedong <gaohedong@xiaomi.com>
Inspired by Linux's way, we also create VLAN devices for managing VLAN,
which will become interfaces like `eth0.58`.
QinQ is also supported, we can create VLAN devices above another VLAN
devices, like `eth0.100.101` (or even `eth0.1.2.3.4`, also supported on
Linux).
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>