Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Oct 2016 08:23:30 +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-11@freebsd.org
Subject:   svn commit: r307503 - stable/11/sys/dev/hyperv/utilities
Message-ID:  <201610170823.u9H8NUHt033179@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Mon Oct 17 08:23:30 2016
New Revision: 307503
URL: https://svnweb.freebsd.org/changeset/base/307503

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/11/sys/dev/hyperv/utilities/hv_kvp.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/hyperv/utilities/hv_kvp.c
==============================================================================
--- stable/11/sys/dev/hyperv/utilities/hv_kvp.c	Mon Oct 17 08:20:17 2016	(r307502)
+++ stable/11/sys/dev/hyperv/utilities/hv_kvp.c	Mon Oct 17 08:23:30 2016	(r307503)
@@ -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?201610170823.u9H8NUHt033179>