mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Reviewing if_nameindex and getifaddrs patch
Date: Tue, 29 Jul 2014 10:34:54 -0400	[thread overview]
Message-ID: <20140729143454.GH1674@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140728111327.658049f2@vostro>

On Mon, Jul 28, 2014 at 11:13:27AM +0300, Timo Teras wrote:
> > I really don't understand the 'hash' logic for getifaddrs yet, but the
> > function seems to work. Some general description of what data the
> > callback receives and what it's doing with it could be helpful for
> > reviewing this part of the patch.
> 
> The rtnetlink enumerate does two netlink 'dumps'. One of 'link' type
> that dumps the physical interfaces, and one of 'addr' type that lists
> all network addresses.
> 
> The 'link' dump is used to get the PF_PACKET ifaddrs with mac
> addresses, as well as to get the ifindex<->ifname mappings and the
> logical flags of each physical interface (SIOCGIFFLAGS equivalent).
> These put into the hash based on ifindex.
> 
> The 'addr' dump then does the ipv4/ipv6 address (easy to extend if we
> need to support something new in future). These lookup the physical
> 'link' info using ifindex. This is needed to fill ifa_flags with valid
> data. It is also used to lookup the interface in non-ipv4 case. (In
> ipv4 case it seems that kernel always sends IFA_LABEL containing the
> real or aliased interface name. Though this probably might change if
> the alias interface system is removed at some point.)

I see. One random thought I had, since you're merging information from
two sources: is there any atomicity guarantee here, or is it possible
that interfaces have changed between the link and addr dumps? I don't
think issues like this should block getting it committed since it's at
least better than what we have now with respect to atomicity, but I
noticed the unused NLM_F_ATOMIC flag and wonder if that could be used
to perform both requests atomically (if they're not already atomic).

Aside from that I'm going to apply the patch again, look at the
resulting code, and make sure I don't see anything else that needs to
be fixed. If it looks ok, I'll go ahead and apply it.

Rich


  reply	other threads:[~2014-07-29 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28  0:49 Rich Felker
2014-07-28  8:13 ` Timo Teras
2014-07-29 14:34   ` Rich Felker [this message]
2014-07-29 14:49   ` Rich Felker
2014-07-30  0:55     ` Rich Felker
2014-07-30  0:58       ` Rich Felker

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=20140729143454.GH1674@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).