|
Message-ID: <20140408125438.GN3034@port70.net> Date: Tue, 8 Apr 2014 14:54:38 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: if_nameindex/getifaddrs and dhcpcd issue * Justin Cormack <justin@...cialbusservice.com> [2014-04-08 11:07:47 +0100]: > I am not sure that it is appropriate that a netlink implementation, > which is the only way to do the enumeration correctly in the potential > absense of /proc, should go into Musl. I would be more inclined to one could just try all the numbers.. this "works" even at boot time :) (and there is /sys/class/net/*/ifindex but that does not help libc) #include <net/if.h> #include <stdlib.h> #include <errno.h> #define N 256 struct if_nameindex *if_nameindex() { struct if_nameindex *p = malloc(N*sizeof*p + N*IF_NAMESIZE); if (!p) errno = ENOBUFS; else { char (*name)[IF_NAMESIZE] = (void*)(p+N); int i,j; for (i=1,j=0; i<N; i++) if (if_indextoname(i, name[j])) { p[j].if_name = name[j]; p[j].if_index = i; j++; } p[j].if_name = 0; p[j].if_index = 0; } return p; } > However I can see no reason why dhcp on a specified interface needs to > enumerate interfaces at all, and it only needs to read ipv4 addresses, > unless it is implementing dhcp6 too, maybe it does now. Again dhcp6 > needs netlink, the Musl ipv6 parts for getifaddrs already use /proc > which is definitely unreliable for early boot config in a distro in my > view. if ipv6 things require netlink anyway then probably musl does not have much choice..
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.