Commit Graph

162 Commits

Author SHA1 Message Date
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
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
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
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
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 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
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 c7845f5b25 netlink: Explicitly set ip address for netlink notify
Prepare for multiple IPv6 addresses per net device, then we can notify
add/remove of a single address later.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
zhanghongyu 43ecf36d78 udp: modify ipv4 multicast to allow different conn to join simultaneously
add ref count for ipv4 multicast and leave the multicast group when close
behavior alignment with linux.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-04 17:56:06 +08:00
zhanghongyu 3a9c193bf7 ioctl: add SIOCGIWNAME support
some tools use this command to distinguish which device returned via getifaddrs() are wireless network device.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-11-04 17:52:47 +08:00
xucheng5 9d3abe8b71 socket can : support ioctl cmd SIOCCANRECOVERY
send CMD to restart controller in state bus-off

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2023-08-21 13:18:51 +08:00
Zhe Weng d3bca3c2cf net: Add FIOC_FILEPATH ioctl support for ICMP(v6)/RPMsg/Usrsock sockets
Example of /proc/PID/group/fd in this case:

FD  OFLAGS  TYPE POS       PATH
3   3       9    0         icmp:[dev eth0, id 1, flg 1]
4   3       9    0         icmp6:[dev eth0, id 2, flg 1]
5   3       9    0         rpmsg:[ap:[test:0]<->remote] # server side
5   3       9    0         rpmsg:[remote<->ap:[test:0]] # client side

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-15 15:00:59 +08:00
Zhe Weng 8e8d86a7bb net/ioctl: Add default print for sockets without FIOC_FILEPATH support
Example of /proc/PID/group/fd in this case:

FD  OFLAGS  TYPE POS       PATH
17  67      9    0         socket:[domain 16, type 2, proto 0]

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-15 15:00:59 +08:00
Zhe Weng c2ba0dfd6c net/netdev: Simplify handling of SIOCSIFMTU
The call of netdev_ifr_dev is already simplified by commit fd53db56b6

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-08-09 18:29:26 +08:00
SPRESENSE 54112ac070 drivers/modem/alt1250: Update alt1250 driver
Updated alt1250 driver with regarding to the following changes.
- Add LTE hibernation feature
- Split source code per module
- Some refactoring
- Some bug fixes
2023-06-08 07:48:17 +02:00
chao an 589d4a9f8e net/semantic/parser: fix compile warning found by sparse
Reference:
https://linux.die.net/man/1/sparse

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
wangchen d197ca9967 net/procfs: Support to show MTU in netdev statistics
Usage:
ifconfig (interfacename)
example:
ifconfig eth0
eth0	Link encap:Ethernet HWaddr 42:d3:59:ad:5a:2f at RUNNING mtu 1500
	inet addr:10.0.1.2 DRaddr:10.0.1.1 Mask:255.255.255.0
	inet6 addr: fe80::40d3:59ff:fead:5a2f/64
	inet6 DRaddr: ::/64

Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-04-28 09:45:21 +08:00
zhanghongyu fdc6dbf176 netlink: add RTM_NEWADDR, RTM_DELADDR and RTM_GETADDR
We have projects that need to sense ip address changes in time,
and set ip address or clear ip address through netlink
so the relevant implementation is added.
The usage and command structure are consistent with linux

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-04-22 01:35:18 +08:00
Xiang Xiao 9f4a15110c net: Finish FIONBIO default action if si_ioctl return OK
Continue the work: https://github.com/apache/nuttx/pull/6976

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-07 11:34:35 +02:00
Zhe Weng 7111d23ae4 net/arp: Only parse ioctl request for valid cmd.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-06 10:51:12 -03:00
Xiang Xiao d5689e070b net/arp: Remove nuttx/net/arp.h
1.move ARPHRD_ETHER to netinet/arp.h
1.move arp_entry_s to net/arp/arp.h
2.move arp_input to nuttx/net/netdev.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-16 22:10:59 +02:00
zhanghongyu 1a81a936df arp: add device check for arp interface
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-12-14 21:17:08 +08:00
tangyusong1 f454dfccb2 Adjust ioctl function of cellular
Add SIOCGCELLNETDEV
Give a uint8_t[136] for cellular to save data

Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
2022-12-09 11:19:55 +08:00
tangyusong1 1c7a9d282c Add mtu set and interface name set in ioctl
Follow LinuxOS:linux-5.10.152\include\uapi\linux\sockios.h
Add SIOCSIFMTU and SIOCSIFNAME

Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
2022-12-08 13:58:26 +01:00
chao an 85440f5db6 net/ioctl/cellular: remove redundant logic
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-15 18:34:07 +08:00
luojun1 ec4af00538 Add Cellular link layer support
1.Add cellular link layer enum definition and register flow
2.Add ioctl flow to set cellular NICs parameters

Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-15 18:34:07 +08:00
chao an 8b238e0b3d net/wireless: separate command catagory of bt/pktradio from wireless ioctl
1. separate command catagory of bt/pktradio from wireless ioctl
2. Remove commoand count limit to support vendor command

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-20 01:16:22 +08:00
Nathan Hartman d09304008e net: Fix sa_family returned by SIOCGIFHWADDR
* net/netdev/netdev_ioctl.c:
  (netdev_ifr_ioctl): The ioctl SIOCGIFHWADDR provides the hardware
   address (e.g., Ethernet MAC, etc.) of a network interface. It is
   based on Linux. (BSD-based systems don't have this ioctl.) The Linux
   implementation sets sa_family to ARPHRD_ETHER for Ethernet and IEEE
   802.11 interfaces [1]. NuttX was setting it to NET_SOCK_FAMILY for
   these interface types as well as 6LoWPAN and PKTRADIO; this was
   incorrect and also the value of NET_SOCK_FAMILY varies based on
   Kconfig settings. Correcting this to ARPHRD_ETHER for Ethernet and
   IEEE 802.11 and ARPHRD_IEEE802154 for 6LoWPAN and PKTRADIO.

References:
[1] 'man 7 netdevice' on Linux.
2022-09-16 02:59:50 +08:00
Nathan Hartman 6c4bd5c5ef net: Fix memcpy() size used by SIOCSIFHWADDR for radios
* net/netdev/netdev_ioctl.c:
  (netdev_ifr_ioctl): The ioctl SIOCSIFHWADDR sets the hardware address
   (e.g., Ethernet MAC, etc.) of a network interface. Radio devices may
   have different lengths of hardware addresses, such as
   NET_6LOWPAN_EADDRSIZE (8), NET_6LOWPAN_SADDRSIZE (2), or
   RADIO_MAX_ADDRLEN (8). Also, Kconfig CONFIG_PKTRADIO_ADDRLEN allows
   the user to set any arbitrary size. Note that while the sister ioctl
   SIOCGIFHWADDR "get hardware address" copies
   `dev->d_mac.radio.nv_addrlen` bytes, SIOCSIFHWADDR was copying
   NET_6LOWPAN_ADDRSIZE bytes unconditionally. Depending on which radio
   is used, this could be incorrect. Fixing it to use
   `dev->d_mac.radio.nv_addrlen` for SIOCSIFHWADDR as well. Also adding
   DEBUGASSERT to ensure this is within bounds of source and
   destination of the copy.
2022-09-16 02:59:40 +08:00
chao an 66d9397320 netdev/ioctl: netlock/unlock() should in pairs
fix regression by:

commit fd53db56b6
Author: chao an <anchao@xiaomi.com>
Date:   Wed Sep 7 10:56:09 2022 +0800

    net/netdev: simplify handling of netdev ifr ioctl()

    1. call netdev_ifr_dev() only once
    2. unify the error code of ENODEV

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 15:50:45 +08:00
chao an fd53db56b6 net/netdev: simplify handling of netdev ifr ioctl()
1. call netdev_ifr_dev() only once
2. unify the error code of ENODEV

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 11:05:13 +08:00
chao an 54dba40f87 net/netdev/ioctl: correct the argument length of ioctl MII/PHY
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-07 03:33:41 +08:00
Xiang Xiao 9726be616a fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 23:16:15 +08:00
Xiang Xiao e0bb281e7a net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
chao.an 162fcd10ca net: cleanup pvconn reference to avoid confuse
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
Fotis Panagiotopoulos 9bc47ecdce Added lock in ifr ioctl calls. 2022-08-25 14:02:20 +02:00
zhanghongyu 51a262150d wifi: clear IFF_RUNNING flag when ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
zhanghongyu 7467586d55 netdev: add return value for ifup / ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
JacobCrabill 4610aee973 net/netdev: Add CONFIG_NETDEV_CAN_FILTER_IOCTL 2022-05-06 08:54:58 +02:00
hejianliang3 e9648d8a73 net:fix coverity warning
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
YAMAMOTO Takashi bc0ca51243 netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression
This fixes a regression caused by the following commit,
which prevents the file flag from being updated.

```
commit 28860b5242
Author: chao.an <anchao@xiaomi.com>
Date:   Sat Mar 19 14:47:37 2022 +0800

    net/netdev: fix switch case missing break

    Signed-off-by: chao.an <anchao@xiaomi.com>
```

Note: some applications like mbedtls uses F_GETFL to confirm
the nonblock-ness of the socket. This is critical for such
applications.
2022-04-01 16:35:12 +08:00
ligd 5b027f5260 net: netdev_ioctl handle FIONBIO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-28 23:26:34 +08:00
chao.an 28860b5242 net/netdev: fix switch case missing break
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 10:14:35 +02:00
Xiang Xiao b2c86f808d net: Remove psock_fcntl related code
since the nonblocking mode set through psock_ioctl now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
Xiang Xiao dfcb3cea59 Replace self defined macros with NET_SOCK_[FAMILY|TYPE|PROTOCOL]
NET_SOCK_* is defined by nuttx/net/netconfig.h and then can be shared

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-21 11:02:33 -03:00
ligd 4a5d577483 socket_rpmsg: add socket_rpmsg_ioctl support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
songlinzhang 22df553443 net/arp: clean the arp table when netdev carrier off
Fix the arp address changed if netdev renew, since the
arp table should be cleared when the netdev carrier off

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2021-11-27 06:19:50 -06:00
chao.an eabe535de7 net/inet: add support of FIONREAD
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 06:20:52 -05:00