mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Natanael Copa <ncopa@alpinelinux.org>
To: musl@lists.openwall.com
Cc: dalias@aerifal.cx, justin@specialbusservice.com
Subject: Re: if_nameindex/getifaddrs and dhcpcd issue
Date: Wed, 9 Apr 2014 09:55:56 +0200	[thread overview]
Message-ID: <20140409095556.701e0363@ncopa-desktop.alpinelinux.org> (raw)
In-Reply-To: <20140408154537.GG26358@brightrain.aerifal.cx>

On Tue, 8 Apr 2014 11:45:37 -0400
Rich Felker <dalias@aerifal.cx> wrote:

> > We should not be looking at dhcpd. It's the APIs musl implements:
> > getifaddrs() and if_nameindex() - they are not currently exposing all
> > the information they should.
> 
> One can argue about what if_nameindex should expose;

Yes. This is the real issue at hand. What dhcpcd does is not that
relevant here.

> for instance,
> should it expose all possible interface names the kernel could
> support, even with modules that haven't been loaded yet?

IMHO, no. I think it should only expose what you normally find
as /sys/class/net/* (you find same list in /proc/net/dev)

A use case if_nameindex() that I think would be valid is a network config ui.

Which interface do you want to configure? 
Presents a list of currently available network interfaces. (from if_nameindex)
It has a button 'Add virtual interface', which lets user configure
bonding/bridges/vlans etc.

(yes, no application should assume that the listed interface actually
works. I could select my USB ethernet dongle and before press 'ok' I
could pull out the USB ethernet...)

> The only
> thing a strictly conforming application can _DO_ with interface
> names/numbers is use them for link-local ipv6 scope ids (this is
> presumably why these functions were added to POSIX in the first
> place). So, from a conformance standpoint, only exposing ids that
> could actually appear on a link-local address (i.e. configured
> interfaces that have ipv6 link-local addresses) would be sufficient.

Then, from a conformance standpoint, the current musl if_nameindex
implementation is broken. It only lists interfaces with configured
ipv4 addresses.

To test yourself:

modprobe dummy
ip link set up dev dummy0
ip addr   #verify that dummy has ipv6 link-local

Then run the following testcase:

#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
    struct if_nameindex *if_ni, *i;

   if_ni = if_nameindex();
    if (if_ni == NULL) {
        perror("if_nameindex");
        exit(EXIT_FAILURE);
    }

   for (i = if_ni; ! (i->if_index == 0 && i->if_name == NULL); i++)
        printf("%u: %s\n", i->if_index, i->if_name);

   if_freenameindex(if_ni);

   exit(EXIT_SUCCESS);
}

The ipv6 link-local configured dummy0 interface will not be listed.



-nc


  parent reply	other threads:[~2014-04-09  7:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08  9:11 Natanael Copa
2014-04-08 10:07 ` Justin Cormack
2014-04-08 12:25   ` Timo Teras
2014-04-08 14:23     ` Natanael Copa
2014-04-08 15:45     ` Rich Felker
2014-04-08 16:08       ` Timo Teras
2014-04-08 16:19         ` Justin Cormack
2014-04-08 22:41           ` Rich Felker
2014-04-09  7:17             ` u-igbb
2014-04-09 22:20               ` Rich Felker
2014-04-09 22:32                 ` Justin Cormack
2014-04-10  7:40                 ` u-igbb
2014-04-10  7:52                   ` Rich Felker
2014-04-09 14:02         ` Timo Teras
2014-04-10  0:55           ` Rich Felker
2014-04-09  7:55       ` Natanael Copa [this message]
2014-04-08 12:54   ` Szabolcs Nagy
2014-04-08 13:42   ` Rich Felker
2014-04-08 14:16     ` Justin Cormack
2014-04-08 15:38       ` Rich Felker
2014-04-09  7:13         ` Natanael Copa
2014-04-09 22:18           ` Rich Felker
2014-04-08 21:16     ` Natanael Copa
2014-04-08 21:30       ` Justin Cormack
2014-04-08 22:59         ` Rich Felker
2014-04-08 14:27   ` Natanael Copa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140409095556.701e0363@ncopa-desktop.alpinelinux.org \
    --to=ncopa@alpinelinux.org \
    --cc=dalias@aerifal.cx \
    --cc=justin@specialbusservice.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).