nuttx/net
dongjiuzhu1 d1bc2800e3 net/local: simplify file descriptor passing using shared filep references
This commit removes unnecessary file duplication and memory allocation when
passing file descriptors through Unix domain sockets, leveraging the new
filep reference counting framework.

Background:
With the new filep framework, file structures (filep) can be safely shared
across processes using reference counting. When passing file descriptors
through SCM_RIGHTS control messages on local sockets, the previous
implementation unnecessarily duplicated the entire file structure.

Changes:

1. In local_sendctl() (sender side):
   - Removed allocation of filep2 structure (kmm_zalloc)
   - Removed file_dup2() call that copied the file structure
   - Now directly stores the original filep with its reference count
   - Eliminates memory allocation overhead and potential failure points

2. In local_recvctl() (receiver side):
   - Changed from file_close() + kmm_free() to file_put()
   - file_put() properly decrements reference count and handles cleanup
   - Consistent with the new filep reference counting model

3. In local_freectl() (cleanup on error):
   - Changed from file_close() + kmm_free() to file_put()
   - Ensures proper reference count management during error paths

Technical Details:
The new filep framework ensures that:
- Multiple file descriptors across different processes can reference the
  same underlying filep structure safely
- Reference counting (via file_get/file_put) manages lifetime correctly
- The underlying file object is only released when all references are gone

This change is safe because file_dup() in the receiver already calls
file_get() internally to increment the reference count for the new fd,
so the filep remains valid after the sender calls file_put().

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-12-31 02:29:46 +08:00
..
arp net/arp: support ARP entry learned on gratuitous ARP response 2025-12-30 21:10:50 +08:00
bluetooth net/ioctl: add a socket interface for ioctl 2025-12-29 14:38:15 +08:00
can net/ioctl: add a socket interface for ioctl 2025-12-29 14:38:15 +08:00
devif net/ipv6: Drop IP packet shorter than length in IP header 2025-12-30 11:28:38 +08:00
icmp net/icmp: Support icmp timestamp request 2025-12-30 21:05:46 +08:00
icmpv6 net/neighbor: Skip Neighbor request if ip address is invalid at ipv6 2025-12-30 22:06:21 +08:00
ieee802154 net/ioctl: add a socket interface for ioctl 2025-12-29 14:38:15 +08:00
igmp igmp_msg.c:mod check of IGMP_SCHEDMSG from assert to error log 2025-12-25 09:58:14 +08:00
inet net/ethernet: fix compilation issues 2025-12-29 23:31:51 +08:00
ipfilter fix compile warning with implicit declaration of function 'icmp_reply' 2024-10-08 22:30:11 +08:00
ipforward net/net_initialize: remove the empty functions that are not needed 2025-12-25 09:50:40 +08:00
ipfrag net/netdev: separate netdev_list_lock from net_lock 2025-12-29 09:42:18 +08:00
local net/local: simplify file descriptor passing using shared filep references 2025-12-31 02:29:46 +08:00
mld mld: free all mld group when netdev unregister 2025-12-25 08:35:04 -03:00
nat net/nat: replace net_lock with nat_lock(mutex) 2025-12-29 09:42:18 +08:00
neighbor net/neighbor: Skip Neighbor request if ip address is invalid at ipv6 2025-12-30 22:06:21 +08:00
netdev net/utils/net_lock.c: add api to lock conn and netdev 2025-12-29 09:42:18 +08:00
netfilter fix compile warning with ipt_sockopt.c and ip6t_sockopt.c: implicit declaration of function 'popcount' 2024-10-08 22:30:11 +08:00
netlink net/ioctl: add a socket interface for ioctl 2025-12-29 14:38:15 +08:00
pkt net/ethernet: fix compilation issues 2025-12-29 23:31:51 +08:00
procfs net/tcp: replace net_lock with conn_lock and conn_lock_dev 2025-12-29 09:42:18 +08:00
route style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
rpmsg net: Split msg_iovlen check in recvmsg into each protocol 2025-01-20 17:12:14 +08:00
sixlowpan style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
socket net/ioctl: add a socket interface for ioctl 2025-12-29 14:38:15 +08:00
tcp net/tcp: fix send RST bug when receive syn retransmit in syn-rcvd state 2025-12-30 21:04:52 +08:00
udp net: change conn lock from mutex to rmutex 2025-12-29 09:42:18 +08:00
usrsock net/bufpool: fix typo 2025-12-25 08:33:13 -03:00
utils net: change conn lock from mutex to rmutex 2025-12-29 09:42:18 +08:00
CMakeLists.txt net: migrate to SPDX identifier 2024-09-12 01:08:11 +08:00
Kconfig net/can: add write buffer to support nonblock send 2025-12-15 10:19:15 +08:00
Makefile Revert "build depend:Revert Make.dep intermediate ddc file" 2024-09-15 19:29:47 +08:00
net_initialize.c net/net_initialize: remove the empty functions that are not needed 2025-12-25 09:50:40 +08:00