qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wan-Teh Chang <wtc@google.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Patch for qemu-0.9.1/slirp/misc.c:getouraddr
Date: Mon, 10 Nov 2008 10:04:12 -0800	[thread overview]
Message-ID: <e8c553a60811101004q700d833fl311db99f588e31d4@mail.gmail.com> (raw)
In-Reply-To: <f43fc5580811090343j31313f2bue8c1dc8a1d3c5d93@mail.gmail.com>

On Sun, Nov 9, 2008 at 3:43 AM, Blue Swirl <blauwirbel@gmail.com> wrote:
> On 11/7/08, Wan-Teh Chang <wtc@google.com> wrote:
>> Attached is a patch for qemu-0.9.1/slirp/misc.c to implement
>>  the getouraddr() function using the BSD function getifaddrs(),
>>  which is also available in glibc on Linux.
>
> How is this better than the current way? Does this change something on
> hosts with multiple interfaces? What if some interfaces are down?

The current way gets the local host's IP addresses by calling
gethostbyname, which is usually implemented with a DNS
lookup.  So the current way usually requires a network request,
and it cannot get the IP addresses of a host that doesn't have
a name.

On hosts with multiple interfaces, the patch may change the
order in which the addresses are listed.  Since both the current
way and the patch just take the first (non-loopback) address
on the list, the patch could change the address chosen by
getouraddr.

If some interfaces are down, I believe the current way can't
detect that, whereas this patch can be enhanced to detect
that.  I believe that we can test the ifa_flags field of the
ifaddrs structure to see if the IFF_UP flag (or the
IFF_RUNNING flag?) is set.

Wan-Teh Chang

      reply	other threads:[~2008-11-10 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-07 18:42 [Qemu-devel] Patch for qemu-0.9.1/slirp/misc.c:getouraddr Wan-Teh Chang
2008-11-09 11:43 ` Blue Swirl
2008-11-10 18:04   ` Wan-Teh Chang [this message]

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=e8c553a60811101004q700d833fl311db99f588e31d4@mail.gmail.com \
    --to=wtc@google.com \
    --cc=qemu-devel@nongnu.org \
    /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.
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).