From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5205 Path: news.gmane.org!not-for-mail From: Justin Cormack Newsgroups: gmane.linux.lib.musl.general Subject: Re: if_nameindex and getifaddrs Date: Sun, 8 Jun 2014 11:03:17 +0100 Message-ID: References: <20140607231820.GA12864@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1402221868 21884 80.91.229.3 (8 Jun 2014 10:04:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Jun 2014 10:04:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5210-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jun 08 12:04:20 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WtZxc-0002tT-4T for gllmg-musl@plane.gmane.org; Sun, 08 Jun 2014 12:04:20 +0200 Original-Received: (qmail 30176 invoked by uid 550); 8 Jun 2014 10:04:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30010 invoked from network); 8 Jun 2014 10:03:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=specialbusservice.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=F3JgQG14+BpV9me0WStpWOLj90V66XcPtU24IntZ7nU=; b=nLeMai+dd6utgSxMTtNvuYM3oN60MZyT/2t0dVMlsKqn1ttiwgxiI3gM/IzQTY9Olh /W0igG3udLMwbBE6v93WMcQfyzctZbF3YoqEI2i0KNNq2qDLRs4rREB55Uy/mN/b4/Qi BkhP12gFgNay3ufnf+IDoGucoezyWEQ+hJHuU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=F3JgQG14+BpV9me0WStpWOLj90V66XcPtU24IntZ7nU=; b=c8XmDUhZYRzQOkFDNQa3hQls1MhDt2+MlARRbxbxdtUzsLIWpAAhXfcSaOGLe4Kr3R i95dqepBQ9De0ryq23G3BKHIT8z0N/lCkGlleapm4CV51blA7zyeKJ/q4WlXQMGtw5zW EsJsQnsN5X3CKs34rhE4JD9o60/ELKCr4vO8K/QNIN49aUtiIi2UlLyvlaXfWRrLgQ7c 1etjXomIBowjZp5l+rC++C/wD6gB4zv4nNasb2coVTmsKYelI6xjAY7fpaePF55Gpo2h C+fQQiC4LgrAmn9qO6SwmX4KHy/tZGokwSehFoKOrxLncGqKg3aHZo2/MNdt0ZX9bOAZ 1IcQ== X-Gm-Message-State: ALoCoQkG+10nlzWLKesl20UIjZR5pceU8/aSzFGIULhNU7ybtKK6PM4AXp9s/h1+s83iWPLgc8BU X-Received: by 10.152.203.236 with SMTP id kt12mr12027644lac.8.1402221797404; Sun, 08 Jun 2014 03:03:17 -0700 (PDT) In-Reply-To: <20140607231820.GA12864@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:5205 Archived-At: On Sun, Jun 8, 2014 at 12:18 AM, Rich Felker wrote: > However, there's been some concern that this code would not work for > users who are using musl on non-Linux kernels with a Linux syscall API > but not a netlink API (e.g. BSD Linux 'emulation'), and it's probably > also somewhat larger and less efficient with memory than it needs to > be. > > Getting the full list of interfaces is definitely possible without > netlink: /proc/net/dev has all the real interface names and they're > trivial to parse without any fancy parser code. The list does not > contain legacy-style aliases (e.g. eth0:2) but these can be obtained > from SIOCGIFCONF if desired (as they are now). As far as I can tell, > legacy aliases are purely associated with a configured IPv4 address. > They simply do not exist with IPv6 interfaces or in an unconfigured > state (and they shate their interface index number with the underlying > base interface). So this method of listing interfaces would be > complete. > > Of course I'm not convinced (despite the fact that I rather dislike > netlink) that it's any better than using netlink. It may at least > partially work on BSD via SIOCGIFCONF -- it seems (some?) BSD's might > support SIOCGIFCONF even for IPv6, but I'm not even clear if the ioctl > interface is really compatible or not. > > If if_nameindex produced a complete list with unconfigured and v6-only > interfaces included (by whatever means) then the current getifaddrs > implementation would "work" in the sense of not omitting interfaces, > but it still might not produce as much output as some users want. > > The above is a summary of my understanding of the situation and some > possible ways forward. I'd welcome some comments, particularly on > anything that would help us keep/improve BSD compatibility alongside > fixing the issues on Linux. I only know a bit about the NetBSD Linux emulation, as I help out the main developer with testing. It is currently not very complete in the networking areas, but there are tests for some of it, and they will be added eventually. Currently there isn't /proc/net/dev emulation in the Linux /proc emulation. Not sure how complete the ioctl emulation is, but at least it is easier to add than netlink. The alias interfaces are another complexity, as I don;t think there has ever been an ipv4 alias equivalent in NetBSD so that would have to be emulated too. I think most of the work is on their side; I can go and eg add tests for all the ioctls in Musl. Justin