| Summary: | Linux(4) getifaddrs() results in Address family not supported by protocol getifaddrs() (EAFNOSUPPORT) | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Didier Garcin <didu31> |
| Component: | kern | Assignee: | Alexander V. Chernikov <melifaro> |
| Status: | Closed FIXED | ||
| Severity: | Affects Many People | CC: | dchagin, emaste, trasz |
| Priority: | --- | Keywords: | needs-qa |
| Version: | 13.0-RELEASE | Flags: | koobs:
maintainer-feedback?
(trasz) koobs: maintainer-feedback? (dchagin) koobs: mfc-stable13? koobs: mfc-stable12? koobs: mfc-stable11- |
| Hardware: | amd64 | ||
| OS: | Any | ||
#include <errno.h>
#include <stdio.h>
#include <ifaddrs.h>
#include <sys/socket.h>
int main(int argc, char** argv)
{
struct ifaddrs *addrs, *ent;
if (getifaddrs(&addrs))
printf("errno = %d\n", errno);
int count = 0;
/* Count the number of interfaces */
for (ent = addrs; ent; ent = ent->ifa_next)
{
count++;
/* ERRATUM */
printf("\"%s\" af_family = %d\n", ent->ifa_name, ent->ifa_addr->sa_family);
}
freeifaddrs(addrs);
}
(In reply to Didier Garcin from comment #1) Can you capture and attach ktrace/strace from running the sample under the Linuxulator? Also, what happens if you run your sample on real Linux? (In reply to Ed Maste from comment #2) I'm sorry, strace is suspended automatically without producing any log : debian$ strace ./if ^C debian$ debian$ strace ./if & [1] 25885 didier@teahupoo:~/labo$ debian$ ps PID TTY TIME CMD 26803 pts/1 00:00:00 ps 26436 pts/1 00:00:00 strace 25885 pts/1 00:00:00 strace 70426 pts/1 00:00:00 bash debian$ On host : freebsd-13% sudo ps -a PID TT STAT TIME COMMAND . . . 25885 1 I 0:00,00 strace ./if 26436 1 TX 0:00,00 strace ./if 69793 1 I 0:00,01 sudo chroot debian /bin/bash . . . AFAIRemember, from some time glibc use NETLINK for getifaddrs, it in my queue, but for first in my POV we need modify domain code to allow detaching of protocol family. I think it’s possible for now after epoch (In reply to Dmitry Chagin from comment #4) Very good news !! over to netlink author merged into the stable/13, thanks too melifaro@ |
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 ?