Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Oct 2016 08:03:48 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r307201 - stable/10/sys/dev/hyperv/utilities
Message-ID:  <201610130803.u9D83mTI030786@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Thu Oct 13 08:03:48 2016
New Revision: 307201
URL: https://svnweb.freebsd.org/changeset/base/307201

Log:
  MFC 305585
  
      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
      Sponsored by:   Microsoft
      Differential Revision:  https://reviews.freebsd.org/D7809

Modified:
  stable/10/sys/dev/hyperv/utilities/hv_kvp.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c
==============================================================================
--- stable/10/sys/dev/hyperv/utilities/hv_kvp.c	Thu Oct 13 08:01:38 2016	(r307200)
+++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c	Thu Oct 13 08:03:48 2016	(r307201)
@@ -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?201610130803.u9D83mTI030786>