cederom commented on PR #22145:
URL: https://github.com/apache/nuttx/pull/22145#issuecomment-7072226222

   **Medium**
   
   1. **`/proc/net/tcp` and `/proc/net/udp` can leave a connection out.** The 
walk finds its place by counting `priv->lines` from the head of the list. If a 
connection already written is freed between two `read()`s, or while the lists 
are unlocked to wait for a device lock (`f89ba72f`), the count skips the next 
unwritten connection. The comment promises no duplicates, and that holds, but 
nobody notices a missing line. The comment and commit message should say lines 
can be missed under churn. This also matters for the test (see apps #1).
   
   **Low**
   
   2. **The three-tries rule skips a line silently.** In `f89ba72f`, after 
three failed tries the line is counted as written but never printed, which also 
leaves a gap in the `sl` numbering. It only happens if the connection at that 
position keeps switching device, so it should be rare. A short comment that 
it's intentional would help.
   3. **UDP still reads connection data without the device lock.** It reads 
`readahead` and calls `udp_wrbuffer_inqueue_size()` the same way TCP did before 
`f89ba72f`. Either fix it here or say in the PR that UDP is left for later.
   4. **The output format changes.** IPv4 and IPv6 lines used to come out 
grouped by family; now they are mixed in list order. Worth one line in the 
commit message for anyone who parses the file.
   5. **Old bug in the code `6ae1cac1` touches.** `tcp_free()` destroys the 
listener's lock (`conn_uninit()`) before it detaches the backlog. In between, 
the `tcp_input()` path for a reset pending connection can still find the 
listener through `blparent` and lock a destroyed mutex. Moving the detach above 
`conn_uninit()` would close that window.
   6. **`tcp_remove_syn_backlog()` now loops until no half-open connection 
matches.** Before, it made a single pass. It matches by address and port, not 
by owner. If a new listener on the same port could show up during the close 
(via SO_REUSEADDR), the loop would free that listener's half-open connections 
and could keep spinning under a SYN flood. It's worth asking the author whether 
that is possible.
   7. **Document the new lock in `tcp.h`.** After `647fd6e3`, 
`listener->accept()` and the `TCP_BACKLOG` callback run with the list lock 
held. That's fine for `accept_eventhandler` today, which only posts a 
semaphore. A note would stop a future callback from taking a device lock there.
   
   **Not this PR's problem:** a `read()` smaller than `TCP_LINELEN` returns 0, 
which looks like end of file too early. The header `snprintf` is also not 
checked against `buflen`. Both were already in master.


-- 
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