From bdcc0b84ed75787006794fb6c98f8f0b1a78a67f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 2 Dec 2010 11:39:15 +0000 Subject: [PATCH] * net.cc (get_xp_ifs): Fix counting of idx to return stable interface alias names for interfaces with multiple IPv4 addresses. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/net.cc | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5fcd5b8c9..90b2fd863 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2010-12-02 Corinna Vinschen + + * net.cc (get_xp_ifs): Fix counting of idx to return stable interface + alias names for interfaces with multiple IPv4 addresses. + 2010-11-29 Corinna Vinschen * fhandler_tty.cc (fhandler_tty_slave::dup): Free path_conv strings diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index aa56ad423..e6d9638c8 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1907,8 +1907,7 @@ get_xp_ifs (ULONG family) ++ifp; } else - for (idx = 0, pua = pap->FirstUnicastAddress; pua; - ++idx, pua = pua->Next) + for (idx = 0, pua = pap->FirstUnicastAddress; pua; pua = pua->Next) { struct sockaddr *sa = (struct sockaddr *) pua->Address.lpSockaddr; # define sin ((struct sockaddr_in *) sa) @@ -1918,10 +1917,12 @@ get_xp_ifs (ULONG family) /* Next in chain */ ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa; /* Interface name */ - if (idx && sa->sa_family == AF_INET) + if (sa->sa_family == AF_INET && idx) __small_sprintf (ifp->ifa_name, "%s:%u", pap->AdapterName, idx); else strcpy (ifp->ifa_name, pap->AdapterName); + if (sa->sa_family == AF_INET) + ++idx; ifp->ifa_ifa.ifa_name = ifp->ifa_name; /* Flags */ ifp->ifa_ifa.ifa_flags = get_flags (pap);