apache / nuttx-apps

Apache NuttX Apps is a collection of tools, shells, network utilities, libraries, interpreters and can be used with the NuttX RTOS
https://nuttx.apache.org/
Apache License 2.0
263 stars 488 forks source link

`CONFIG_SYSTEM_DHCPC_RENEW6` implicitly depends on `CONFIG_NET_ICMPv6_AUTOCONF` #2412

Open sumpfralle opened 3 weeks ago

sumpfralle commented 3 weeks ago

Versions

How to reproduce

make distclean
tools/configure.sh -l sim:nsh
kconfig-tweak --enable CONFIG_NET
kconfig-tweak --keep-case --enable CONFIG_NET_IPv6
kconfig-tweak --enable CONFIG_NET_UDP
kconfig-tweak --keep-case --enable CONFIG_NET_ICMPv6
kconfig-tweak --enable CONFIG_SYSTEM_DHCPC_RENEW6
make olddefconfig
make

The linking fails:

/usr/bin/ld: nuttx.rel: in function `renew6_main':
/home/example/git/nuttx/nuttx-apps/system/dhcp6c/renew6_main.c:46:(.text.renew6_main+0x35): undefined reference to `netlib_obtain_ipv6addr'
collect2: error: ld returned 1 exit status

The missing function is called here: https://github.com/apache/nuttx-apps/blob/master/system/dhcp6c/renew6_main.c#L46

The function is implemented here: https://github.com/apache/nuttx-apps/blob/master/netutils/netlib/netlib_obtainipv6addr.c#L151

Workaround

--- a/system/dhcp6c/Kconfig
+++ b/system/dhcp6c/Kconfig
@@ -7,7 +7,7 @@ config SYSTEM_DHCPC_RENEW6
        tristate "DHCP IPv6 Address Renewal"
        default n
        select NETUTILS_DHCP6C
-       depends on NET_UDP && NET_IPv6
+       depends on NET_UDP && NET_IPv6 && NET_ICMPv6_AUTOCONF
        ---help---
                Enable the DHCP client 'renew6' command

The above patch adds NET_ICMPv6_AUTOCONF as a dependency.

Afterwards the expanded procedure works a bit better (added AUTOCONF):

make distclean
tools/configure.sh -l sim:nsh
kconfig-tweak --enable CONFIG_NET
kconfig-tweak --keep-case --enable CONFIG_NET_IPv6
kconfig-tweak --enable CONFIG_NET_UDP
kconfig-tweak --keep-case --enable CONFIG_NET_ICMPv6
kconfig-tweak --keep-case --enable CONFIG_NET_ICMPv6_AUTOCONF
kconfig-tweak --enable CONFIG_SYSTEM_DHCPC_RENEW6
make olddefconfig
make

Now it fails later:

/usr/bin/ld: nuttx.rel: in function `dhcp6c_command':
/home/lars/git/nuttx/nuttx-apps/netutils/dhcp6c/dhcp6c.c:857:(.text.dhcp6c_command+0x3c5): undefined reference to `NXsetsockopt'
/usr/bin/ld: nuttx.rel: in function `dhcp6c_precise_open':
/home/lars/git/nuttx/nuttx-apps/netutils/dhcp6c/dhcp6c.c:1792:(.text.dhcp6c_precise_open+0x493): undefined reference to `NXsetsockopt'
/usr/bin/ld: /home/lars/git/nuttx/nuttx-apps/netutils/dhcp6c/dhcp6c.c:1793:(.text.dhcp6c_precise_open+0x4c0): undefined reference to `NXsetsockopt'
/usr/bin/ld: /home/lars/git/nuttx/nuttx-apps/netutils/dhcp6c/dhcp6c.c:1794:(.text.dhcp6c_precise_open+0x4f6): undefined reference to `NXsetsockopt'
collect2: error: ld returned 1 exit status

But the above error is probably related to the selected platform (sim:nsh).

Is the added dependency the proper way to solve this issue? In this case I could prepare a PR.

UPDATE: I previously mentioned CONFIG_ICMPv6_SOCKET (instead of _AUTOCONF), but the former setting is not related to the problem above.