Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2016 14:43:17 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300148 - in head: share/man/man4 sys/net
Message-ID:  <201605181443.u4IEhHEE012678@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Wed May 18 14:43:17 2016
New Revision: 300148
URL: https://svnweb.freebsd.org/changeset/base/300148

Log:
  Split 'show vnets' into 'show vnet' and 'show all vnets'.
  While here adjust some db_printf format string.
  
  Document the two show commands in ddb.4.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/share/man/man4/ddb.4
  head/sys/net/vnet.c

Modified: head/share/man/man4/ddb.4
==============================================================================
--- head/share/man/man4/ddb.4	Wed May 18 14:18:03 2016	(r300147)
+++ head/share/man/man4/ddb.4	Wed May 18 14:43:17 2016	(r300148)
@@ -60,7 +60,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 15, 2016
+.Dd May 18, 2016
 .Dt DDB 4
 .Os
 .Sh NAME
@@ -542,6 +542,11 @@ Output is similar to
 but also includes the address of the TTY structure.
 .\"
 .Pp
+.It Ic show Cm all vnets
+Show the same output as "show vnet" does, but lists all
+virtualized network stacks within the system.
+.\"
+.Pp
 .It Ic show Cm allchains
 Show the same information like "show lockchain" does, but
 for every thread in the system.
@@ -1060,6 +1065,13 @@ Currently, it is not possible to use thi
 is compiled in the kernel.
 .\"
 .Pp
+.It Ic show Cm vnet Ar addr
+Prints virtualized network stack
+.Vt struct vnet
+structure present at the address
+.Ar addr .
+.\"
+.Pp
 .It Ic show Cm vnode Op Ar addr
 Prints vnode
 .Vt struct vnode

Modified: head/sys/net/vnet.c
==============================================================================
--- head/sys/net/vnet.c	Wed May 18 14:18:03 2016	(r300147)
+++ head/sys/net/vnet.c	Wed May 18 14:43:17 2016	(r300148)
@@ -690,27 +690,45 @@ vnet_log_recursion(struct vnet *old_vnet
  * DDB(4).
  */
 #ifdef DDB
-DB_SHOW_COMMAND(vnets, db_show_vnets)
+static void
+db_vnet_print(struct vnet *vnet)
+{
+
+	db_printf("vnet            = %p\n", vnet);
+	db_printf(" vnet_magic_n   = %#08x (%s, orig %#08x)\n",
+	    vnet->vnet_magic_n,
+	    (vnet->vnet_magic_n == VNET_MAGIC_N) ?
+		"ok" : "mismatch", VNET_MAGIC_N);
+	db_printf(" vnet_ifcnt     = %u\n", vnet->vnet_ifcnt);
+	db_printf(" vnet_sockcnt   = %u\n", vnet->vnet_sockcnt);
+	db_printf(" vnet_data_mem  = %p\n", vnet->vnet_data_mem);
+	db_printf(" vnet_data_base = %#jx\n",
+	    (uintmax_t)vnet->vnet_data_base);
+	db_printf("\n");
+}
+
+DB_SHOW_ALL_COMMAND(vnets, db_show_all_vnets)
 {
 	VNET_ITERATOR_DECL(vnet_iter);
 
 	VNET_FOREACH(vnet_iter) {
-		db_printf("vnet            = %p\n", vnet_iter);
-		db_printf(" vnet_magic_n   = 0x%x (%s, orig 0x%x)\n",
-		    vnet_iter->vnet_magic_n,
-		    (vnet_iter->vnet_magic_n == VNET_MAGIC_N) ?
-			"ok" : "mismatch", VNET_MAGIC_N);
-		db_printf(" vnet_ifcnt     = %u\n", vnet_iter->vnet_ifcnt);
-		db_printf(" vnet_sockcnt   = %u\n", vnet_iter->vnet_sockcnt);
-		db_printf(" vnet_data_mem  = %p\n", vnet_iter->vnet_data_mem);
-		db_printf(" vnet_data_base = 0x%jx\n",
-		    (uintmax_t)vnet_iter->vnet_data_base);
-		db_printf("\n");
+		db_vnet_print(vnet_iter);
 		if (db_pager_quit)
 			break;
 	}
 }
 
+DB_SHOW_COMMAND(vnet, db_show_vnet)
+{
+
+	if (!have_addr) {
+		db_printf("usage: show vnet <struct vnet *>\n");
+		return;
+	}
+
+	db_vnet_print((struct vnet *)addr);
+}
+
 static void
 db_show_vnet_print_vs(struct vnet_sysinit *vs, int ddb)
 {
@@ -734,7 +752,7 @@ db_show_vnet_print_vs(struct vnet_sysini
 	sym = db_search_symbol((vm_offset_t)vs->func, DB_STGY_PROC, &offset);
 	db_symbol_values(sym, &funcname, NULL);
 	xprint("%s(%p)\n", (vsname != NULL) ? vsname : "", vs);
-	xprint("  0x%08x 0x%08x\n", vs->subsystem, vs->order);
+	xprint("  %#08x %#08x\n", vs->subsystem, vs->order);
 	xprint("  %p(%s)(%p)\n",
 	    vs->func, (funcname != NULL) ? funcname : "", vs->arg);
 #undef xprint



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605181443.u4IEhHEE012678>