[PATCH v4 0/1] MR10553: iphlpapi: Prefer adapters with valid MAC in GetAdaptersInfo.
### What this changes - Adds a MAC validity predicate for adapter entries. - In GetAdaptersInfo, counts adapters with valid physical MAC. - If valid adapters exist, excludes entries with invalid MAC from returned list. ### Why On macOS, pseudo interfaces without usable physical address can appear before real hardware adapters. Legacy clients that pick the first adapter may send empty MAC and fail auth. ### Scope - Module: iphlpapi - API path: GetAdaptersInfo - Platform impact: mainly macOS-like interface layouts with pseudo/tunnel adapters exposed early. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59614 -- v4: nsiproxy.sys: Filter legacy macOS gif/stf interfaces from table. https://gitlab.winehq.org/wine/wine/-/merge_requests/10553
From: Nikolai Abdusamatov <nick.luft.work@gmail.com> On macOS, gif0 (IFT_GIF) and stf0 (IFT_STF) are legacy IPv4/IPv6 transition tunnel interfaces with no direct Windows equivalent. Windows deprecated and disabled analogous adapters. Their presence inflates the NSI adapter table and exposes macOS-specific interfaces to Windows applications. Use getifaddrs()/AF_LINK to identify BSD interface types without relying on interface names. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59614 --- dlls/nsiproxy.sys/ndis.c | 57 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/dlls/nsiproxy.sys/ndis.c b/dlls/nsiproxy.sys/ndis.c index 8c15186ed53..f9e47e580f3 100644 --- a/dlls/nsiproxy.sys/ndis.c +++ b/dlls/nsiproxy.sys/ndis.c @@ -30,6 +30,10 @@ #include <sys/ioctl.h> #include <unistd.h> +#ifdef HAVE_IFADDRS_H +#include <ifaddrs.h> +#endif + #ifdef HAVE_NET_IF_H #include <net/if.h> #endif @@ -66,6 +70,10 @@ #include <linux/wireless.h> #endif +#if defined(HAVE_IFADDRS_H) && defined(HAVE_NET_IF_DL_H) && defined(HAVE_NET_IF_TYPES_H) +#define HAVE_BSD_IF_INFO 1 +#endif + #include <pthread.h> #include "ntstatus.h" @@ -274,11 +282,43 @@ static WCHAR *strdupAtoW( const char *str ) return ret; } -static struct if_entry *add_entry( UINT index, char *name ) +#ifdef HAVE_BSD_IF_INFO +static void if_get_bsd_info( const struct ifaddrs *ifaddrs, const char *name, UINT *bsd_type ) +{ + const struct ifaddrs *entry; + + *bsd_type = 0; + if (!ifaddrs) return; + + for (entry = ifaddrs; entry; entry = entry->ifa_next) + { + if (!entry->ifa_name || strcmp( entry->ifa_name, name )) continue; + if (!entry->ifa_addr || entry->ifa_addr->sa_family != AF_LINK) continue; + *bsd_type = ((const struct sockaddr_dl *)entry->ifa_addr)->sdl_type; + return; + } +} + +static BOOL if_should_skip( UINT bsd_type ) +{ + if (bsd_type == IFT_GIF || bsd_type == IFT_STF) return TRUE; + + return FALSE; +} +#else +static BOOL if_should_skip( UINT bsd_type ) +{ + (void)bsd_type; + return FALSE; +} +#endif + +static struct if_entry *add_entry( UINT index, char *name, UINT bsd_type ) { struct if_entry *entry; int name_len = strlen( name ); + if (if_should_skip( bsd_type )) return NULL; if (name_len >= sizeof(entry->if_unix_name)) return NULL; entry = malloc( sizeof(*entry) ); if (!entry) return NULL; @@ -310,13 +350,26 @@ static unsigned int update_if_table( void ) { struct if_nameindex *indices = if_nameindex(), *entry; unsigned int append_count = 0; +#ifdef HAVE_BSD_IF_INFO + struct ifaddrs *ifaddrs = NULL; + if (getifaddrs( &ifaddrs ) != 0) ifaddrs = NULL; +#endif for (entry = indices; entry->if_index; entry++) { - if (!find_entry_from_index( entry->if_index ) && add_entry( entry->if_index, entry->if_name )) + UINT bsd_type; + bsd_type = 0; +#ifdef HAVE_BSD_IF_INFO + if_get_bsd_info( ifaddrs, entry->if_name, &bsd_type ); +#endif + if (!find_entry_from_index( entry->if_index ) && add_entry( entry->if_index, entry->if_name, bsd_type )) ++append_count; } +#ifdef HAVE_BSD_IF_INFO + if (ifaddrs) freeifaddrs( ifaddrs ); +#endif + if_freenameindex( indices ); return append_count; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10553
On Sun Apr 12 23:58:40 2026 +0000, Paul Gofman wrote:
Yes, sorry, I was unclear, I don't know that these Mac specific interfaces need to be exposed in Wine, I only questioned that IFF_POINTOPOINT should be stripped off (surely not on Linux). That is what you suggest as well. Thanks to everyone for your detailed feedback and suggestions. I've updated the patch based on them - I hope I got it right. The game still loads correctly, and the buffer size doesn't exceed the client’s limit.
I've also attached the latest logs, including a comparison with the previous version. [analysis_summary.txt](/uploads/68d89f1348ab9b257566b116cddaf80d/analysis_summary.txt) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10553#note_136157
participants (2)
-
Nikolai Abdusamatov -
Nikolai Abdusamatov (@n-abdusamatov)