Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Oct 2007 00:15:33 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 128041 for review
Message-ID:  <200710250015.l9P0FXwh015801@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=128041

Change 128041 by zec@zec_tpx32 on 2007/10/25 00:15:01

	A hack to allow for bpf taps to be open directly on ifnets
	attached to foreign vnets.
	
	ifname@vimage_name is the form that should be used for
	tcpdump or ethereal to attach directly to an ifnet in
	a foerign vnet.

Affected files ...

.. //depot/projects/vimage/src/sys/net/bpf.c#15 edit

Differences ...

==== //depot/projects/vimage/src/sys/net/bpf.c#15 (text+ko) ====

@@ -1156,9 +1156,32 @@
 	struct bpf_if *bp;
 	struct ifnet *theywant;
 
+#define IMUNES_BPF_HACK
+#if defined(VIMAGE) && defined(IMUNES_BPF_HACK)
+	struct vnet *target_vnet = curvnet;
+	char *c;
+
+	/* Hack to support tapping in foreign vnets */
+	c = rindex(ifr->ifr_name, '@');
+	if ( c != NULL ) {
+		struct vimage *target_vimage;
+
+		*c++ = 0;
+		target_vimage = vimage_by_name(TD_TO_VIMAGE(curthread), c);
+		if (target_vimage == NULL)
+			return ENXIO;
+		target_vnet = target_vimage->v_net;
+        }
+	CURVNET_SET_QUIET(target_vnet);
+#endif
+
 	theywant = ifunit(ifr->ifr_name);
-	if (theywant == NULL || theywant->if_bpf == NULL)
+	if (theywant == NULL || theywant->if_bpf == NULL) {
+#if defined(VIMAGE) && defined(IMUNES_BPF_HACK)
+		CURVNET_RESTORE();
+#endif
 		return (ENXIO);
+	}
 
 	bp = theywant->if_bpf;
 	/*
@@ -1180,6 +1203,9 @@
 	BPFD_LOCK(d);
 	reset_d(d);
 	BPFD_UNLOCK(d);
+#if defined(VIMAGE) && defined(IMUNES_BPF_HACK)
+	CURVNET_RESTORE();
+#endif
 	return (0);
 }
 



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