cederom commented on PR #22620:
URL: https://github.com/apache/nuttx/pull/22620#issuecomment-7294826190
Thanks — the six one-line changes are correct, and I checked that the list
is complete: after this PR every in-tree defconfig that builds ping (330 of
them) gets `NET_SOCKOPTS` either set directly or selected by something else
(`NETDB_DNSCLIENT`, `NETUTILS_WEBCLIENT`, the
`EXAMPLES_{DISCOVER,XMLRPC,TCPECHO}_DHCPC` options, `NET_CAN_SOCK_OPTS`). The
new lines are in `savedefconfig` order.
I do have a question about the reason for the change, though:
**The IPv4 ping doesn't need `NET_SOCKOPTS` to build.** The commit message
says ping and ping6 call `setsockopt()` for `ICMP_FILTER`/`ICMP6_FILTER`, which
only exists with `CONFIG_NET_SOCKOPTS`. On nuttx-apps master, though, the IPv4
call is already wrapped:
/* netutils/ping/icmp_ping.c */
#ifdef CONFIG_NET_SOCKOPTS
filter = ICMP_SET_FILTER(ICMP_ECHO_REPLY);
ret = setsockopt(priv->sockfd, SOL_RAW, ICMP_FILTER, ...);
...
#endif
Only `icmpv6_ping.c` calls `setsockopt(ICMP6_FILTER)` without a guard. All
six configs here enable only `SYSTEM_PING` (IPv4); none has `NET_IPv6` or
`SYSTEM_PING6`. So they build and link today, and what breaks them is the new
`depends on NET_ICMP && NET_SOCKOPTS` on `NETUTILS_PING` in
apache/nuttx-apps#4201 (commit e1cb70d). Its "undefined reference to
`setsockopt`" seems to come from before the IPv4 guard was added.
Since `NET_SOCKOPTS` builds `setsockopt.c`, `getsockopt.c`, `net_timeo.c`
and the per-protocol option handlers, this adds flash on small boards (e.g. the
STM32F107 stm32butterfly2), and MemBrowse didn't measure any of these six.
Would one of these work instead?
1. In nuttx-apps, add the dependency to `NETUTILS_PING6` only, or better,
guard the `ICMP6_FILTER` call with `#ifdef CONFIG_NET_SOCKOPTS` like the IPv4
one, and leave `NETUTILS_PING` alone. This PR then isn't needed.
2. If the filter is meant to be required for IPv4 too, please remove the
now-dead `#ifdef CONFIG_NET_SOCKOPTS` in `icmp_ping.c` in #4201 and change the
commit message here to say it's a policy choice, not a build fix.
Small things:
- The commit message says "ping and ping6 call setsockopt() ... which only
exists with CONFIG_NET_SOCKOPTS"; that's only true of ping6.
- It would help to note the flash cost for at least one of these boards
(e.g. `stm32butterfly2:nshnet`, which CI builds).
--
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]