zhhyu7 opened a new pull request, #21893:
URL: https://github.com/apache/nuttx/pull/21893

   ## Summary
   
   Pick a batch of net/tcp fixes and small improvements from a downstream
   tree onto master.  All are self-contained TCP changes.  Patches that
   depend on downstream-only infrastructure (global mempool / bmp) or that
   master already implements differently were deliberately excluded.
   
   ### TCP protocol fixes
   - fix window size decrease when receiving out-of-order packets
   - directly send RST when SO_LINGER is set and l_linger is 0
   - drop packet when the TCP offset/length info is wrong (RFC 793 3.1)
   - support simultaneous OPEN attempts (RFC 793 / RFC 1122)
   - stop the timer when receiving TCP_ACK in TCP_SYN_* states
   - delayed release of TCP resources in TCP_SYN state (avoid UAF)
   - fix use-after-free in tcp_accept_connection callback
   - fix non-blocking connect race by extending the lock scope
   - fix passive established conn cannot be freed if not accepted
   - fix potential null pointer dereference in tcp_input
   - fix tx_unacked counting exception
   - fix build error when CONFIG_NET_TCP_FAST_RETRANSMIT is disabled
   
   ### Related
   - net/socket: set _SF_CONNECTING flag when socket connect
   - drivers/net/tun: fix tcpdump cannot capture the tun reply packet
   - drivers/net/netdev_upperhalf: change bool to int to fix an unaligned
     access problem
   
   ## Impact
   
   Most of these are bug fixes on error/edge paths and do not change the
   normal data path. The ones with observable or compatibility-relevant
   effects:
   
   - **Behavior change — out-of-order window** ("fix window size decrease
     when receive out-of-order packets"): cached out-of-order segments are
     no longer counted against the advertised receive window, so the window
     no longer shrinks for them. This changes the advertised window under
     packet reordering (intended; aligns with Linux behavior).
   
   - **Behavior change — SO_LINGER=0 close**: when SO_LINGER is set with
     l_linger=0, close() now aborts with RST and releases the connection
     immediately instead of going through the normal FIN handshake. Callers
     relying on the old graceful-close behavior with this specific option
     combination will see an RST.
   
   - **Statistics / procfs output change** ("drop packet when offset info is
     wrong"): adds a new counter `headerr` to the TCP statistics structure
     and an extra column to the TCP line in `/proc/net/stat` (guarded by
     CONFIG_NET_STATISTICS && CONFIG_NET_TCP). Anything parsing that line by
     fixed columns must account for the new field.
   
   - **Cross-protocol touch** ("set _SF_CONNECTING flag on connect"): sets
     the _SF_CONNECTING socket flag during connect; touches the TCP, rpmsg,
     usrsock and vsock socket paths. No API change, but the flag is now set
     on connect across these families.
   
   - The remaining changes (SYN-state timer stop, delayed resource release
     in TCP_SYN, accept use-after-free, non-blocking connect race, passive
     conn free, null-pointer deref, tx_unacked accounting, the
     FAST_RETRANSMIT build fix, and the tun tcpdump fix) are fixes on
     error, close or race paths and do not alter the normal connected
     send/recv behavior.
   
   No public API signatures change. The TCP statistics structure layout
   changes (new `headerr` field), which affects any out-of-tree code that
   reads it by offset.
   
   ## Testing
   
   Built and run on the simulator (flat build, single core).
   
   Build / style:
   - `./tools/configure.sh sim:tcploop` (+ CONFIG_NET_IPv4) — make and link
     succeed.
   - `./tools/checkpatch.sh -c -m -g <range>` — passes for all 15 commits.
   
   Runtime (sim:tcploop, IPv4 loopback, bundled throwaway self-tests):
   
   1. Full connection lifecycle (server thread listen/accept/recv/echo,
      client connect/send/recv/close), run twice back-to-back:
   
          nsh> ifup lo
          nsh> tcptest
          tcptest: client connected
          tcptest: server accepted from 127.0.0.1:23496
          tcptest: server received 'tcp-loopback-payload-0123456789' (31 bytes)
          tcptest: client echo verified 'tcp-loopback-payload-0123456789'
          tcptest: TCP loopback PASS
   
      Exercises the normal path: connect, listen/accept, established
      send/recv, active+passive close, and port reuse on the second run.
   
   2. Connect into the backlog, then close the listener WITHOUT accepting,
      so the passive connection must be freed — completes cleanly, no crash
      or hang (covers "passive established conn cannot be freed if not
      accepted").
   
   3. SO_LINGER with l_linger=0 close — completes cleanly (covers the
      "directly send RST when SO_LINGER is set and l_linger is 0" path).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to