svn commit: r353685 - in head/sys: amd64/conf arm64/conf conf dev/alc dev/bge dev/bxe dev/cxgb dev/mlx4/mlx4_en dev/re dev/virtio/network i386/conf kern net netinet/netdump powerpc/conf sparc64/con...

Conrad Meyer cem at FreeBSD.org
Thu Oct 17 16:23:08 UTC 2019


Author: cem
Date: Thu Oct 17 16:23:03 2019
New Revision: 353685
URL: https://svnweb.freebsd.org/changeset/base/353685

Log:
  Split out a more generic debugnet(4) from netdump(4)
  
  Debugnet is a simplistic and specialized panic- or debug-time reliable
  datagram transport.  It can drive a single connection at a time and is
  currently unidirectional (debug/panic machine transmit to remote server
  only).
  
  It is mostly a verbatim code lift from netdump(4).  Netdump(4) remains
  the only consumer (until the rest of this patch series lands).
  
  The INET-specific logic has been extracted somewhat more thoroughly than
  previously in netdump(4), into debugnet_inet.c.  UDP-layer logic and up, as
  much as possible as is protocol-independent, remains in debugnet.c.  The
  separation is not perfect and future improvement is welcome.  Supporting
  INET6 is a long-term goal.
  
  Much of the diff is "gratuitous" renaming from 'netdump_' or 'nd_' to
  'debugnet_' or 'dn_' -- sorry.  I thought keeping the netdump name on the
  generic module would be more confusing than the refactoring.
  
  The only functional change here is the mbuf allocation / tracking.  Instead
  of initiating solely on netdump-configured interface(s) at dumpon(8)
  configuration time, we watch for any debugnet-enabled NIC for link
  activation and query it for mbuf parameters at that time.  If they exceed
  the existing high-water mark allocation, we re-allocate and track the new
  high-water mark.  Otherwise, we leave the pre-panic mbuf allocation alone.
  In a future patch in this series, this will allow initiating netdump from
  panic ddb(4) without pre-panic configuration.
  
  No other functional change intended.
  
  Reviewed by:	markj (earlier version)
  Some discussion with:	emaste, jhb
  Objection from:	marius
  Differential Revision:	https://reviews.freebsd.org/D21421

Added:
  head/sys/net/debugnet.c   (contents, props changed)
  head/sys/net/debugnet.h   (contents, props changed)
  head/sys/net/debugnet_inet.c   (contents, props changed)
  head/sys/net/debugnet_int.h   (contents, props changed)
Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/arm64/conf/GENERIC
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/sys/dev/alc/if_alc.c
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bxe/bxe.c
  head/sys/dev/bxe/bxe.h
  head/sys/dev/cxgb/cxgb_adapter.h
  head/sys/dev/cxgb/cxgb_main.c
  head/sys/dev/cxgb/cxgb_sge.c
  head/sys/dev/mlx4/mlx4_en/en.h
  head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
  head/sys/dev/re/if_re.c
  head/sys/dev/virtio/network/if_vtnet.c
  head/sys/i386/conf/GENERIC
  head/sys/kern/kern_mbuf.c
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/net/iflib.c
  head/sys/netinet/netdump/netdump.h
  head/sys/netinet/netdump/netdump_client.c
  head/sys/powerpc/conf/GENERIC
  head/sys/powerpc/conf/GENERIC64
  head/sys/sparc64/conf/GENERIC
  head/sys/sys/mbuf.h
  head/sys/sys/param.h

Modified: head/sys/amd64/conf/GENERIC
==============================================================================
--- head/sys/amd64/conf/GENERIC	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/amd64/conf/GENERIC	Thu Oct 17 16:23:03 2019	(r353685)
@@ -111,6 +111,7 @@ options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sys
 options 	EKCD			# Support for encrypted kernel dumps
 options 	GZIO			# gzip-compressed kernel and user dumps
 options 	ZSTDIO			# zstd-compressed kernel and user dumps
+options 	DEBUGNET		# debugnet networking
 options 	NETDUMP			# netdump(4) client support
 
 # Make an SMP-capable kernel by default

Modified: head/sys/arm64/conf/GENERIC
==============================================================================
--- head/sys/arm64/conf/GENERIC	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/arm64/conf/GENERIC	Thu Oct 17 16:23:03 2019	(r353685)
@@ -103,6 +103,7 @@ options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sys
 options 	EKCD			# Support for encrypted kernel dumps
 options 	GZIO			# gzip-compressed kernel and user dumps
 options 	ZSTDIO			# zstd-compressed kernel and user dumps
+options 	DEBUGNET		# debugnet networking
 options 	NETDUMP			# netdump(4) client support
 
 # SoC support

Modified: head/sys/conf/NOTES
==============================================================================
--- head/sys/conf/NOTES	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/conf/NOTES	Thu Oct 17 16:23:03 2019	(r353685)
@@ -1042,6 +1042,10 @@ options 	DUMMYNET
 # This allows a panicking kernel to transmit a kernel dump to a remote host.
 options 	NETDUMP
 
+# The DEBUGNET option enables a basic debug/panic-time networking API.  It
+# is used by NETDUMP.
+options 	DEBUGNET
+
 #####################################################################
 # FILESYSTEM OPTIONS
 

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/conf/files	Thu Oct 17 16:23:03 2019	(r353685)
@@ -4077,6 +4077,8 @@ net/mp_ring.c			optional ether iflib
 net/mppcc.c			optional netgraph_mppc_compression
 net/mppcd.c			optional netgraph_mppc_compression
 net/netisr.c			standard
+net/debugnet.c			optional inet debugnet
+net/debugnet_inet.c		optional inet debugnet
 net/pfil.c			optional ether | inet
 net/radix.c			standard
 net/radix_mpath.c		standard

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/conf/options	Thu Oct 17 16:23:03 2019	(r353685)
@@ -321,6 +321,8 @@ NETSMB		opt_netsmb.h
 
 # Enable netdump(4) client support.
 NETDUMP 	opt_global.h
+# Enable debugnet(4) networking support.
+DEBUGNET 	opt_global.h
 
 # Options used only in subr_param.c.
 HZ		opt_param.h

Modified: head/sys/dev/alc/if_alc.c
==============================================================================
--- head/sys/dev/alc/if_alc.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/alc/if_alc.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/taskqueue.h>
 
 #include <net/bpf.h>
+#include <net/debugnet.h>
 #include <net/if.h>
 #include <net/if_var.h>
 #include <net/if_arp.h>
@@ -64,7 +65,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
-#include <netinet/netdump/netdump.h>
 
 #include <dev/mii/mii.h>
 #include <dev/mii/miivar.h>
@@ -215,7 +215,7 @@ static int	sysctl_int_range(SYSCTL_HANDLER_ARGS, int, 
 static int	sysctl_hw_alc_proc_limit(SYSCTL_HANDLER_ARGS);
 static int	sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS);
 
-NETDUMP_DEFINE(alc);
+DEBUGNET_DEFINE(alc);
 
 static device_method_t alc_methods[] = {
 	/* Device interface. */
@@ -1657,8 +1657,8 @@ alc_attach(device_t dev)
 		goto fail;
 	}
 
-	/* Attach driver netdump methods. */
-	NETDUMP_SET(ifp, alc);
+	/* Attach driver debugnet methods. */
+	DEBUGNET_SET(ifp, alc);
 
 fail:
 	if (error != 0)
@@ -4658,9 +4658,9 @@ sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS)
 	    ALC_IM_TIMER_MIN, ALC_IM_TIMER_MAX));
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-alc_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+alc_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct alc_softc *sc;
 
@@ -4668,17 +4668,17 @@ alc_netdump_init(struct ifnet *ifp, int *nrxr, int *nc
 	KASSERT(sc->alc_buf_size <= MCLBYTES, ("incorrect cluster size"));
 
 	*nrxr = ALC_RX_RING_CNT;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	*clsize = MCLBYTES;
 }
 
 static void
-alc_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused)
+alc_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
 {
 }
 
 static int
-alc_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+alc_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct alc_softc *sc;
 	int error;
@@ -4695,7 +4695,7 @@ alc_netdump_transmit(struct ifnet *ifp, struct mbuf *m
 }
 
 static int
-alc_netdump_poll(struct ifnet *ifp, int count)
+alc_debugnet_poll(struct ifnet *ifp, int count)
 {
 	struct alc_softc *sc;
 
@@ -4707,4 +4707,4 @@ alc_netdump_poll(struct ifnet *ifp, int count)
 	alc_txeof(sc);
 	return (alc_rxintr(sc, count));
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/bge/if_bge.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 
+#include <net/debugnet.h>
 #include <net/if.h>
 #include <net/if_var.h>
 #include <net/if_arp.h>
@@ -100,7 +101,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
-#include <netinet/netdump/netdump.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
@@ -519,7 +519,7 @@ static void bge_add_sysctl_stats(struct bge_softc *, s
     struct sysctl_oid_list *);
 static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS);
 
-NETDUMP_DEFINE(bge);
+DEBUGNET_DEFINE(bge);
 
 static device_method_t bge_methods[] = {
 	/* Device interface */
@@ -3983,8 +3983,8 @@ again:
 		goto fail;
 	}
 
-	/* Attach driver netdump methods. */
-	NETDUMP_SET(ifp, bge);
+	/* Attach driver debugnet methods. */
+	DEBUGNET_SET(ifp, bge);
 
 fail:
 	if (error)
@@ -6844,16 +6844,16 @@ bge_get_counter(if_t ifp, ift_counter cnt)
 	}
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-bge_netdump_init(if_t ifp, int *nrxr, int *ncl, int *clsize)
+bge_debugnet_init(if_t ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct bge_softc *sc;
 
 	sc = if_getsoftc(ifp);
 	BGE_LOCK(sc);
 	*nrxr = sc->bge_return_ring_cnt;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	if ((sc->bge_flags & BGE_FLAG_JUMBO_STD) != 0 &&
 	    (if_getmtu(sc->bge_ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN +
 	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN)))
@@ -6864,12 +6864,12 @@ bge_netdump_init(if_t ifp, int *nrxr, int *ncl, int *c
 }
 
 static void
-bge_netdump_event(if_t ifp __unused, enum netdump_ev event __unused)
+bge_debugnet_event(if_t ifp __unused, enum debugnet_ev event __unused)
 {
 }
 
 static int
-bge_netdump_transmit(if_t ifp, struct mbuf *m)
+bge_debugnet_transmit(if_t ifp, struct mbuf *m)
 {
 	struct bge_softc *sc;
 	uint32_t prodidx;
@@ -6888,7 +6888,7 @@ bge_netdump_transmit(if_t ifp, struct mbuf *m)
 }
 
 static int
-bge_netdump_poll(if_t ifp, int count)
+bge_debugnet_poll(if_t ifp, int count)
 {
 	struct bge_softc *sc;
 	uint32_t rx_prod, tx_cons;
@@ -6913,4 +6913,4 @@ bge_netdump_poll(if_t ifp, int count)
 	bge_txeof(sc, tx_cons);
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/bxe/bxe.c
==============================================================================
--- head/sys/dev/bxe/bxe.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/bxe/bxe.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -237,7 +237,7 @@ MODULE_DEPEND(bxe, pci, 1, 1, 1);
 MODULE_DEPEND(bxe, ether, 1, 1, 1);
 DRIVER_MODULE(bxe, pci, bxe_driver, bxe_devclass, 0, 0);
 
-NETDUMP_DEFINE(bxe);
+DEBUGNET_DEFINE(bxe);
 
 /* resources needed for unloading a previously loaded device */
 
@@ -13124,8 +13124,8 @@ bxe_init_ifnet(struct bxe_softc *sc)
     /* attach to the Ethernet interface list */
     ether_ifattach(ifp, sc->link_params.mac_addr);
 
-    /* Attach driver netdump methods. */
-    NETDUMP_SET(ifp, bxe);
+    /* Attach driver debugnet methods. */
+    DEBUGNET_SET(ifp, bxe);
 
     return (0);
 }
@@ -19533,27 +19533,27 @@ bxe_eioctl(struct cdev *dev, u_long cmd, caddr_t data,
     return (rval);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-bxe_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+bxe_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct bxe_softc *sc;
 
 	sc = if_getsoftc(ifp);
 	BXE_CORE_LOCK(sc);
 	*nrxr = sc->num_queues;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	*clsize = sc->fp[0].mbuf_alloc_size;
 	BXE_CORE_UNLOCK(sc);
 }
 
 static void
-bxe_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused)
+bxe_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
 {
 }
 
 static int
-bxe_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+bxe_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct bxe_softc *sc;
 	int error;
@@ -19570,7 +19570,7 @@ bxe_netdump_transmit(struct ifnet *ifp, struct mbuf *m
 }
 
 static int
-bxe_netdump_poll(struct ifnet *ifp, int count)
+bxe_debugnet_poll(struct ifnet *ifp, int count)
 {
 	struct bxe_softc *sc;
 	int i;
@@ -19585,4 +19585,4 @@ bxe_netdump_poll(struct ifnet *ifp, int count)
 	(void)bxe_txeof(sc, &sc->fp[0]);
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/bxe/bxe.h
==============================================================================
--- head/sys/dev/bxe/bxe.h	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/bxe/bxe.h	Thu Oct 17 16:23:03 2019	(r353685)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/taskqueue.h>
 #include <contrib/zlib/zlib.h>
 
+#include <net/debugnet.h>
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/if_arp.h>
@@ -70,7 +71,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip6.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
-#include <netinet/netdump/netdump.h>
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>

Modified: head/sys/dev/cxgb/cxgb_adapter.h
==============================================================================
--- head/sys/dev/cxgb/cxgb_adapter.h	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/cxgb/cxgb_adapter.h	Thu Oct 17 16:23:03 2019	(r353685)
@@ -578,10 +578,10 @@ void cxgb_qflush(struct ifnet *ifp);
 void t3_iterate(void (*)(struct adapter *, void *), void *);
 void cxgb_refresh_stats(struct port_info *);
 
-#ifdef NETDUMP
-int cxgb_netdump_encap(struct sge_qset *qs, struct mbuf **m);
-int cxgb_netdump_poll_rx(adapter_t *adap, struct sge_qset *qs);
-int cxgb_netdump_poll_tx(struct sge_qset *qs);
+#ifdef DEBUGNET
+int cxgb_debugnet_encap(struct sge_qset *qs, struct mbuf **m);
+int cxgb_debugnet_poll_rx(adapter_t *adap, struct sge_qset *qs);
+int cxgb_debugnet_poll_tx(struct sge_qset *qs);
 #endif
 
 #endif

Modified: head/sys/dev/cxgb/cxgb_main.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_main.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/cxgb/cxgb_main.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/proc.h>
 
 #include <net/bpf.h>
+#include <net/debugnet.h>
 #include <net/ethernet.h>
 #include <net/if.h>
 #include <net/if_var.h>
@@ -74,7 +75,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
-#include <netinet/netdump/netdump.h>
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
@@ -218,7 +218,7 @@ static devclass_t	cxgb_port_devclass;
 DRIVER_MODULE(cxgb, cxgbc, cxgb_port_driver, cxgb_port_devclass, 0, 0);
 MODULE_VERSION(cxgb, 1);
 
-NETDUMP_DEFINE(cxgb);
+DEBUGNET_DEFINE(cxgb);
 
 static struct mtx t3_list_lock;
 static SLIST_HEAD(, adapter) t3_list;
@@ -1053,8 +1053,8 @@ cxgb_port_attach(device_t dev)
 
 	ether_ifattach(ifp, p->hw_addr);
 
-	/* Attach driver netdump methods. */
-	NETDUMP_SET(ifp, cxgb);
+	/* Attach driver debugnet methods. */
+	DEBUGNET_SET(ifp, cxgb);
 
 #ifdef DEFAULT_JUMBO
 	if (sc->params.nports <= 2)
@@ -3590,9 +3590,9 @@ cxgbc_mod_event(module_t mod, int cmd, void *arg)
 	return (rc);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-cxgb_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+cxgb_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct port_info *pi;
 	adapter_t *adap;
@@ -3607,18 +3607,18 @@ cxgb_netdump_init(struct ifnet *ifp, int *nrxr, int *n
 }
 
 static void
-cxgb_netdump_event(struct ifnet *ifp, enum netdump_ev event)
+cxgb_debugnet_event(struct ifnet *ifp, enum debugnet_ev event)
 {
 	struct port_info *pi;
 	struct sge_qset *qs;
 	int i;
 
 	pi = if_getsoftc(ifp);
-	if (event == NETDUMP_START)
+	if (event == DEBUGNET_START)
 		for (i = 0; i < pi->adapter->nqsets; i++) {
 			qs = &pi->adapter->sge.qs[i];
 
-			/* Need to reinit after netdump_mbuf_dump(). */
+			/* Need to reinit after debugnet_mbuf_start(). */
 			qs->fl[0].zone = zone_pack;
 			qs->fl[1].zone = zone_clust;
 			qs->lro.enabled = 0;
@@ -3626,7 +3626,7 @@ cxgb_netdump_event(struct ifnet *ifp, enum netdump_ev 
 }
 
 static int
-cxgb_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+cxgb_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct port_info *pi;
 	struct sge_qset *qs;
@@ -3637,11 +3637,11 @@ cxgb_netdump_transmit(struct ifnet *ifp, struct mbuf *
 		return (ENOENT);
 
 	qs = &pi->adapter->sge.qs[pi->first_qset];
-	return (cxgb_netdump_encap(qs, &m));
+	return (cxgb_debugnet_encap(qs, &m));
 }
 
 static int
-cxgb_netdump_poll(struct ifnet *ifp, int count)
+cxgb_debugnet_poll(struct ifnet *ifp, int count)
 {
 	struct port_info *pi;
 	adapter_t *adap;
@@ -3653,8 +3653,8 @@ cxgb_netdump_poll(struct ifnet *ifp, int count)
 
 	adap = pi->adapter;
 	for (i = 0; i < adap->nqsets; i++)
-		(void)cxgb_netdump_poll_rx(adap, &adap->sge.qs[i]);
-	(void)cxgb_netdump_poll_tx(&adap->sge.qs[pi->first_qset]);
+		(void)cxgb_debugnet_poll_rx(adap, &adap->sge.qs[i]);
+	(void)cxgb_debugnet_poll_tx(&adap->sge.qs[pi->first_qset]);
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_sge.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/cxgb/cxgb_sge.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -390,9 +390,9 @@ reclaim_completed_tx(struct sge_qset *qs, int reclaim_
 	return (reclaim);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 int
-cxgb_netdump_poll_tx(struct sge_qset *qs)
+cxgb_debugnet_poll_tx(struct sge_qset *qs)
 {
 
 	return (reclaim_completed_tx(qs, TX_RECLAIM_MAX, TXQ_ETH));
@@ -1595,9 +1595,9 @@ t3_encap(struct sge_qset *qs, struct mbuf **m)
 	return (0);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 int
-cxgb_netdump_encap(struct sge_qset *qs, struct mbuf **m)
+cxgb_debugnet_encap(struct sge_qset *qs, struct mbuf **m)
 {
 	int error;
 
@@ -3040,9 +3040,9 @@ process_responses_gts(adapter_t *adap, struct sge_rspq
 	return (work);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 int
-cxgb_netdump_poll_rx(adapter_t *adap, struct sge_qset *qs)
+cxgb_debugnet_poll_rx(adapter_t *adap, struct sge_qset *qs)
 {
 
 	return (process_responses_gts(adap, &qs->rspq));

Modified: head/sys/dev/mlx4/mlx4_en/en.h
==============================================================================
--- head/sys/dev/mlx4/mlx4_en/en.h	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/mlx4/mlx4_en/en.h	Thu Oct 17 16:23:03 2019	(r353685)
@@ -53,8 +53,8 @@
 #include <dev/mlx4/doorbell.h>
 #include <dev/mlx4/cmd.h>
 
+#include <net/debugnet.h>
 #include <netinet/tcp_lro.h>
-#include <netinet/netdump/netdump.h>
 
 #include "en_port.h"
 #include <dev/mlx4/stats.h>

Modified: head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
==============================================================================
--- head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -54,7 +54,7 @@
 #include "en.h"
 #include "en_port.h"
 
-NETDUMP_DEFINE(mlx4_en);
+DEBUGNET_DEFINE(mlx4_en);
 
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv);
 static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv);
@@ -2304,7 +2304,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int 
 	ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
 
-	NETDUMP_SET(dev, mlx4_en);
+	DEBUGNET_SET(dev, mlx4_en);
 
 	en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num);
 	en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num);
@@ -2888,27 +2888,27 @@ static void mlx4_en_sysctl_stat(struct mlx4_en_priv *p
 	}
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-mlx4_en_netdump_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
+mlx4_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize)
 {
 	struct mlx4_en_priv *priv;
 
 	priv = if_getsoftc(dev);
 	mutex_lock(&priv->mdev->state_lock);
 	*nrxr = priv->rx_ring_num;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	*clsize = priv->rx_mb_size;
 	mutex_unlock(&priv->mdev->state_lock);
 }
 
 static void
-mlx4_en_netdump_event(struct ifnet *dev, enum netdump_ev event)
+mlx4_en_debugnet_event(struct ifnet *dev, enum debugnet_ev event)
 {
 }
 
 static int
-mlx4_en_netdump_transmit(struct ifnet *dev, struct mbuf *m)
+mlx4_en_debugnet_transmit(struct ifnet *dev, struct mbuf *m)
 {
 	struct mlx4_en_priv *priv;
 	int err;
@@ -2925,7 +2925,7 @@ mlx4_en_netdump_transmit(struct ifnet *dev, struct mbu
 }
 
 static int
-mlx4_en_netdump_poll(struct ifnet *dev, int count)
+mlx4_en_debugnet_poll(struct ifnet *dev, int count)
 {
 	struct mlx4_en_priv *priv;
 
@@ -2937,4 +2937,4 @@ mlx4_en_netdump_poll(struct ifnet *dev, int count)
 
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/re/if_re.c
==============================================================================
--- head/sys/dev/re/if_re.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/re/if_re.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -128,6 +128,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 
+#include <net/debugnet.h>
 #include <net/if.h>
 #include <net/if_var.h>
 #include <net/if_arp.h>
@@ -139,8 +140,6 @@ __FBSDID("$FreeBSD$");
 
 #include <net/bpf.h>
 
-#include <netinet/netdump/netdump.h>
-
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <sys/bus.h>
@@ -310,7 +309,7 @@ static void re_setwol		(struct rl_softc *);
 static void re_clrwol		(struct rl_softc *);
 static void re_set_linkspeed	(struct rl_softc *);
 
-NETDUMP_DEFINE(re);
+DEBUGNET_DEFINE(re);
 
 #ifdef DEV_NETMAP	/* see ixgbe.c for details */
 #include <dev/netmap/if_re_netmap.h>
@@ -1745,7 +1744,7 @@ re_attach(device_t dev)
 		goto fail;
 	}
 
-	NETDUMP_SET(ifp, re);
+	DEBUGNET_SET(ifp, re);
 
 fail:
 	if (error)
@@ -4093,28 +4092,28 @@ sysctl_hw_re_int_mod(SYSCTL_HANDLER_ARGS)
 	    RL_TIMER_MAX));
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-re_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+re_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct rl_softc *sc;
 
 	sc = if_getsoftc(ifp);
 	RL_LOCK(sc);
 	*nrxr = sc->rl_ldata.rl_rx_desc_cnt;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	*clsize = (ifp->if_mtu > RL_MTU &&
 	    (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) ? MJUM9BYTES : MCLBYTES;
 	RL_UNLOCK(sc);
 }
 
 static void
-re_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused)
+re_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
 {
 }
 
 static int
-re_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+re_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct rl_softc *sc;
 	int error;
@@ -4131,7 +4130,7 @@ re_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
 }
 
 static int
-re_netdump_poll(struct ifnet *ifp, int count)
+re_debugnet_poll(struct ifnet *ifp, int count)
 {
 	struct rl_softc *sc;
 	int error;
@@ -4147,4 +4146,4 @@ re_netdump_poll(struct ifnet *ifp, int count)
 		return (error);
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- head/sys/dev/virtio/network/if_vtnet.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/dev/virtio/network/if_vtnet.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/uma.h>
 
+#include <net/debugnet.h>
 #include <net/ethernet.h>
 #include <net/if.h>
 #include <net/if_var.h>
@@ -69,7 +70,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet6/ip6_var.h>
 #include <netinet/udp.h>
 #include <netinet/tcp.h>
-#include <netinet/netdump/netdump.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
@@ -230,7 +230,7 @@ static void	vtnet_disable_interrupts(struct vtnet_soft
 
 static int	vtnet_tunable_int(struct vtnet_softc *, const char *, int);
 
-NETDUMP_DEFINE(vtnet);
+DEBUGNET_DEFINE(vtnet);
 
 /* Tunables. */
 static SYSCTL_NODE(_hw, OID_AUTO, vtnet, CTLFLAG_RD, 0, "VNET driver parameters");
@@ -1025,7 +1025,7 @@ vtnet_setup_interface(struct vtnet_softc *sc)
 	vtnet_set_rx_process_limit(sc);
 	vtnet_set_tx_intr_threshold(sc);
 
-	NETDUMP_SET(ifp, vtnet);
+	DEBUGNET_SET(ifp, vtnet);
 
 	return (0);
 }
@@ -3972,9 +3972,9 @@ vtnet_tunable_int(struct vtnet_softc *sc, const char *
 	return (def);
 }
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 static void
-vtnet_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
+vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
 {
 	struct vtnet_softc *sc;
 
@@ -3982,7 +3982,7 @@ vtnet_netdump_init(struct ifnet *ifp, int *nrxr, int *
 
 	VTNET_CORE_LOCK(sc);
 	*nrxr = sc->vtnet_max_vq_pairs;
-	*ncl = NETDUMP_MAX_IN_FLIGHT;
+	*ncl = DEBUGNET_MAX_IN_FLIGHT;
 	*clsize = sc->vtnet_rx_clsize;
 	VTNET_CORE_UNLOCK(sc);
 
@@ -3992,17 +3992,17 @@ vtnet_netdump_init(struct ifnet *ifp, int *nrxr, int *
 	 * XXX add a separate zone like we do for mbufs? otherwise we may alloc
 	 * buckets
 	 */
-	uma_zone_reserve(vtnet_tx_header_zone, NETDUMP_MAX_IN_FLIGHT * 2);
-	uma_prealloc(vtnet_tx_header_zone, NETDUMP_MAX_IN_FLIGHT * 2);
+	uma_zone_reserve(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
+	uma_prealloc(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
 }
 
 static void
-vtnet_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused)
+vtnet_debugnet_event(struct ifnet *ifp __unused, enum debugnet_ev event __unused)
 {
 }
 
 static int
-vtnet_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
+vtnet_debugnet_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct vtnet_softc *sc;
 	struct vtnet_txq *txq;
@@ -4021,7 +4021,7 @@ vtnet_netdump_transmit(struct ifnet *ifp, struct mbuf 
 }
 
 static int
-vtnet_netdump_poll(struct ifnet *ifp, int count)
+vtnet_debugnet_poll(struct ifnet *ifp, int count)
 {
 	struct vtnet_softc *sc;
 	int i;
@@ -4036,4 +4036,4 @@ vtnet_netdump_poll(struct ifnet *ifp, int count)
 		(void)vtnet_rxq_eof(&sc->vtnet_rxqs[i]);
 	return (0);
 }
-#endif /* NETDUMP */
+#endif /* DEBUGNET */

Modified: head/sys/i386/conf/GENERIC
==============================================================================
--- head/sys/i386/conf/GENERIC	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/i386/conf/GENERIC	Thu Oct 17 16:23:03 2019	(r353685)
@@ -99,6 +99,7 @@ options 	VERBOSE_SYSINIT=0	# Support debug.verbose_sys
 options 	EKCD			# Support for encrypted kernel dumps
 options 	GZIO			# gzip-compressed kernel and user dumps
 options 	ZSTDIO			# zstd-compressed kernel and user dumps
+options 	DEBUGNET		# debugnet networking
 options 	NETDUMP			# netdump(4) client support
 
 # To make an SMP kernel, the next two lines are needed

Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c	Thu Oct 17 16:20:24 2019	(r353684)
+++ head/sys/kern/kern_mbuf.c	Thu Oct 17 16:23:03 2019	(r353685)
@@ -413,10 +413,10 @@ mbuf_init(void *dummy)
 }
 SYSINIT(mbuf, SI_SUB_MBUF, SI_ORDER_FIRST, mbuf_init, NULL);
 
-#ifdef NETDUMP
+#ifdef DEBUGNET
 /*
- * netdump makes use of a pre-allocated pool of mbufs and clusters.  When
- * netdump is configured, we initialize a set of UMA cache zones which return
+ * debugnet makes use of a pre-allocated pool of mbufs and clusters.  When
+ * debugnet is configured, we initialize a set of UMA cache zones which return
  * items from this pool.  At panic-time, the regular UMA zone pointers are
  * overwritten with those of the cache zones so that drivers may allocate and
  * free mbufs and clusters without attempting to allocate physical memory.
@@ -424,18 +424,28 @@ SYSINIT(mbuf, SI_SUB_MBUF, SI_ORDER_FIRST, mbuf_init, 
  * We keep mbufs and clusters in a pair of mbuf queues.  In particular, for
  * the purpose of caching clusters, we treat them as mbufs.
  */
-static struct mbufq nd_mbufq =
-    { STAILQ_HEAD_INITIALIZER(nd_mbufq.mq_head), 0, INT_MAX };
-static struct mbufq nd_clustq =
-    { STAILQ_HEAD_INITIALIZER(nd_clustq.mq_head), 0, INT_MAX };
+static struct mbufq dn_mbufq =
+    { STAILQ_HEAD_INITIALIZER(dn_mbufq.mq_head), 0, INT_MAX };
+static struct mbufq dn_clustq =
+    { STAILQ_HEAD_INITIALIZER(dn_clustq.mq_head), 0, INT_MAX };
 
-static int nd_clsize;
-static uma_zone_t nd_zone_mbuf;
-static uma_zone_t nd_zone_clust;
-static uma_zone_t nd_zone_pack;
+static int dn_clsize;
+static uma_zone_t dn_zone_mbuf;
+static uma_zone_t dn_zone_clust;
+static uma_zone_t dn_zone_pack;
 
+static struct debugnet_saved_zones {
+	uma_zone_t dsz_mbuf;
+	uma_zone_t dsz_clust;
+	uma_zone_t dsz_pack;
+	uma_zone_t dsz_jumbop;
+	uma_zone_t dsz_jumbo9;
+	uma_zone_t dsz_jumbo16;
+	bool dsz_debugnet_zones_enabled;
+} dn_saved_zones;
+
 static int
-nd_buf_import(void *arg, void **store, int count, int domain __unused,
+dn_buf_import(void *arg, void **store, int count, int domain __unused,
     int flags)
 {
 	struct mbufq *q;
@@ -448,7 +458,7 @@ nd_buf_import(void *arg, void **store, int count, int 
 		m = mbufq_dequeue(q);
 		if (m == NULL)
 			break;
-		trash_init(m, q == &nd_mbufq ? MSIZE : nd_clsize, flags);
+		trash_init(m, q == &dn_mbufq ? MSIZE : dn_clsize, flags);
 		store[i] = m;
 	}
 	KASSERT((flags & M_WAITOK) == 0 || i == count,
@@ -457,7 +467,7 @@ nd_buf_import(void *arg, void **store, int count, int 
 }
 
 static void
-nd_buf_release(void *arg, void **store, int count)
+dn_buf_release(void *arg, void **store, int count)
 {
 	struct mbufq *q;
 	struct mbuf *m;
@@ -472,7 +482,7 @@ nd_buf_release(void *arg, void **store, int count)
 }
 
 static int
-nd_pack_import(void *arg __unused, void **store, int count, int domain __unused,
+dn_pack_import(void *arg __unused, void **store, int count, int domain __unused,
     int flags __unused)
 {
 	struct mbuf *m;
@@ -483,12 +493,12 @@ nd_pack_import(void *arg __unused, void **store, int c
 		m = m_get(MT_DATA, M_NOWAIT);
 		if (m == NULL)
 			break;
-		clust = uma_zalloc(nd_zone_clust, M_NOWAIT);
+		clust = uma_zalloc(dn_zone_clust, M_NOWAIT);
 		if (clust == NULL) {
 			m_free(m);
 			break;
 		}
-		mb_ctor_clust(clust, nd_clsize, m, 0);
+		mb_ctor_clust(clust, dn_clsize, m, 0);
 		store[i] = m;
 	}
 	KASSERT((flags & M_WAITOK) == 0 || i == count,
@@ -497,7 +507,7 @@ nd_pack_import(void *arg __unused, void **store, int c
 }
 
 static void
-nd_pack_release(void *arg __unused, void **store, int count)
+dn_pack_release(void *arg __unused, void **store, int count)
 {
 	struct mbuf *m;
 	void *clust;
@@ -506,109 +516,142 @@ nd_pack_release(void *arg __unused, void **store, int 
 	for (i = 0; i < count; i++) {
 		m = store[i];
 		clust = m->m_ext.ext_buf;
-		uma_zfree(nd_zone_clust, clust);
-		uma_zfree(nd_zone_mbuf, m);
+		uma_zfree(dn_zone_clust, clust);
+		uma_zfree(dn_zone_mbuf, m);
 	}
 }
 
 /*
- * Free the pre-allocated mbufs and clusters reserved for netdump, and destroy
+ * Free the pre-allocated mbufs and clusters reserved for debugnet, and destroy
  * the corresponding UMA cache zones.
  */
 void
-netdump_mbuf_drain(void)
+debugnet_mbuf_drain(void)
 {
 	struct mbuf *m;
 	void *item;
 
-	if (nd_zone_mbuf != NULL) {
-		uma_zdestroy(nd_zone_mbuf);
-		nd_zone_mbuf = NULL;
+	if (dn_zone_mbuf != NULL) {
+		uma_zdestroy(dn_zone_mbuf);
+		dn_zone_mbuf = NULL;
 	}
-	if (nd_zone_clust != NULL) {
-		uma_zdestroy(nd_zone_clust);
-		nd_zone_clust = NULL;
+	if (dn_zone_clust != NULL) {
+		uma_zdestroy(dn_zone_clust);
+		dn_zone_clust = NULL;
 	}
-	if (nd_zone_pack != NULL) {
-		uma_zdestroy(nd_zone_pack);
-		nd_zone_pack = NULL;
+	if (dn_zone_pack != NULL) {
+		uma_zdestroy(dn_zone_pack);
+		dn_zone_pack = NULL;
 	}
 
-	while ((m = mbufq_dequeue(&nd_mbufq)) != NULL)
+	while ((m = mbufq_dequeue(&dn_mbufq)) != NULL)
 		m_free(m);
-	while ((item = mbufq_dequeue(&nd_clustq)) != NULL)
-		uma_zfree(m_getzone(nd_clsize), item);
+	while ((item = mbufq_dequeue(&dn_clustq)) != NULL)
+		uma_zfree(m_getzone(dn_clsize), item);
 }
 
 /*
- * Callback invoked immediately prior to starting a netdump.
+ * Callback invoked immediately prior to starting a debugnet connection.
  */
 void
-netdump_mbuf_dump(void)
+debugnet_mbuf_start(void)
 {
 
+	MPASS(!dn_saved_zones.dsz_debugnet_zones_enabled);
+
+	/* Save the old zone pointers to restore when debugnet is closed. */
+	dn_saved_zones = (struct debugnet_saved_zones) {
+		.dsz_debugnet_zones_enabled = true,
+		.dsz_mbuf = zone_mbuf,
+		.dsz_clust = zone_clust,
+		.dsz_pack = zone_pack,
+		.dsz_jumbop = zone_jumbop,
+		.dsz_jumbo9 = zone_jumbo9,
+		.dsz_jumbo16 = zone_jumbo16,
+	};
+
 	/*
 	 * All cluster zones return buffers of the size requested by the
 	 * drivers.  It's up to the driver to reinitialize the zones if the
-	 * MTU of a netdump-enabled interface changes.
+	 * MTU of a debugnet-enabled interface changes.
 	 */
-	printf("netdump: overwriting mbuf zone pointers\n");
-	zone_mbuf = nd_zone_mbuf;
-	zone_clust = nd_zone_clust;
-	zone_pack = nd_zone_pack;
-	zone_jumbop = nd_zone_clust;
-	zone_jumbo9 = nd_zone_clust;
-	zone_jumbo16 = nd_zone_clust;
+	printf("debugnet: overwriting mbuf zone pointers\n");
+	zone_mbuf = dn_zone_mbuf;
+	zone_clust = dn_zone_clust;
+	zone_pack = dn_zone_pack;
+	zone_jumbop = dn_zone_clust;
+	zone_jumbo9 = dn_zone_clust;
+	zone_jumbo16 = dn_zone_clust;
 }
 
 /*
- * Reinitialize the netdump mbuf+cluster pool and cache zones.
+ * Callback invoked when a debugnet connection is closed/finished.
  */
 void
-netdump_mbuf_reinit(int nmbuf, int nclust, int clsize)
+debugnet_mbuf_finish(void)
 {
+
+	MPASS(dn_saved_zones.dsz_debugnet_zones_enabled);
+
+	printf("debugnet: restoring mbuf zone pointers\n");
+	zone_mbuf = dn_saved_zones.dsz_mbuf;
+	zone_clust = dn_saved_zones.dsz_clust;
+	zone_pack = dn_saved_zones.dsz_pack;
+	zone_jumbop = dn_saved_zones.dsz_jumbop;
+	zone_jumbo9 = dn_saved_zones.dsz_jumbo9;
+	zone_jumbo16 = dn_saved_zones.dsz_jumbo16;
+
+	memset(&dn_saved_zones, 0, sizeof(dn_saved_zones));
+}
+
+/*
+ * Reinitialize the debugnet mbuf+cluster pool and cache zones.
+ */
+void
+debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize)
+{
 	struct mbuf *m;
 	void *item;
 
-	netdump_mbuf_drain();
+	debugnet_mbuf_drain();
 
-	nd_clsize = clsize;
+	dn_clsize = clsize;
 
-	nd_zone_mbuf = uma_zcache_create("netdump_" MBUF_MEM_NAME,
+	dn_zone_mbuf = uma_zcache_create("debugnet_" MBUF_MEM_NAME,
 	    MSIZE, mb_ctor_mbuf, mb_dtor_mbuf,
 #ifdef INVARIANTS
 	    trash_init, trash_fini,
 #else
 	    NULL, NULL,
 #endif
-	    nd_buf_import, nd_buf_release,
-	    &nd_mbufq, UMA_ZONE_NOBUCKET);
+	    dn_buf_import, dn_buf_release,

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-head mailing list