Subject: Re: [PATCH iproute2] lib: move rtnl_echo_talk from libnetlink to utils

From: Stephen Hemminger <[email-masked]>
Date: Tue, 11 Jul 2023 09:00:11 -0700

On Tue, 11 Jul 2023 15:31:17 +0800
Hangbin Liu <[email-masked]> wrote:

> In commit 6c09257f1bf6 ("rtnetlink: add new function rtnl_echo_talk()"),
> some json obj functions were exported in libnetlink. Which cause build
> error like:
>     /usr/bin/ld: /tmp/cc6YaGBM.o: in function `rtnl_echo_talk':
>     libnetlink.c:(.text+0x25bd): undefined reference to `new_json_obj'
>     /usr/bin/ld: libnetlink.c:(.text+0x25c7): undefined reference to `open_json_object'
>     /usr/bin/ld: libnetlink.c:(.text+0x25e3): undefined reference to `close_json_object'
>     /usr/bin/ld: libnetlink.c:(.text+0x25e8): undefined reference to `delete_json_obj'
>     collect2: error: ld returned 1 exit status
> 
> Commit 6d68d7f85d8a ("testsuite: fix build failure") only fixed this issue
> for iproute building. But if other applications include the libnetlink.a,
> they still have this problem, because libutil.a is not exported to the
> LDLIBS. So let's move the rtnl_echo_talk() from libnetlink.c to utils.c
> to avoid this issue.
> 
> After the fix, we can also remove the update by c0a06885b944 ("testsuite: fix
> testsuite build failure when iproute build without libcap-devel").
> 
> Reported-by: Ying Xu <[email-masked]>
> Fixes: 6c09257f1bf6 ("rtnetlink: add new function rtnl_echo_talk()")
> Signed-off-by: Hangbin Liu <[email-masked]>

I don't see this when iproute2 is built.
Libnetlink is not a public API. And there is no guarantee about
compatibility if an application links with it.  Collect2 should be
using a supported library like libmnl instea.