From 363b7d88f6832d32cc7e29d05598472c370a2d85 Mon Sep 17 00:00:00 2001
From: Sepherosa Ziehau <sephe@FreeBSD.org>
Date: Mon, 19 Sep 2016 07:07:23 +0000
Subject: [PATCH] hyperv/hn: Don't allow NVS and NDIS version change upon
 reinitailization

NVS and NDIS version change would break too much assumption and static
configuration.

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7919
---
 sys/dev/hyperv/netvsc/hv_net_vsc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sys/dev/hyperv/netvsc/hv_net_vsc.c b/sys/dev/hyperv/netvsc/hv_net_vsc.c
index a64eb6227faa..204017f38281 100644
--- a/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ b/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -495,6 +495,22 @@ hn_nvs_init(struct hn_softc *sc)
 {
 	int i;
 
+	if (device_is_attached(sc->hn_dev)) {
+		/*
+		 * NVS version and NDIS version MUST NOT be changed.
+		 */
+		if (bootverbose) {
+			if_printf(sc->hn_ifp, "reinit NVS version 0x%x, "
+			    "NDIS version %u.%u\n", sc->hn_nvs_ver,
+			    HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver),
+			    HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver));
+		}
+		return (hn_nvs_doinit(sc, sc->hn_nvs_ver));
+	}
+
+	/*
+	 * Find the supported NVS version and set NDIS version accordingly.
+	 */
 	for (i = 0; i < nitems(hn_nvs_version); ++i) {
 		int error;