[Bug 259374] [Linux Compatibility Layer] : getifaddrs() : errno = EAFNOSUPPORT

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 23 Oct 2021 10:27:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259374

            Bug ID: 259374
           Summary: [Linux Compatibility Layer] : getifaddrs()  : errno =
                    EAFNOSUPPORT
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: didu31@hotmail.fr

Hi,

interface with gnu/linux getifaddrs() is no perfect.
This concerns at least interface with debian wheezy, buster and bulleyes
kernels.

freebsd-13% ifconfig
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
       
options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether 84:2b:2b:ae:6a:85
        inet 192.168.0.45 netmask 0xffffff00 broadcast 192.168.0.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

And consider this snippet, if.c:

#include <errno.h>
#include <stdio.h>
#include <ifaddrs.h>

int main(int argc, char** argv)
{
  struct ifaddrs *addrs, *ent;

  if (getifaddrs(&addrs))
  {
      printf("errno = %d\n", errno);
      perror("getifaddrs()");
      return 1;
  }

  int count = 0;

  /* Count the number of interfaces */
  for (ent = addrs; ent; ent = ent->ifa_next) 
  {
    count++;
  }
freeifaddrs(addrs);
}

freebsd-13% cc if.c -o if
freebsd-13% ./if
"bge0" af_family = 18            (= AF_LINK  /* Link layer interface */)
"bge0" af_family = 2             (= AF_INET)
"lo0" af_family = 18
"lo0" af_family = 2

freebsd-13% sudo chroot compat/debian /bin/bash
debian% cc if.c -o if
debian% ./if
errno = 97                      (EAFNOSUPPORT)
getifaddrs(): Address family not supported by protocol


Could it be a compatibility bug with AF_LINK ?

-- 
You are receiving this mail because:
You are the assignee for the bug.