364 Commits

Author SHA1 Message Date
shichunma
3fb776e45c net/netdev: a valid netdev for ipv4 should have ipv4 addr configured
It's not a valid netdev if without ipv4 address.

Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
2026-02-02 13:57:56 +08:00
zhanghongyu
d5d6b65213 Revert "net: limit TCP and UDP send/recv buffer usage with throttled IOB"
This reverts commit fa652f9c24.

When testing iperf on boards such as ESP32-C6, ESP32-C3, and ESP32,
blocking issues are encountered, so the patch is reverted.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-23 14:40:06 -03:00
zhanghongyu
fa652f9c24 net: limit TCP and UDP send/recv buffer usage with throttled IOB
The main content of this submission is to limit both the TX/RX buffers
of TCP/UDP to throttled IOBs, avoiding impacts on the sending and
receiving of control-type messages.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-21 20:06:47 +08:00
daichuan
b01f8b04e9 netdev: delete macro CONFIG_NETDEV_CHECKSUM with nuttx
not need CONFIG_NETDEV_CHECKSUM with nuttx

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-19 23:22:46 +08:00
daichuan
99bf7c3c5f net: skip TCP/UDP pseudo-header checksum with hardware offload
When supporting hardware checksum offloading, the network protocol stack
does not perform TCP/UDP pseudo-header checksum calculation.

Skip TCP/UDP pseudo header checksum calculation in network protocol stack

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-19 23:22:46 +08:00
daichuan
42da4e322a net/netdev: fix compile error and add cmake/makefile
Fix compilation errors and add build files

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-19 23:22:46 +08:00
daichuan
d2dde8a29a net/netdev: modify for hardware checksum offload
Implementation of main hardware verification and uninstallation functions

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-19 23:22:46 +08:00
zhanghongyu
4ce3dac146 net: move the tool interface functions to the public directory
expose the query interface of the network card to the network card
driver so that the network card driver can support more features.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-16 09:42:01 +08:00
zhanghongyu
5ce2955e62 net/netdev: correct the ioctl command validation logic
This patch fixes the validation order in netdev ioctl handlers for
Bluetooth, IEEE 802.15.4, and packet radio devices. The command type
should be validated before checking the argument pointer to return
the correct error code (-ENOTTY vs -EINVAL).

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 19:59:40 +08:00
wangchen
96fcc8bb1d net:modify check condition from IFF_UP to IFF_RUNNING in the sending process
Modify check condition from IFF_UP  to IFF_RUNNING in the sending process

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2026-01-09 21:48:18 +08:00
Jiri Vlasak
7fa4a7f3b4 net/netdev: Fix best prefix in findby
When comparing with netmask, the best prefix len is netmask.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-01-08 22:45:16 +08:00
wangchen
c2774ba1ec netdev:When running, proto stack can exchange packets with device
netdev:when network device is running status,the network protocol stack is allowed to send packet to the network device and to receive from the network device

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2026-01-06 16:04:03 +08:00
zhanghongyu
c481374fb8 devif_poll: only call the corresponding xxx_poll when there is data to be sent
reduce the execution consumption of irrelevant code

testing the TX rates of TCP and UDP based on the Infineon board can
increase them by 13%.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-02 00:04:16 +08:00
zhanghongyu
3778834527 netdev_foreach.c: add lock protection during the traversal process
when traversing g_netdevices, it is necessary to ensure that they are
not modified during the traversal.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-02 00:00:55 +08:00
wenquan1
d6bd89ff14 Revert "net/arp: reducing unnecessary ARP requests can mitigate"
This reverts commit 696a94c8055dc59933457e8ce5c3c91dbecab980
first, when continuous ping from tester to vela, if ignore arp expire when ping response use arp_out to build L2 layer, this cause TC13 testing arp entry expire feature failed. second, the patch of support queue iob when arp_out failed can fix this bug.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-01-01 17:03:29 +08:00
zhanghongyu
adb161aa10 arp: the manually configured arp table should not have a timeout period
Improve the behavior of the ARP table so that the manually configured
ARP table has the highest priority, can only be manually modified to
other values, otherwise will never change again, and will not time out.
The modified behavior is consistent with that of Linux.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-01 17:03:29 +08:00
zhanghongyu
eb60667561 net/utils/net_lock.c: add api to lock conn and netdev
add new api to protect access and operation to conn and dev

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-29 09:42:18 +08:00
zhanghongyu
0af74a54bb net/netdev: separate netdev_list_lock from net_lock
use netdev_list_lock to protect all network card traversal, registration,
and deregistration operations.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-29 09:42:18 +08:00
zhanghongyu
a0bd741387 mld: free all mld group when netdev unregister
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>
2025-12-25 08:35:04 -03:00
gaohedong
23013b33ce net/ethernet: ARP can be configured on interface
ARP can be configured on interface.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-25 12:23:38 +08:00
Zhe Weng
2b34bcfcb1 netdev/ioctl: Add support for simple VLAN ioctl
Supporting ADD_VLAN_CMD and DEL_VLAN_CMD of SIOCSIFVLAN
Ref: https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L621

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng
b2db3a6430 net/netdev: Add netdev_iob_replace_l2 for netdev to avoid misuse
And fix wrong `d_len` for IOBs from `upper->txq` in TX.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
zhanghongyu
f5741c0ea1 net/netdev/netdev_register.c: skip mld_devinit if Nic can not support mld
avoid unnecessary operations

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-06 18:13:26 +08:00
nuttxs
22560958bc net/arp: reducing unnecessary ARP requests can mitigate
Some checks failed
Build Documentation / build-html (push) Has been cancelled
network congestion and avoid packet delays caused by
waiting for ARP responses

Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
2025-07-08 12:43:43 -03:00
Lars Kruse
3ce85ca54e style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
Carlos Sanchez
dd53c34722 net/netdev: Change SIOCSCANBITRATE to require interface down.
Previously, SIOCSCANBITRATE brought the iterface up to ensure changes
where immediately applied. This was confusing, see
https://lists.apache.org/thread/g8d0m6yp7noywhroby5br4hxt3r4og2c
Now SIOCSCANBITRATE fails is interface is up.
All existing SocketCAN drivers updated.

Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
2025-04-15 01:59:57 +08:00
zhanghongyu
05f7b7ac97 include/netinet/arp.h: change the type of arp_dev from uint8_t to char
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>
2024-12-26 23:29:23 +08:00
Jukka Laitinen
313b2cd1ed net/netdev/netdev_default.c: Exclude socket can from default devices
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2024-10-16 15:39:11 +08:00
wangxiaoxin
2a99490ed6 add a flag of lin internal sleep/wakeup state
Signed-off-by: wangxiaoxin <wangxiaoxin@xiaomi.com>
2024-10-16 14:33:59 +08:00
wangchen
7dcbd235fc netdev:In netdev_default,If there is only one loopback network devices, it returns NULL
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>
2024-10-13 02:02:54 +08:00
zhangjun21
d21f10bea6 case SIOCGIWNAME: add filter out non-802.11 interfaces
netdev_wifr_ioctl SIOCGIWNAME cmd, need to filter out non-802.11 interfaces

Signed-off-by: zhangjun21 <zhangjun21@xiaomi.com>
2024-10-09 12:43:54 +08:00
wangxiaoxin
983f263ea6 add can/lin controller status
Signed-off-by: wangxiaoxin <wangxiaoxin@xiaomi.com>
2024-10-09 08:39:14 +08:00
zhangjun21
16124b0926 fix snprintf truncation warnings
gcc7.1 adds truncation warning, netdev_ifconf.c fix snprintf truncation warnings

Signed-off-by: zhangjun21 <zhangjun21@xiaomi.com>
2024-10-08 22:31:32 +08:00
Xiang Xiao
77821fb7eb net: Remove IFF_DOWN flag to compatible with Linux/*BSD
turn off interface by checking IFF_UP flag isn't set:
https://github.com/apache/nuttx/issues/1838

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-08 10:15:16 +08:00
Alin Jerpelea
67d02a45eb net: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:08:11 +08:00
Zhe Weng
dde7411679 netdev/statistics: Add bytes for netdev statistics log
Now the log looks like:
wlan0:T30/30(3385B),R(14+24)/40(6061B)

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-09-10 11:36:03 +08:00
daichuan
e48d5d8271 add for support cmake with netdev_notify_recvcpu.c
Signed-off-by: daichuan <daichuan@xiaomi.com>
2024-08-30 01:45:06 +08:00
daichuan
b5753d06f2 support rss/arfs with device
Signed-off-by: daichuan <daichuan@xiaomi.com>
2024-08-30 01:45:06 +08:00
Zhe Weng
acbddd11d5 net/netdev: Add periodic log for netdev statistics
Work for every network device using `CONFIG_NETDEV_STATISTICS`.

Log style:
<interface>:T{done}/{total},R({v4}+{v6})/{total} {Protocol}:T{tx},R{rx},D{drop}
Example:
wlan0:T10/10,R(10+20)/31 TCP:T0,R0,D0 UDP:T0,R10,D0 ICMP:T0,R0,D0 ICMP6:T0,R0,D0

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-08-22 16:17:56 +08:00
wangchen
27c2940df2 netdev/ioctl: Setting log level to warning on SIOCGIFHWADDR failure
When our apps call getifaddrs on lo frequently, the loopback device will failed in SIOCGIFHWADDR and print too many error logs.

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-08-21 01:37:06 +08:00
liqinhui
05b101134a net:Support jumbo frame prealloc the iob for the ICMP/UDP/TCP.
For the ICMP, UDP and TCP, pre-alloc an iob for a jumbo frame.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2024-06-02 09:31:37 -03:00
Zhe Weng
2a342d2424 net/netdev: Add netdev_iob_clone helper
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-03-29 11:52:24 +08:00
wangchen
204f4a18a0 Support to ARP Address Conflict Detection
Support to ARP Address Conflict Detection

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2024-01-25 11:25:03 -03:00
Zhe Weng
3b74cfecc2 net/route: Support longest prefix match for routing
Support longest prefix match routing described as "Longest Match" in
RFC 1812, Section 5.2.4.3, Page 75.

Introduced `prefixlen` to indicate the prefix length of currently
founded route, and only looks up for longer prefix in all later steps.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-01-09 05:58:10 -08:00
Zhe Weng
5aeb15469a netdev/ipv6: Move xxx_ipv6multicast from arch to common code
The `xxx_ipv6multicast` function in each driver is not adapted to
multiple IPv6 addresses yet, and they're redundant, so try to take them
into common code.

Change:
1. Add MAC `g_ipv6_ethallnodes` and `g_ipv6_ethallrouters` in
   `icmpv6_devinit` and call them in `netdev_register`
2. Add multicast MAC for Neighbor Solicitation when adding any IPv6
   address, and remove them when IPv6 address is removed
3. Select `NET_MCASTGROUP` when `NET_ICMPv6` because now we need
   `d_addmac` when we have ICMPv6

Note:
We want modules outside net stack to call functions like
`netdev_ipv6_add` and never touch the related MAC address, so these MAC
functions are added as internal functions to `net/netdev/netdev.h`

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-16 05:26:16 -08:00
liqinhui
98e3615b60 net/netdev: Modify the logic for setting the IFF_RUNNING status of interfaces.
Refer to the logic of the `netif_carrier_on` on linux.
https://github.com/torvalds/linux/blob/master/net/sched/sch_generic.c#L575

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-15 18:24:23 -08:00
Petteri Aimonen
c3a234fe99 ipv6: Fix source address with many addresses in same network
Previously ipv6 multi-address support decided packet source
address based on its destination. This doesn't work if NuttX
device has multiple addresses within same subnet.

Instead when a packet is a response to existing connection,
the source address should be based on the destination address
used in the received packet.
2023-12-13 06:13:25 -08:00
Zhe Weng
4c99ad1ba9 net/utils: Switch argument order of net_ipv6_pref2mask
When implementing IPv6-related logic, we found the `net_ipv6_pref2mask`
and `net_ipv6addr_copy` are using different argument order:
```
net_ipv6addr_copy(ifaddr->addr, addr);
net_ipv6_pref2mask(preflen, ifaddr->mask);
```
Change the order to:
```
net_ipv6addr_copy(ifaddr->addr, addr);
net_ipv6_pref2mask(ifaddr->mask, preflen);
```

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
Zhe Weng
3e4d847f42 net/netdev: Support managing multiple IPv6 addresses by ioctl
1. Supporting `SIOCSIFADDR` and `SIOCDIFADDR` with Linux in6_ifreq struct to manage ipv6 addresses.
   Ref: https://man7.org/linux/man-pages/man7/netdevice.7.html
2. Supporting alias like 'eth0:0' for multiple IPv6 addresses, to keep previous ioctl `SIOCGLIFADDR`, `SIOCSLIFADDR`, `SIOCGLIFNETMASK` and `SIOCSLIFNETMASK` working.
   Ref: https://man7.org/linux/man-pages/man8/ifconfig.8.html

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
Zhe Weng
2b9633e652 net: Support multiple IPv6 address per netdev
Note that user-space related code, like procfs and lifreq related ioctl commands, are not touched in this commit.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00