提交 3321e738 编写于 作者: K K. Y. Srinivasan 提交者: Greg Kroah-Hartman

Tools: hv: Don't return loopback addresses

Don't return loopback addresses and further don't terminate
the IP address strings with a semicolon. This is the current
behavior of Windows guests.
Signed-off-by: NK. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: NHaiyang Zhang <haiyangz@microsoft.com>
Reported-by: NClaudio Latini <claudio.latini@live.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 f426a36c
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <net/if.h>
/* /*
* KVP protocol: The user mode component first registers with the * KVP protocol: The user mode component first registers with the
...@@ -882,7 +883,7 @@ static int kvp_process_ip_address(void *addrp, ...@@ -882,7 +883,7 @@ static int kvp_process_ip_address(void *addrp,
addr_length = INET6_ADDRSTRLEN; addr_length = INET6_ADDRSTRLEN;
} }
if ((length - *offset) < addr_length + 1) if ((length - *offset) < addr_length + 2)
return HV_E_FAIL; return HV_E_FAIL;
if (str == NULL) { if (str == NULL) {
strcpy(buffer, "inet_ntop failed\n"); strcpy(buffer, "inet_ntop failed\n");
...@@ -890,11 +891,13 @@ static int kvp_process_ip_address(void *addrp, ...@@ -890,11 +891,13 @@ static int kvp_process_ip_address(void *addrp,
} }
if (*offset == 0) if (*offset == 0)
strcpy(buffer, tmp); strcpy(buffer, tmp);
else else {
strcat(buffer, ";");
strcat(buffer, tmp); strcat(buffer, tmp);
strcat(buffer, ";"); }
*offset += strlen(str) + 1; *offset += strlen(str) + 1;
return 0; return 0;
} }
...@@ -956,7 +959,9 @@ kvp_get_ip_info(int family, char *if_name, int op, ...@@ -956,7 +959,9 @@ kvp_get_ip_info(int family, char *if_name, int op,
* supported address families; if not we gather info on * supported address families; if not we gather info on
* the specified address family. * the specified address family.
*/ */
if ((family != 0) && (curp->ifa_addr->sa_family != family)) { if ((((family != 0) &&
(curp->ifa_addr->sa_family != family))) ||
(curp->ifa_flags & IFF_LOOPBACK)) {
curp = curp->ifa_next; curp = curp->ifa_next;
continue; continue;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册