Skip to content

Conversation

@zhhyu7
Copy link
Contributor

@zhhyu7 zhhyu7 commented Dec 30, 2025

Summary

remove the use of net_lock in the usrsock module and decouple it from other network modules.

Impact

net::usrsock

Testing

sim:rpserver and sim:rpproxy with ping and iperf
NuttX log:

NuttShell (NSH) NuttX-12.12.0-RC0
server> ifconfig eth0 10.0.1.2/24
server> 
server> cu

NuttShell (NSH) NuttX-12.12.0-RC0
proxy> 
proxy> ping -c 3 10.0.1.1
PING 10.0.1.1 56 bytes of data
56 bytes from 10.0.1.1: icmp_seq=0 time=40.0 ms
56 bytes from 10.0.1.1: icmp_seq=1 time=50.0 ms
56 bytes from 10.0.1.1: icmp_seq=2 time=40.0 ms
3 packets transmitted, 3 received, 0% packet loss, time 3030 ms
rtt min/avg/max/mdev = 40.000/43.333/50.000/4.717 ms
proxy> iperf -c 10.0.1.1 -B 10.0.1.2
     IP: 10.0.1.2

 mode=tcp-client sip=10.0.1.2:5001,dip=10.0.1.1:5001, interval=3, time=30

           Interval         Transfer         Bandwidth

  -0.00-   3.01 sec    1228800 Bytes    3.27 Mbits/sec
   3.01-   6.02 sec    1228800 Bytes    3.27 Mbits/sec
   6.02-   9.03 sec    1236992 Bytes    3.29 Mbits/sec
   9.03-  12.04 sec    1228800 Bytes    3.27 Mbits/sec
  12.04-  15.05 sec    1236992 Bytes    3.29 Mbits/sec
  15.05-  18.06 sec    1228800 Bytes    3.27 Mbits/sec
  18.06-  21.07 sec    1236992 Bytes    3.29 Mbits/sec
  21.07-  24.08 sec    1228800 Bytes    3.27 Mbits/sec
  24.08-  27.09 sec    1236992 Bytes    3.29 Mbits/sec
  27.09-  30.10 sec    1228800 Bytes    3.27 Mbits/sec
  -0.00-  30.10 sec   12320768 Bytes    3.27 Mbits/sec
iperf exit
proxy> iperf -s -B 10.0.1.2
     IP: 10.0.1.2

 mode=tcp-server sip=10.0.1.2:5001,dip=0.0.0.0:5001, interval=3, time=0
accept: 10.0.1.1:58450

           Interval         Transfer         Bandwidth

   0.00-   3.01 sec    1228800 Bytes    3.27 Mbits/sec
   3.01-   6.02 sec    1228800 Bytes    3.27 Mbits/sec
   6.02-   9.03 sec    1236992 Bytes    3.29 Mbits/sec
closed by the peer: 10.0.1.1:58450
iperf exit
proxy> 

@github-actions github-actions bot added Area: Networking Effects networking subsystem Area: Drivers Drivers issues Size: M The size of the change in this PR is medium labels Dec 30, 2025
acassis
acassis previously approved these changes Dec 30, 2025
@acassis
Copy link
Contributor

acassis commented Dec 30, 2025

@zhhyu7 please fix this CI error:

Error: /github/workspace/sources/nuttx/include/nuttx/net/usrsock.h:322:10: error: implicit declaration of function 'net_sem_timedwait2'; did you mean 'nxsem_timedwait'? [-Wimplicit-function-declaration]
322 | return net_sem_timedwait2(sem, interruptible, timeout, &g_usrsock_lock,
| ^~~~~~~~~~~~~~~~~~
| nxsem_timedwait
make[1]: *** [Makefile:109: drivers_initialize.o] Error 1
make[1]: Target 'libdrivers.a' not remade because of errors.
make: *** [tools/LibTargets.mk:107: drivers/libdrivers.a] Error 2
make: Target 'all' not remade because of errors.

@zhhyu7 zhhyu7 force-pushed the upstream-2 branch 3 times, most recently from 556fe8f to 0c30689 Compare December 31, 2025 00:48
dup2 and setsockopt can use the lock in conn to protect resources,
the lock in accept is originally used to protect the connection status.
however, only the send, recv, netpoll, and connect processes will
check this flag. only when the interface returns will the corresponding
conn structure be exposed to the caller, and then the above operations
can be performed. Therefore, this net_lock is not necessary.

Signed-off-by: zhanghongyu <[email protected]>
…break

two rmutexes can be passed in, and later the wait scenarios that require
break the conn and netdev locks will be replaced.

Signed-off-by: zhanghongyu <[email protected]>
remove the use of net_lock in the usrsock module and decouple it from
other network modules.

Signed-off-by: zhanghongyu <[email protected]>
@acassis acassis merged commit f27a9bb into apache:master Jan 1, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Area: Networking Effects networking subsystem Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants