On Friday, November 27, 2015, Jamie Taylor <Jamie.Taylor@pobox.com> wrote:
On Thu, Nov 26, 2015 at 08:11:20PM +0800, Bruno Jesus wrote:
> Hi, Jamie and Joachim and list. This is a short version of a long
> patch I'm working on, it orders the IP list with the default routes on
> top and it supports more than one default route. It fixes the problem
> on Linux and FreeBSD, could anyone also test it on OSX, please?

I am away from my test setup until next week due to the Thanksgiving
holiday in the USA, but I will do a test on OSX when I get back to it,
unless someone else has already reported results.  Based on my reading
of the patch, I expect it will work to solve the problem of the magic
loopback address being returned as the first entry.

Thanks for the feedback. I'll wait your or someone else tests.
 
Based on the results of the tests that Joachim shared with us,
I suspect a more correct approach (i.e., one that more closely matches
the results from Windows) may involve using GetIpAddrTable rather
than iterating over the IP forwarding table (except to figure out which
are the default routes) or using GetAdaptersInfo.  Of course, the wine
implementation of GetIpAddrTable may also not match the behavior of
Windows when there are no adapters configured, but that may be a
problem whether or not WS_get_local_ips works correctly.
(I recognize that you are working on a larger patch which may address
this concern.)

The complete version of the patch solves the loopback issues by ignoring the loopback routes. The loopback is only added if it is the only IP found as in Windows.
 
Oh, and as for the reason the magic loopback address exists in the first
place, the best information that I could find was this thread on the list
from 2008, regarding the patch where it was introduced:
https://www.winehq.org/pipermail/wine-devel/2008-April/064835.html
and specifically this post:
https://www.winehq.org/pipermail/wine-devel/2008-April/064850.html


But now we won't return the loopback anymore so the first IP returned will be a valid network IP so this will no longer be necessary as far as I can see.

Hope this helps,
Jamie

Best wishes, 
Bruno