qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Patch for qemu-0.9.1/slirp/misc.c:getouraddr


From: Wan-Teh Chang
Subject: Re: [Qemu-devel] Patch for qemu-0.9.1/slirp/misc.c:getouraddr
Date: Mon, 10 Nov 2008 10:04:12 -0800

On Sun, Nov 9, 2008 at 3:43 AM, Blue Swirl <address@hidden> wrote:
> On 11/7/08, Wan-Teh Chang <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]