The attached patches almost make traceroute compile with musl libc (http://musl-libc.org).
The first patch makes support for IDN in libc's resolver optional.
The second patch is a sed -i 's/u_int/uint/'. The u_int*_t types are not standard and therefore on musl <sys types.h=""> needs to be included to get them. It is easier though to use the standard <stdint.h> types because the netinet headers are already using them anyway.
The third patch is a sed -i 's.sys/poll.poll/'. <sys poll.h=""> is a non-standard synonym for <poll.h>. musl omits a warning when trying to include it.
It would be nice if the DOS-newlines in mod-dccp.c could be converted.
mod-tcp.c does not compile yet, because musl does not provide the TCPOPT* constants in <netinet tcp.h="">. Since apart from iptables this seems to be the only project using them, it is not clear whether they will be added. As the values of the TCP options don't randomly change, it would be nice if the code be
2; / TCPOPT_MAXSEG /
instead of
TCPOPT_MAXSEG; / 2 /
and likewise in the other places.
Patch 1
Patch 2
Patch 3
Last edit: Felix Janda 2015-06-17
Thanks.
Agree with all except the TCPOPT_MAXSEG -- this macro is present in standard Linuxes for decade, it is a task for musl to include it.
Moreover, since the "diet-like" libc libraries are useful for systems with "diet-like" resources, it is likely it might be used for some, say, low-level network controller, where the TCPOPT_* etc. macros might be needed.
Anyway, is it possible with the musl just to compile with additional cflags "-D AI_IDN=0 -D NI_IDN=0 -D TCPOPT_MAXSEG=2" ? It could be better than to change code for the (currently) rare environment...
I'll put uint, poll and DOS fixes to the next release.
Thanks for applying most of the fixes so quickly!
musl cares much about following standards and being clean. If I want to make a case with the musl developers to add constants, I should refer to some standard or wide usage.
Looking though http://codesearch.debian.net/perpackage-results/TCPOPT_%20-path%3A.*%2Ftcp.h/2/page_0 (search in source code of 18000 packages in the debian repositories) I find only iptables and trcaceroute using TCPOPT_* without providing the declarations themselves. Whether to add these constants is currently up for discussion: http://marc.info/?l=netfilter-devel&m=143448347516274&w=2 For traceroute it would be very easy to change the code to do something like in http://sources.debian.net/src/libnids/1.23-2/src/tcp.c/?hl=204#L204.
musl plans http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Name_Resolver_.2F_DNS to add IDN support to the resolver. However it will be automatically enabled so that one does not need to pass AI_IDN to getaddrinfo. Since they are called glibc specific, I don't know whether the constants will be added. Debian code search again finds many projects #defining AI_IDN when not already defined.
OK, I'll resolve the macros issue as well.
Thank you very much.
According to http://git.musl-libc.org/cgit/musl/commit/?id=53f41fb568ae43034c9876cc9bd3961fd6d13671 musl is going to support TCPOPT... constants in netinet/tcp.h . Hence the traceroute code can be unchanged.
What about AI_IDN and NI_IDN ?
Last edit: Dmitry Butskoy 2016-02-14
Yes, the TCPOPT constants have been added.
IDN is planned for musl-1.15. (musl-1.13 hasn't yet been released.)
Done in 2.0.22
Thanks.