From owner-freebsd-current@FreeBSD.ORG Wed Oct 13 21:52:13 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F2CF16A4CE; Wed, 13 Oct 2004 21:52:13 +0000 (GMT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3E10E43D1F; Wed, 13 Oct 2004 21:52:13 +0000 (GMT) (envelope-from sam@errno.com) Received: from [66.127.85.93] ([66.127.85.93]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.6) with ESMTP id i9DLqCWi004903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Oct 2004 14:52:12 -0700 (PDT) (envelope-from sam@errno.com) Message-ID: <416DA3A2.9020702@errno.com> Date: Wed, 13 Oct 2004 14:52:34 -0700 From: Sam Leffler Organization: Errno Consulting User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ruslan Ermilov References: <9256D57F598E6C41B288AA7DB94F29C902DFB963@pgnmail1.pgnaplikace.cz> <20041012140205.GD29433@cell.sick.ru> <416BFE30.2090308@errno.com> <20041012185129.GA86935@ip.net.ua> <416C3C77.20406@errno.com> <20041013064227.GA1338@ip.net.ua> <416D4EE6.1080109@errno.com> <20041013162307.GA4987@ip.net.ua> In-Reply-To: <20041013162307.GA4987@ip.net.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-current@freebsd.org cc: Gleb Smirnoff Subject: Re: Broadcom bge and 802.1Q vlan tags X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2004 21:52:13 -0000 Ruslan Ermilov wrote: > On Wed, Oct 13, 2004 at 08:51:02AM -0700, Sam Leffler wrote: > >>Ruslan Ermilov wrote: >> >>>Hi Sam, >>> >>>On Tue, Oct 12, 2004 at 01:20:07PM -0700, Sam Leffler wrote: >>> >>> >>>>>>This pessimizes normal traffic. >>>>> >>>>>m_tag_locate() doesn't look like a very expensive function. And >>>>>with the "normal traffic", I don't expect to be more than one tag, >>>>>no? Also, if if_nvlans > 0, this is already "pessimized". >>>>> >>>>> >>>>> >>>>> >>>>>>We should look for a solution in the >>>>>>driver(s) to avoid sending packets up with tags when no vlans are >>>>>>configured. >>>>>> >>>>> >>>>>I'd be opposed to such a change in behavior. The VLAN consumer can >>>>>be not only vlan(4), it can equally be the ng_vlan(4) node, etc. >>>> >>>>I'm not sure what you are opposed to or why. The issue I have is that >>>>m_tag_locate can be expensive if many packets have tags. The check for >>>>the existence of vlans configured on the interface short-circuits this >>>>work. That vlan-tagged packets may be generated when no vlans are >>>>configured seems wrong to me and breaks the assumption used to write the >>>>code. Changing the driver to drop the frame if ifp->if_nvlans is zero >>>>seems straightforward and could probably be hidden in the existing macro. >>>> >>> >>>Please take a moment and re-read what I've already said: vlan(4) is not >>>the only consumer of VLAN frames: ng_vlan(4) is another such one, and I >>>have a proprietary Netgraph node here that demultiplexes VLANs. If you >>>start dropping VLAN frames in drivers when if_nvlans == 0, this will be >>>a problem for me. Is that clear now? >>> >>> >>>Cheers, >> >>I've read what you've written but you also haven't explained why you >>can't signal the presence of these other entities in some way. >> > > Because these other entities don't have an access to "ifp", and can > even exist on remote host (please see below). > > >>The >>current mechanism to signal the presence of "interested parties" for >>vlan-tagged frames is ifp->if_nvlans. You are saying you have new >>(proprietary) code that is interested in vlans but will not use the >>existing mechanism. My reaction is fix your code, don't pessimize the >>code everyone else uses without netgraph. >> > > But ng_vlan(4) is part of the standard FreeBSD distribution, and you > don't have access to "ifp" inside ng_vlan(4), because it's connected > to the interface indirectly, through the ng_ether(4) node. Even worse, > ng_vlan(4) may not even be connected to a local interface, for example, > you can capture and tunnel all Ethernet traffic to another host, and > do the VLAN processing there, FWIW. > > So while ifp->if_nvlans seems to be a good signalling mechamism for > vlan(4), it's not suitable for ng_vlan(4) and other Netgraph code > that works with VLAN. This code works now, and I'm afraid it will > break if we change drivers to drop VLAN frames if if_nvlans == 0, > and I fail to see how I can make it work again after that. > > In other words, I want that ng_ether(4) continues to see VLAN frames > even if no vlan(4) interfaces are configured, like it does now: the > ng_ether processing is done in ether_input() before ether_demux() > that checks for ifp->if_nvlans. > > OTOH, you may be right that one option would be to make ng_ether(4) > increment ifp->if_nvlans, but I'm a little worried about the effect > of doing this on the VLAN_OUTPUT_TAG macro (it looks safe, but I'm > not sure). I'm open to changing the mechanism by which we signal the presence of vlans and/or "interested parties" (or the presence of a h/w tag). However I believe if_nvlans is managed entirely in if_vlan.c and bumping it when ng_vlan is present would be ok (if that's feasible). OTOH this issue exists only because running the tag list for every packet can potentially be expensive. I recall cjsp (?) wanting to optimize this better so another tact is to look (again) at how to speed this up for the most common/important cases. Vlans may be important enough to assign an mbuf flag bit though I'd prefer to do that as a last resort (and I'm sure other folks would popup and want a bit too :)). Sam