From owner-freebsd-net@FreeBSD.ORG Mon May 19 13:07:27 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 46D591065671 for ; Mon, 19 May 2008 13:07:27 +0000 (UTC) (envelope-from john@roof1.dnepro.net) Received: from roof1.dnepro.net (a66.dnepro.net [212.3.111.66]) by mx1.freebsd.org (Postfix) with ESMTP id ADB1A8FC19 for ; Mon, 19 May 2008 13:07:25 +0000 (UTC) (envelope-from john@roof1.dnepro.net) Received: from roof1.dnepro.net (localhost [127.0.0.1]) by roof1.dnepro.net (8.14.1/8.14.1) with ESMTP id m4JD7MJ1045251 for ; Mon, 19 May 2008 16:07:23 +0300 (EEST) (envelope-from john@roof1.dnepro.net) Received: (from john@localhost) by roof1.dnepro.net (8.14.1/8.14.1/Submit) id m4JD7McV045250 for freebsd-net@freebsd.org; Mon, 19 May 2008 16:07:22 +0300 (EEST) (envelope-from john) Date: Mon, 19 May 2008 16:07:22 +0300 From: Eugene Perevyazko To: freebsd-net@freebsd.org Message-ID: <20080519130722.GA40822@roof1.dnepro.net> Mail-Followup-To: freebsd-net@freebsd.org References: <20080515152607.GA36663@roof1.dnepro.net> <482C6303.9000904@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <482C6303.9000904@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93, clamav-milter version 0.93 on roof1.dnepro.net X-Virus-Status: Clean Subject: Re: How to inject fullsize 802.1q-tagged frame through BPF? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 May 2008 13:07:27 -0000 On Thu, May 15, 2008 at 12:21:23PM -0400, Sam Leffler wrote: > Eugene Perevyazko wrote: > > Is there a way to inject full-mtu vlan-tagged frame through BPF on parent > >device? > > I'd like not to open several tenths of BPFs for each vlanN if it's > > possible. > > bpf write code in the kernel calculates header size when packets are > injected. This is likely based on the frames being stock 802.3 so would > require mods to the bpf code to handle the additional space for the tag. I've made a simple patch that works for me on FreeBSD 6.2-RELEASE #1. Not sure if this is the way to do it, but it "just works". May be someone else will need such feature too. Eugene Perevyazko --- bpf.c.old Mon May 19 10:47:55 2008 +++ bpf.c Mon May 19 10:57:44 2008 @@ -64,6 +64,7 @@ #include #include +#include #include #include @@ -617,7 +618,9 @@ return (0); bzero(&dst, sizeof(dst)); - error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, ifp->if_mtu, + /* Use VLAN_MTU capability, if supported */ + error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, + ifp->if_mtu + ( (ifp->if_capenable & IFCAP_VLAN_MTU) ? ETHER_VLAN_ENCAP_LEN : 0 ), &m, &dst, d->bd_wfilter); if (error) return (error);