cederom commented on PR #4149:
URL: https://github.com/apache/nuttx-apps/pull/4149#issuecomment-7207369646

   Thanks! The layout of the two new entry structs matches what 
`convert_matches()` in the kernel walks (I checked that `match_size` padding 
and the `match + 1` payload offset agree on 64-bit and 32-bit). The rate parse 
and print round-trip correctly (`5/s`, `7/m`, `3/hour`, `13/day`, `10000/s` all 
give the same rate back, and `10001/s` is rejected). Comments:
   
   **1. `!` before the new options carries over to the next option**
   
   `-m`, `--limit` and `--limit-burst` do not look at or clear `inv`. So 
`iptables -A INPUT ! -m limit -p tcp --dport 22 -j DROP` silently inverts 
`--dport` instead. Linux rejects `!` for these options. I'd suggest an error 
when `inv` is set in those three branches.
   
   **2. TCP flag names** (`iptables_utils.c:262`)
   
   Linux iptables accepts flag names in any case (`syn,ack`) and accepts 
`ALL`/`NONE` as items of the list. Here only upper case works, and `ALL`/`NONE` 
only as the whole argument. Using `strncasecmp()` and handling `ALL`/`NONE` 
inside the loop would make scripts written for Linux work unchanged.
   
   **3. Limit after a UDP or ICMP match** (`netlib_iptables.c:814`, same in 
ip6tables)
   
   `-p udp -m limit` works (it takes the "no match" path), but `-p udp --dport 
53 -m limit` and `-p icmp --icmp-type 8 -m limit` fail. The second one is 
probably the most common use of `-m limit` (limiting ping floods). Two more 
structs in the same pattern would cover it, since the kernel side already 
supports it. A follow-up is fine; it is documented as a limitation.
   
   **4. Small things**
   
   - `iptables_match2str(IPT_MATCH(entry), entry->target_offset - sizeof(struct 
ipt_entry))`: if `target_offset` is ever smaller than the entry size, this 
wraps around to a huge length. A `target_offset > sizeof(...) ? ... : 0` guard 
costs nothing.
   - `#include <nuttx/net/tcp.h>` only for `TCP_SYN` etc. pulls a 
kernel-internal header into an app. That's harmless in a flat build, but 
defining the six flag values locally (as the Linux tool does) might be cleaner. 
This is a question more than a request.
   
   **5. Merge order**
   
   This PR needs `XT_MATCH_NAME_LIMIT`, `XT_LIMIT_SCALE` and `struct 
xt_rateinfo` from apache/nuttx#22367, so that one has to be merged first (or CI 
here will fail on nuttx 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