--- old/usr/src/lib/libzonecfg/common/libzonecfg.c	Wed Oct  5 00:33:26 2016
+++ new/usr/src/lib/libzonecfg/common/libzonecfg.c	Wed Oct  5 00:33:26 2016
@@ -22,8 +22,8 @@
 /*
  * Copyright 2014 Gary Mills
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Joyent Inc.
  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2015 Joyent Inc.
  */
 
 #include <libsysevent.h>
@@ -191,7 +191,6 @@
 	{ALIAS_SHARES, "zone.cpu-shares", "privileged", "none", 0},
 	{ALIAS_CPUCAP, "zone.cpu-cap", "privileged", "deny", 0},
 	{ALIAS_MAXPROCS, "zone.max-processes", "privileged", "deny", 100},
-	{ALIAS_ZFSPRI, "zone.zfs-io-priority", "privileged", "none", 0},
 	{NULL, NULL, NULL, NULL, 0}
 };
 
@@ -239,8 +238,6 @@
 static char zoneadm_lock_held[] = LOCK_ENV_VAR"=1";
 static char zoneadm_lock_not_held[] = LOCK_ENV_VAR"=0";
 
-static void zonecfg_notify_delete(const char *);
-
 char *zonecfg_root = "";
 
 /*
@@ -430,10 +427,8 @@
 	 * Treat failure to find the XML file silently, since, well, it's
 	 * gone, and with the index file cleaned up, we're done.
 	 */
-	if (err == Z_OK || err == Z_NO_ZONE) {
-		zonecfg_notify_delete(zonename);
+	if (err == Z_OK || err == Z_NO_ZONE)
 		return (Z_OK);
-	}
 	return (err);
 }
 
@@ -1130,7 +1125,7 @@
  * In general, the operation of this function should succeed or fail as
  * a unit.
  */
-static int
+int
 zonecfg_refresh_index_file(zone_dochandle_t handle)
 {
 	char name[ZONENAME_MAX], zonepath[MAXPATHLEN];
@@ -1152,15 +1147,6 @@
 	(void) strlcpy(ze.zone_path, zonepath + strlen(zonecfg_root),
 	    sizeof (ze.zone_path));
 
-	if ((err = zonecfg_get_brand(handle, ze.zone_brand,
-	    sizeof (ze.zone_brand))) != 0)
-		return (err);
-
-	if ((err = zonecfg_get_iptype(handle, &ze.zone_iptype)) != Z_OK)
-		return (err);
-
-	ze.zone_did = zonecfg_get_did(handle);
-
 	if (is_renaming(handle)) {
 		opcode = PZE_MODIFY;
 		(void) strlcpy(ze.zone_name, handle->zone_dh_delete_name,
@@ -1503,56 +1489,6 @@
 	}
 }
 
-static void
-zonecfg_notify_conf_change(const char *zname, char *os, char *ns)
-{
-	evchan_t *ze_chan;
-	struct timeval now;
-	uint64_t t;
-	nvlist_t *nvl = NULL;
-
-	if (sysevent_evc_bind(ZONE_EVENT_CHANNEL, &ze_chan, 0) != 0)
-		return;
-
-	/* Current time since Jan 1 1970 but consumers expect NS */
-	gettimeofday(&now, NULL);
-	t = (now.tv_sec * NANOSEC) + (now.tv_usec * 1000);
-
-	if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_NAME, zname) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_NEWSTATE, ns) == 0 &&
-	    nvlist_add_string(nvl, ZONE_CB_OLDSTATE, os) == 0 &&
-	    nvlist_add_int32(nvl, ZONE_CB_ZONEID, -1) == 0 &&
-	    nvlist_add_uint64(nvl, ZONE_CB_TIMESTAMP, t) == 0) {
-		(void) sysevent_evc_publish(ze_chan, ZONE_EVENT_STATUS_CLASS,
-		    ZONE_EVENT_STATUS_SUBCLASS, "sun.com", "zonecfg", nvl,
-		    EVCH_SLEEP);
-	}
-
-	nvlist_free(nvl);
-	(void) sysevent_evc_unbind(ze_chan);
-}
-
-void
-zonecfg_notify_create(zone_dochandle_t handle)
-{
-	char zname[ZONENAME_MAX];
-
-	if (zonecfg_check_handle(handle) != Z_OK)
-		return;
-
-	if (zonecfg_get_name(handle, zname, sizeof (zname)) != Z_OK)
-		return;
-
-	zonecfg_notify_conf_change(zname, "", ZONE_STATE_STR_CONFIGURED);
-}
-
-static void
-zonecfg_notify_delete(const char *zname)
-{
-	zonecfg_notify_conf_change(zname, ZONE_STATE_STR_CONFIGURED, "");
-}
-
 /*
  * Special case: if access(2) fails with ENOENT, then try again using
  * ZONE_CONFIG_ROOT instead of config_file_path(zonename).  This is how we
@@ -2143,32 +2079,6 @@
 }
 
 /*
- * Turn an addr that looks like f:2:0:44:5:6C into 0f:02:00:44:05:6c
- * We're expecting a dst of at least MAXMACADDRLEN size here.
- */
-static void
-normalize_mac_addr(char *dst, const char *src, int len)
-{
-	char *p, *e, *sep = "";
-	long n;
-	char buf[MAXMACADDRLEN], tmp[4];
-
-	*dst = '\0';
-	(void) strlcpy(buf, src, sizeof (buf));
-	p = strtok(buf, ":");
-	while (p != NULL) {
-		n = strtol(p, &e, 16);
-		if (*e != NULL || n > 0xff)
-			return;
-		(void) snprintf(tmp, sizeof (tmp), "%s%02x", sep, n);
-		(void) strlcat(dst, tmp, len);
-
-		sep = ":";
-		p = strtok(NULL, ":");
-	}
-}
-
-/*
  * Determines whether there is a net resource with the physical interface, IP
  * address, and default router specified by 'tabptr' in the zone configuration
  * to which 'handle' refers.  'tabptr' must have an interface, an address, a
@@ -2193,7 +2103,6 @@
 	char address[INET6_ADDRSTRLEN];
 	char physical[LIFNAMSIZ];
 	char mac[MAXMACADDRLEN];
-	char norm_mac[MAXMACADDRLEN];
 	char gnic[LIFNAMSIZ];
 	size_t addrspec;		/* nonzero if tabptr has IP addr */
 	size_t physspec;		/* nonzero if tabptr has interface */
@@ -2250,14 +2159,10 @@
 		    physical, sizeof (physical)) != Z_OK ||
 		    strcmp(tabptr->zone_nwif_physical, physical) != 0))
 			continue;
-		if (iptype == ZS_EXCLUSIVE && macspec != 0) {
-			if (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) !=
-			    Z_OK)
-				continue;
-			normalize_mac_addr(norm_mac, mac, sizeof (norm_mac));
-			if (strcmp(tabptr->zone_nwif_mac, norm_mac) != 0)
-				continue;
-		}
+		if (iptype == ZS_EXCLUSIVE && macspec != 0 &&
+		    (fetchprop(cur, DTD_ATTR_MAC, mac, sizeof (mac)) != Z_OK ||
+		    strcmp(tabptr->zone_nwif_mac, mac) != 0))
+			continue;
 		if (iptype == ZS_EXCLUSIVE && gnicspec != 0 &&
 		    (fetchprop(cur, DTD_ATTR_GNIC, gnic,
 		    sizeof (gnic)) != Z_OK ||
@@ -2455,7 +2360,7 @@
 		gnic_match = match_prop(cur, DTD_ATTR_GNIC,
 		    tabptr->zone_nwif_gnic);
 
-		if (((addr_match && allowed_addr_match) || mac_match ||
+		if ((addr_match || allowed_addr_match || mac_match ||
 		    gnic_match) && phys_match) {
 			xmlUnlinkNode(cur);
 			xmlFreeNode(cur);
@@ -4867,7 +4772,7 @@
 	pool_conf_t *poolconf;
 	pool_t *pool;
 	pool_elem_t *pe;
-	pool_value_t *pv;
+	pool_value_t *pv = pool_value_alloc();
 	const char *sched_str;
 
 	if (pool_get_status(&status) != PO_SUCCESS || status != POOL_ENABLED)
@@ -4888,23 +4793,15 @@
 		return (Z_NO_POOL);
 	}
 
-	if ((pv = pool_value_alloc()) == NULL) {
-		(void) pool_conf_close(poolconf);
-		pool_conf_free(poolconf);
-		return (Z_NO_POOL);
-	}
-
 	pe = pool_to_elem(poolconf, pool);
 	if (pool_get_property(poolconf, pe, "pool.scheduler", pv) !=
 	    POC_STRING) {
 		(void) pool_conf_close(poolconf);
-		pool_value_free(pv);
 		pool_conf_free(poolconf);
 		return (Z_NO_ENTRY);
 	}
 	(void) pool_value_get_string(pv, &sched_str);
 	(void) pool_conf_close(poolconf);
-	pool_value_free(pv);
 	pool_conf_free(poolconf);
 	if (strlcpy(class, sched_str, clsize) >= clsize)
 		return (Z_TOO_BIG);
@@ -6174,27 +6071,16 @@
 zone_set_state(char *zone, zone_state_t state)
 {
 	struct zoneent ze;
-	int res;
-	zone_state_t oldst = (zone_state_t)-1;
 
 	if (state != ZONE_STATE_CONFIGURED && state != ZONE_STATE_INSTALLED &&
 	    state != ZONE_STATE_INCOMPLETE)
 		return (Z_INVAL);
 
-	(void) zone_get_state(zone, &oldst);
-
 	bzero(&ze, sizeof (ze));
 	(void) strlcpy(ze.zone_name, zone, sizeof (ze.zone_name));
 	ze.zone_state = state;
 	(void) strlcpy(ze.zone_path, "", sizeof (ze.zone_path));
-	res = putzoneent(&ze, PZE_MODIFY);
-
-	if (res == Z_OK) {
-		zonecfg_notify_conf_change(zone, zone_state_str(oldst),
-		    zone_state_str(state));
-	}
-
-	return (res);
+	return (putzoneent(&ze, PZE_MODIFY));
 }
 
 /*
@@ -6343,30 +6229,6 @@
 	}
 }
 
-/*
- * Changes a zone's UUID to the given value. Returns an error if the UUID is
- * malformed or if the zone cannot be located.
- */
-int
-zonecfg_set_uuid(const char *zonename, const char *zonepath,
-    const char *uuid)
-{
-	int err;
-	struct zoneent ze;
-
-	bzero(&ze, sizeof (ze));
-	ze.zone_state = -1;	/* Preserve existing state in index */
-	(void) strlcpy(ze.zone_name, zonename, sizeof (ze.zone_name));
-	(void) strlcpy(ze.zone_path, zonepath, sizeof (ze.zone_path));
-	if (uuid_parse((char *)uuid, ze.zone_uuid) == -1)
-		return (Z_INVALID_PROPERTY);
-
-	if ((err = putzoneent(&ze, PZE_MODIFY)) != Z_OK)
-		return (err);
-
-	return (Z_OK);
-}
-
 /*
  * File-system convenience functions.
  */
