--- old/usr/src/cmd/mdb/Makefile.common	Mon Sep 16 13:28:50 2013
+++ new/usr/src/cmd/mdb/Makefile.common	Mon Sep 16 13:28:50 2013
@@ -19,11 +19,12 @@
 # CDDL HEADER END
 #
 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013 by Delphix. All rights reserved.
 #
 # MDB modules used for debugging user processes that every ISA's build
 # subdirectory will need to build.
 #
- 
+
 COMMON_MODULES_PROC = \
 	dof \
 	libavl \
@@ -67,6 +68,7 @@
 	ip \
 	ipc \
 	ipp \
+	klmmod \
 	krtld \
 	lofs \
 	logindmux \
--- /dev/null	Mon Sep 16 13:28:52 2013
+++ new/usr/src/cmd/mdb/common/modules/klmmod/nlm.c	Mon Sep 16 13:28:52 2013
@@ -0,0 +1,232 @@
+/*
+ * CDDL HEADER START
+ *
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include <mdb/mdb_ctf.h>
+#include <mdb/mdb_modapi.h>
+#include <mdb/mdb_ks.h>
+
+
+/*
+ * nlm_host dcmd implementation
+ */
+
+typedef struct mdb_sockaddr_in { /* IPv4 struct */
+	sa_family_t	sin_family;
+	struct {
+		union { /* MUST specify all fields in the union */
+			struct {
+				uint8_t s_b1;
+				uint8_t s_b2;
+				uint8_t s_b3;
+				uint8_t s_b4;
+			} S_un_b;
+			struct {
+				uint16_t s_w1;
+				uint16_t s_w2;
+			} S_un_w;
+			uint32_t S_addr;
+		} S_un;
+	} sin_addr;
+} mdb_sockaddr_in_t;
+
+typedef struct mdb_sockaddr_in6 { /* IPv6 struct */
+	in6_addr_t sin6_addr;
+} mdb_sockaddr_in6_t;
+
+typedef struct mdb_nlm_host {
+	uint_t		nh_refs;
+	uintptr_t	nh_name;
+	struct { /* struct netbuf in the os src code */
+		/*
+		 * ptr to struct sockaddr_in/mdb_sockaddr_in_t
+		 * or to struct sockaddr_in6/mdb_sockaddr_in6_t
+		 */
+		uintptr_t	buf;
+	} nh_addr;
+	sysid_t		nh_sysid;
+	uint8_t		nh_flags;
+} mdb_nlm_host_t;
+
+/*
+ * Output looks like:
+ * > ::nlm_host
+ * NLM_HOST         IP ADDR               HOST             REFCNT  SYSID  FLAGS
+ * ffffff01d80f7b48 172.16.203.114        delphix               0     14    0x5
+ * ffffff01d80f7968 fe80::dc:ff:fe01:fdbf charleston.talisker   0     31    0x5
+ */
+static int
+nlm_host_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+	mdb_nlm_host_t nlm_host;
+	char nh_name[1024];
+	mdb_sockaddr_in_t sockaddr;
+	mdb_sockaddr_in6_t sockaddr6;
+	boolean_t ipv4;
+
+	if (argc != 0) {
+		return (DCMD_USAGE);
+	}
+
+	if (!(flags & DCMD_ADDRSPEC)) {
+		if (mdb_walk_dcmd("nlm_host", "nlm_host", argc, argv) == -1) {
+			mdb_warn("can't walk all nlm_hosts");
+			return (DCMD_ERR);
+		}
+		return (DCMD_OK);
+	}
+
+
+	if (mdb_ctf_vread(&nlm_host, "struct nlm_host", "mdb_nlm_host_t",
+	    addr, 0) == -1) {
+		return (DCMD_ERR);
+	}
+
+	if (mdb_readstr(nh_name, sizeof (nh_name), nlm_host.nh_name) == -1) {
+		mdb_warn("failed to read nh_name at %p\n", nlm_host.nh_name);
+		(void) strcpy(nh_name, "<unknown>");
+	}
+
+	/*
+	 * We expect to primarily encounter IPv4 addresses, so use an IPv4
+	 * struct for the initial read.
+	 */
+	if (mdb_ctf_vread(&sockaddr, "struct sockaddr_in", "mdb_sockaddr_in_t",
+	    nlm_host.nh_addr.buf, 0) == -1) {
+		return (DCMD_ERR);
+	}
+	if (sockaddr.sin_family == AF_INET) { /* IPv4 */
+		ipv4 = B_TRUE;
+	} else { /* AF_INET6 == IPv6 */
+		ipv4 = B_FALSE;
+		if (mdb_ctf_vread(&sockaddr6, "struct sockaddr_in6",
+		    "mdb_sockaddr_in6_t", nlm_host.nh_addr.buf, 0) == -1) {
+			return (DCMD_ERR);
+		}
+	}
+
+	if (DCMD_HDRSPEC(flags)) {
+		mdb_printf("%<u>%-16s %-24s %-16s %6s %6s %6s%</u>\n",
+		    "NLM_HOST", "IP ADDR", "HOST", "REFCNT",
+		    "SYSID", "FLAGS");
+	}
+
+	mdb_printf("%-16p ", addr);
+	if (ipv4) {
+		mdb_printf("%-24I", sockaddr.sin_addr.S_un.S_addr);
+	} else {
+		mdb_printf("%-24N", &sockaddr6.sin6_addr);
+	}
+	mdb_printf(" %-20s %2u %6u %6#x\n",
+	    nh_name, nlm_host.nh_refs, nlm_host.nh_sysid, nlm_host.nh_flags);
+
+	return (DCMD_OK);
+}
+
+/*
+ * nlm_host walker implementation
+ */
+
+typedef struct mdb_nlm_globals_list {
+	uintptr_t tqh_first; /* first element */
+} mdb_nlm_globals_list_t;
+
+typedef struct mdb_nlm_globals {
+	struct {
+		uintptr_t tqe_next; /* next element */
+	} nlm_link;
+} mdb_nlm_globals_t;
+
+static int
+nlm_host_walk_init(mdb_walk_state_t *wsp)
+{
+	mdb_nlm_globals_list_t globals_list;
+	GElf_Sym sym;
+	mdb_nlm_globals_t nlm_global;
+
+	/*
+	 * 1. Find the global list of zones.
+	 * 2. Read the first element in the list.
+	 * 3. Read the AVL tree field and call ::walk avl.
+	 */
+	if (mdb_lookup_by_name("nlm_zones_list", &sym) != 0) {
+		return (WALK_ERR);
+	}
+
+	if (mdb_ctf_vread(&globals_list, "struct nlm_globals_list",
+	    "mdb_nlm_globals_list_t", sym.st_value, 0) == -1) {
+		return (WALK_ERR);
+	}
+
+	if (globals_list.tqh_first == 0) {
+		mdb_warn("empty zones list!\n");
+		return (WALK_ERR);
+	}
+
+	/* This walk works for a single zone. Warn if there is > 1 zone. */
+	if (mdb_ctf_vread(&nlm_global, "struct nlm_globals",
+	    "mdb_nlm_globals_t", globals_list.tqh_first, 0) == -1) {
+		return (WALK_ERR);
+	}
+	if (nlm_global.nlm_link.tqe_next != 0) {
+		mdb_warn("2+ zones present -- info for only the "
+		    "first zone in the data structure will be printed.\n");
+	}
+
+	wsp->walk_addr = globals_list.tqh_first
+	    + mdb_ctf_offsetof_by_name("struct nlm_globals", "nlm_hosts_tree");
+	if (mdb_layered_walk("avl", wsp) == -1) {
+		mdb_warn("failed to walk 'avl'\n");
+		return (WALK_ERR);
+	}
+
+	return (WALK_NEXT);
+}
+
+static int
+nlm_host_walk_step(mdb_walk_state_t *wsp)
+{
+	return (wsp->walk_callback(wsp->walk_addr, wsp->walk_layer,
+	    wsp->walk_cbdata));
+}
+
+
+static const mdb_dcmd_t dcmds[] = {
+	{ "nlm_host", "", "dump an nlm_host structure",
+	    nlm_host_dcmd, NULL },
+	{ NULL }
+};
+
+static const mdb_walker_t walkers[] = {
+	{ "nlm_host", "dump all nlm_host structures",
+	    nlm_host_walk_init, nlm_host_walk_step, NULL },
+	{ NULL }
+};
+
+static const mdb_modinfo_t modinfo = {
+	MDB_API_VERSION, dcmds, walkers
+};
+
+const mdb_modinfo_t *
+_mdb_init(void)
+{
+	return (&modinfo);
+}
--- /dev/null	Mon Sep 16 13:28:52 2013
+++ new/usr/src/cmd/mdb/intel/amd64/klmmod/Makefile	Mon Sep 16 13:28:52 2013
@@ -0,0 +1,25 @@
+# CDDL HEADER START
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2013 by Delphix. All rights reserved.
+#
+
+MODULE = klmmod.so
+MDBTGT = kvm
+
+MODSRCS = nlm.c
+
+include ../../../../Makefile.cmd
+include ../../../../Makefile.cmd.64
+include ../../Makefile.amd64
+include ../../../Makefile.module
--- /dev/null	Mon Sep 16 13:28:53 2013
+++ new/usr/src/cmd/mdb/intel/ia32/klmmod/Makefile	Mon Sep 16 13:28:53 2013
@@ -0,0 +1,24 @@
+# CDDL HEADER START
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2013 by Delphix. All rights reserved.
+#
+
+MODULE = klmmod.so
+MDBTGT = kvm
+
+MODSRCS = nlm.c
+
+include ../../../../Makefile.cmd
+include ../../Makefile.ia32
+include ../../../Makefile.module
--- /dev/null	Mon Sep 16 13:28:53 2013
+++ new/usr/src/cmd/mdb/sparc/v9/klmmod/Makefile	Mon Sep 16 13:28:53 2013
@@ -0,0 +1,31 @@
+# CDDL HEADER START
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2013 by Delphix. All rights reserved.
+#
+
+MODULE = klmmod.so
+MDBTGT = kvm
+
+MODSRCS = nlm.c
+
+include ../../../../Makefile.cmd
+include ../../../../Makefile.cmd.64
+include ../../Makefile.sparcv9
+
+ROOTKMOD = $(ROOT)/usr/kernel/kmdb$(MACHMODDIR)
+
+include ../../../Makefile.module
+
+$(ROOTKMOD):
+	$(INS.dir)
--- old/usr/src/pkg/manifests/developer-debug-mdb.mf	Mon Sep 16 13:28:54 2013
+++ new/usr/src/pkg/manifests/developer-debug-mdb.mf	Mon Sep 16 13:28:54 2013
@@ -21,6 +21,7 @@
 
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013 by Delphix. All rights reserved.
 #
 
 set name=pkg.fmri value=pkg:/developer/debug/mdb@$(PKGVERS)
@@ -102,6 +103,7 @@
 file path=kernel/kmdb/$(ARCH64)/ip group=sys mode=0555
 file path=kernel/kmdb/$(ARCH64)/ipc group=sys mode=0555
 file path=kernel/kmdb/$(ARCH64)/ipp group=sys mode=0555
+file path=kernel/kmdb/$(ARCH64)/klmmod group=sys mode=0555
 file path=kernel/kmdb/$(ARCH64)/krtld group=sys mode=0555
 file path=kernel/kmdb/$(ARCH64)/lofs group=sys mode=0555
 file path=kernel/kmdb/$(ARCH64)/logindmux group=sys mode=0555
@@ -138,6 +140,7 @@
 $(i386_ONLY)file path=kernel/kmdb/ip group=sys mode=0555
 $(i386_ONLY)file path=kernel/kmdb/ipc group=sys mode=0555
 $(i386_ONLY)file path=kernel/kmdb/ipp group=sys mode=0555
+$(i386_ONLY)file path=kernel/kmdb/klmmod group=sys mode=0555
 $(i386_ONLY)file path=kernel/kmdb/krtld group=sys mode=0555
 $(i386_ONLY)file path=kernel/kmdb/lofs group=sys mode=0555
 $(i386_ONLY)file path=kernel/kmdb/logindmux group=sys mode=0555
@@ -218,6 +221,7 @@
 file path=usr/lib/mdb/kvm/$(ARCH64)/ip.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/ipc.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/ipp.so group=sys mode=0555
+file path=usr/lib/mdb/kvm/$(ARCH64)/klmmod.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/krtld.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/lofs.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/logindmux.so group=sys mode=0555
@@ -256,6 +260,7 @@
 $(i386_ONLY)file path=usr/lib/mdb/kvm/ip.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/ipc.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/ipp.so group=sys mode=0555
+$(i386_ONLY)file path=usr/lib/mdb/kvm/klmmod.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/krtld.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/lofs.so group=sys mode=0555
 $(i386_ONLY)file path=usr/lib/mdb/kvm/logindmux.so group=sys mode=0555
