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

   **The bug is real.** In `include/netutils/netlib.h`, `union 
netlib_conntrack_addr_u` has `ipv4` only under `CONFIG_NET_IPv4` and `ipv6` 
only under `CONFIG_NET_IPv6`. In `nuttx/include/nuttx/net/ip.h`, 
`net_ipv4addr_hdrcopy()` and `net_ipv6addr_hdrcopy()` are guarded the same way. 
`netlib_conntrack.c` is built whenever `CONFIG_NETLINK_NETFILTER=y`, and that 
option only depends on `NET_NAT`. So a NAT44-only config (`NET_IPv4=y`, 
`NET_IPv6=n`) fails on `tuple->src.ipv6`, and the reverse fails for a 
NAT66-only config.
   
   **The fix is correct.** I checked the kernel side 
(`net/netlink/netlink_netfilter.c`). `netlink_conntrack_fill_ip()` emits 
`CTA_IP_V4_*` only under `CONFIG_NET_NAT44` (which depends on `NET_IPv4`) and 
`CTA_IP_V6_*` only under `CONFIG_NET_NAT66` (which depends on `NET_IPv6`). 
`netlink_list_conntrack()` returns `-ENOSYS` for a family that isn't enabled. 
So in every configuration this change drops only attributes the kernel can't 
send, and runtime behaviour doesn't change. If both families are off, the 
`switch` is left with no cases, which is still valid C.
   
   **Unrelated things I noticed (no need to address in this PR):**
   - `system/conntrack` calls `inet_ntop(family, &tuple->src, ...)` with 
`family` taken from the message. With IPv6 disabled the union is only 4 bytes, 
so an `AF_INET6` family would over-read it. The kernel never sends one in that 
configuration, so this is theoretical only.
   - In `netlib_get_conntrack()`, `struct netlib_conntrack_s ct` isn't cleared 
between messages. If an entry is missing an attribute, the values from the 
previous entry are reported.


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