From owner-p4-projects@FreeBSD.ORG Sun Oct 28 17:59:07 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C088016A468; Sun, 28 Oct 2007 17:59:07 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6432D16A417; Sun, 28 Oct 2007 17:59:07 +0000 (UTC) (envelope-from zec@icir.org) Received: from xaqua.tel.fer.hr (xaqua.tel.fer.hr [161.53.19.25]) by mx1.freebsd.org (Postfix) with ESMTP id CA04913C4AC; Sun, 28 Oct 2007 17:59:06 +0000 (UTC) (envelope-from zec@icir.org) Received: by xaqua.tel.fer.hr (Postfix, from userid 20006) id 6F35D9B64D; Sun, 28 Oct 2007 18:59:04 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on xaqua.tel.fer.hr X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, HTML_MESSAGE autolearn=ham version=3.1.7 Received: from [192.168.200.100] (zec2.tel.fer.hr [161.53.19.79]) by xaqua.tel.fer.hr (Postfix) with ESMTP id C49869B64D; Sun, 28 Oct 2007 18:59:02 +0100 (CET) From: Marko Zec To: Julian Elischer Date: Sun, 28 Oct 2007 18:59:00 +0100 User-Agent: KMail/1.9.7 References: <200710250015.l9P0FXwh015801@repoman.freebsd.org> <472028E6.6090809@elischer.org> In-Reply-To: <472028E6.6090809@elischer.org> MIME-Version: 1.0 Message-Id: <200710281859.00823.zec@icir.org> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Perforce Change Reviews , Marko Zec Subject: Re: PERFORCE change 128041 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2007 17:59:08 -0000 On Thursday 25 October 2007 07:25:58 Julian Elischer wrote: > Marko Zec wrote: > > 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. > > by definition it would have to be a child vnet right? Yes. vimage_by_name(struct thread *toplevel, char *name) searches for a vimage bellow the position in the hierarchy pointed by toplevel, so it can never return a ptr to a vimage above the toplevel position, i.e. it can find only children of *toplevel. > > 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); > > }