Skip to content

differences in struct ifaddrs #682

Closed

Description

@mwanner

Currently, there are two variants of struct ifaddrs in libc: one matching Linux with an ifa_ifu field and an OS X variant with only ifa_dstaddr. However, some other BSD derivates define ifa_broadaddr as well, which isn't currently covered (and I guess the fields would be misaligned on systems having ifa_broadaddr as a separate field in the struct).

Googling for getifaddr man pages, I found these different definitions:

Variant 1: union:
http://man7.org/linux/man-pages/man3/getifaddrs.3.html (Linux)
https://docs.oracle.com/cd/E26502_01/html/E29035/getifaddrs-3socket.html (Solaris 11)

Variant 2: only ifa_dstaddr, no ifa_broadaddr (or possibly a macro on ifa_dstaddr):
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/getifaddrs.3.html (OS X)

Variant 3: separate fields ifa_dstraddr and ifa_broadaddr:
http://netbsd.gw.com/cgi-bin/man-cgi?getifaddrs+3+NetBSD-current (NetBSD)
https://www.freebsd.org/cgi/man.cgi?getifaddrs (FreeBSD)
https://man.openbsd.org/getifaddrs.3 (OpenBSD)

Based on these findings, I suppose struct ifaddr in src/unix/bsd/mod.rs would have to move down to the variant-specific fiels under apple, freebsdlike and netbsdlike to adjust for this difference. And the Solaris variant should probably simply be changed to use ifa_ifu. Any other platform that needs to be supported and checked?

Activity

  1. alexcrichton commented on Jul 20, 2017

    @alexcrichton
    Member

    Platforms like Solaris and some BSD platforms aren't verified automatically today, so feel free to change the definition on those paltforms!

  2. marmistrz commented on Jul 23, 2017

    @marmistrz
    Contributor

    Can Travis test BSD/Solaris?

  3. alexcrichton commented on Jul 23, 2017

    @alexcrichton
    Member

    Only with QEMU currently, they don't offer native hosts running BSD/Solaris

  4. asomers commented on Jul 26, 2017

    @asomers
    Contributor

    I have a buildbot that I use to test nix and mio-aio on freebsd. What does it take to verify libc? I have plenty of cpu cycles to spare.

  5. alexcrichton commented on Jul 26, 2017

    @alexcrichton
    Member

    Oh note that we've already got QEMU emulation of FreeBSD, is that sufficient for libc?

  6. asomers commented on Jul 26, 2017

    @asomers
    Contributor

    Yeah, QEMU is probably good enough for libc, as long as its fast enough.

  7. asomers commented on Nov 16, 2017

    @asomers
    Contributor

    Actually, things aren't as bad as @mwanner thinks. The man pages make it look like the BSDs have an extra ifa_broadaddr field, but it's actually a macro for ifa_dstaddr. AFAICT, the only problem is on NetBSD, which adds an extra ifa_addrflags field at the end.

    Here are links to the structure definitions, as opposed to man pages
    https://github.com/illumos/illumos-gate/blob/master/usr/src/head/ifaddrs.h
    https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/include/ifaddrs.h?rev=1.4&content-type=text/x-cvsweb-markup
    http://cvsweb.netbsd.org/bsdweb.cgi/src/include/ifaddrs.h?rev=1.8&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
    https://svnweb.freebsd.org/base/head/include/ifaddrs.h?revision=250887&view=markup

    A maintainer should retitle the issue to "missing field for struct ifaddrs on NetBSD"

  8. EternalDeiwos commented on Jan 13, 2018

    @EternalDeiwos

    Registering an interest regarding this for Android.

    I've noticed that this seems to be absent from the linux path? Specifically the following in ./unix/bsd/mod.rs:

    seem to be missing from ./unix/nonbsd/mod.rs, which would mean that all linux (not just android) builds of libc would just not have access to libc::ifaddrs?

    To further complicate things, if this repo is to be believed, it seems that the Android NDK might not support ifaddrs.

  9. jakllsch commented on Aug 14, 2018

    @jakllsch
    Contributor

    The NetBSD situation with ifa_addrflags is complicated. The still-supported NetBSD 7.x release series does not have the ifa_addrflags field, while the NetBSD 8.x release series and -current do.

    I've not looked closely as to what this particular difference means for compatibility of binaries. The lack of OS-level ABI/API breaking-change handling in the libc crate leaves a lot to be desired…

  10. gnzlbg commented on Nov 22, 2018

    @gnzlbg
    Contributor

    It seems that a lot of work has happened here already. What exactly remains to be done here?

  11. mwanner commented on Nov 23, 2018

    @mwanner
    ContributorAuthor

    I agree, ifa_broadaddr has vanished, it seems.

  12. added a commit that references this issue on Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions