checkpoint-restore / criu

Checkpoint/Restore tool
criu.org
Other
2.77k stars 561 forks source link

Linking `criu` fails, because `net/netlink.h` from kernel is not installed #2329

Closed dilyanpalauzov closed 5 months ago

dilyanpalauzov commented 5 months ago

When I try to compile criu-3.19 I get this error

  LINK     criu/criu
/usr/local/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: criu/built-in.o: in function `nsid_cb':
/src/containers/criu-3.19/criu/net.c:3626:(.text+0x4796f): undefined reference to `nla_get_s32'
/usr/local/lib/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../x86_64-pc-linux-gnu/bin/ld: criu/built-in.o: in function `dump_one_netdev':
/src/containers/criu-3.19/criu/net.c:524:(.text+0x49f71): undefined reference to `nla_get_s32'
collect2: error: ld returned 1 exit status
make[1]: *** [criu/Makefile:88: criu/criu] Error 1
make: *** [Makefile:269: criu] Error 2

nla_get_s32() is called from criu/net.c. nla_get_s32() is defined as macro in linux-5.10.198/include/net/netlink.h as static inline s32 nla_get_s32(const struct nlattr *nla) { return *(s32 *) nla_data(nla); }.

The problem is, that I cannot convince the kernel to install net/netlink.h by calling its make headers_install.

Do I oversee a way to install linux-5.10.198/include/net/netlink.h from the kernel source code, or shall I use newer kernel, or am I supposed to manually fix this build step anyhow?

rst0git commented 5 months ago

@dilyanpalauzov From the error message it looks like the header file is correctly installed but the linker fails to find a reference to nla_get_s32. It should be provided by libnl (https://github.com/checkpoint-restore/criu/commit/0588c3b21a17f063437cff22c15ca12801ed711b).

dilyanpalauzov commented 5 months ago

I download https://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz from https://www.infradead.org/~tgr/libnl/ . Unpack it. grep -ri nla_get_s32 finds nothing.

rst0git commented 5 months ago

On my system (Fedora 39), nla_get_s32() is defined in /usr/include/libnl3/netlink/attr.h, which is provided by the libnl3-devel package: https://github.com/thom311/libnl/blob/8693347f/include/netlink/attr.h#L113

Could you try to install the libnl release from GitHub? https://github.com/thom311/libnl/releases

dilyanpalauzov commented 5 months ago

Installing thom311/libnl does help. So the problem is that the detection of the right libnl, if any, is not done correctly.

avagin commented 5 months ago

@dilyanpalauzov you can find all required packages in dockerfile: https://github.com/checkpoint-restore/criu/tree/criu-dev/scripts/build