Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Sep 2016 07:16:56 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305585 - head/sys/dev/hyperv/utilities
Message-ID:  <201609080716.u887GuLw008196@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Thu Sep  8 07:16:56 2016
New Revision: 305585
URL: https://svnweb.freebsd.org/changeset/base/305585

Log:
  hyperv/kvp: Fix IPv4/IPv6 address injection support.
  
  The GUID string provided by hypervisor has leading and trailing braces,
  while our GUID string does not have braces at all.  Both braces should
  be ignored, when the GUID strings are compared.
  
  Submitted by:	Hongjiang Zhang <honzhan microsoft com>
  Modified by:	sephe
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D7809

Modified:
  head/sys/dev/hyperv/utilities/hv_kvp.c

Modified: head/sys/dev/hyperv/utilities/hv_kvp.c
==============================================================================
--- head/sys/dev/hyperv/utilities/hv_kvp.c	Thu Sep  8 07:16:15 2016	(r305584)
+++ head/sys/dev/hyperv/utilities/hv_kvp.c	Thu Sep  8 07:16:56 2016	(r305585)
@@ -332,20 +332,23 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru
 
 	if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) {
 		for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) {
-			/* XXX access other driver's softc?  are you kidding? */
 			device_t dev = devs[devcnt];
 			struct vmbus_channel *chan;
 			char buf[HYPERV_GUID_STRLEN];
+			int n;
 
-			/*
-			 * Trying to find GUID of Network Device
-			 */
 			chan = vmbus_get_channel(dev);
-			hyperv_guid2str(vmbus_chan_guid_inst(chan),
-			    buf, sizeof(buf));
+			n = hyperv_guid2str(vmbus_chan_guid_inst(chan), buf,
+			    sizeof(buf));
 
-			if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id,
-			    HYPERV_GUID_STRLEN - 1) == 0) {
+			/*
+			 * The string in the 'kvp_ip_val.adapter_id' has
+			 * braces around the GUID; skip the leading brace
+			 * in 'kvp_ip_val.adapter_id'.
+			 */
+			if (strncmp(buf,
+			    ((char *)&umsg->body.kvp_ip_val.adapter_id) + 1,
+			    n) == 0) {
 				strlcpy((char *)umsg->body.kvp_ip_val.adapter_id,
 				    device_get_nameunit(dev), MAX_ADAPTER_ID_SIZE);
 				break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609080716.u887GuLw008196>