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

   ## Summary
   
   A configuration with `NET_ICMPv6_NEIGHBOR` and without `NET_ICMPv6_SOCKET` 
does not build. `struct icmpv6_conn_s` and `icmpv6_nextconn()` exist only with 
`NET_ICMPv6_SOCKET`, but `icmpv6_poll()` and `devif_poll_icmpv6()` are also 
built with `NET_ICMPv6_NEIGHBOR` alone. qemu-armv8a:netnsh with `NET_IPv6`, 
`NET_ICMPv6` and `NET_ICMPv6_NEIGHBOR` on master:
   
   ```
   ./icmpv6/icmpv6.h:270:29: error: 'struct icmpv6_conn_s' declared inside 
parameter list will not be visible outside of this definition or declaration 
[-Werror]
   icmpv6/icmpv6_poll.c:65:6: error: conflicting types for 'icmpv6_poll'; have 
'void(struct net_driver_s *, struct icmpv6_conn_s *)'
   icmpv6/icmpv6_poll.c:68:58: error: invalid use of undefined type 'struct 
icmpv6_conn_s'
   icmpv6/icmpv6_poll.c:78:31: error: invalid use of undefined type 'struct 
icmpv6_conn_s'
   devif/devif_poll.c:553:38: error: invalid use of undefined type 'struct 
icmpv6_conn_s'
   devif/devif_poll.c:561:28: error: passing argument 2 of 'icmpv6_poll' from 
incompatible pointer type [-Wincompatible-pointer-types]
   devif/devif_poll.c:572:28: error: implicit declaration of function 
'icmpv6_nextconn'; did you mean 'icmp_nextconn'? 
[-Wimplicit-function-declaration]
   ```
   
   Without ICMPv6 sockets the poll needs only the callback list of the device 
(`conn` is NULL): Neighbor Solicitation and autoconfiguration add their 
callbacks to it. This PR:
   
   - adds a forward reference to `struct icmpv6_conn_s` in net/icmpv6/icmpv6.h,
   - makes `icmpv6_nextconn()` NULL without sockets, as other functions of 
icmpv6.h do (`icmpv6_wait_setup()`, `icmpv6_wait_cancel()`),
   - uses the connection only with `NET_ICMPv6_SOCKET` in `icmpv6_poll()` and 
`devif_poll_icmpv6()`.
   
   ## Impact
   
   - Configurations with `NET_ICMPv6_SOCKET` do not change: `icmpv6_poll()` 
uses the callback list of the connection when `conn` is not NULL, and the list 
of the device when it is NULL, as before. The 29 defconfigs with 
`NET_ICMPv6_NEIGHBOR` all have `NET_ICMPv6_SOCKET`, so CI did not build the 
broken case.
   - Configurations with `NET_ICMPv6_NEIGHBOR` and without `NET_ICMPv6_SOCKET` 
now build.
   - Network code only: the same for flat, protected and kernel builds and for 
every architecture. The "invalid use of undefined type" errors are errors with 
every compiler, also without `-Werror`.
   - No Kconfig, API or documentation change.
   
   ## Testing
   
   qemu-armv8a:netnsh, aarch64-none-elf-gcc 14.2 (arm64 builds with `-Werror`), 
`EXTRAFLAGS="-Wno-cpp -Werror"`, master 80a052ff9cc vs this PR, apps master 
ee3d67104:
   
   | Configuration | master | this PR |
   |---|---|---|
   | netnsh + `NET_IPv6`, `NET_ICMPv6`, `NET_ICMPv6_NEIGHBOR`, no 
`NET_ICMPv6_SOCKET` | build fails (errors above) | builds, no warnings; one UDP 
`sendto()` to fc00::1 returns 1 |
   | netnsh + `NET_IPv6`, `NET_ICMPv6`, `NET_ICMPv6_NEIGHBOR`, 
`NET_ICMPv6_SOCKET`, `SYSTEM_PING6` | `ping6 -c 4 fc00::1`: 4 of 4 replies | 
`ping6 -c 4 fc00::1`: 4 of 4 replies |
   | netnsh (default, IPv4 only) | not run | builds, no warnings |
   
   The runs use QEMU HVF with a user network (`-netdev 
user,ipv6-net=fc00::/64,ipv6-host=fc00::1 -device virtio-net-device`) and the 
netinit default address fc00::2. Without sockets, the UDP datagram to fc00::1 
needs a Neighbor Solicitation first: `sendto()` returns 1, and ifconfig counts 
1 ICMPv6 packet sent and 1 received. With sockets, `ping6` uses the poll of the 
connection and the Neighbor Solicitation uses the poll of the device. `ping -c 
2 10.0.2.2` also gets 2 of 2 replies in both. `tools/checkpatch.sh -c -u -m -g 
origin/master..HEAD` passes.
   
   Not run: a protected or kernel build, SMP, other architectures.
   


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