From owner-freebsd-net@FreeBSD.ORG Sun Mar 4 07:05:03 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A7EDB16A400 for ; Sun, 4 Mar 2007 07:05:03 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.freebsd.org (Postfix) with ESMTP id 2092B13C478 for ; Sun, 4 Mar 2007 07:05:01 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.4) with ESMTP id l2474wDL047568; Sun, 4 Mar 2007 10:04:59 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.4/Submit) id l2474wOv047567; Sun, 4 Mar 2007 10:04:58 +0300 (MSK) (envelope-from yar) Date: Sun, 4 Mar 2007 10:04:58 +0300 From: Yar Tikhiy To: Bruce M Simpson Message-ID: <20070304070458.GG40430@comp.chem.msu.su> References: <45E8B964.2090200@incunabulum.net> <20070303215359.GB40430@comp.chem.msu.su> <45EA0756.2000107@incunabulum.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45EA0756.2000107@incunabulum.net> User-Agent: Mutt/1.5.9i Cc: freebsd-net@freebsd.org Subject: Re: [PATCH] Ethernet cleanup; 802.1p input and M_PROMISC 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: Sun, 04 Mar 2007 07:05:03 -0000 On Sat, Mar 03, 2007 at 11:40:06PM +0000, Bruce M Simpson wrote: > Yar Tikhiy wrote: > > > >In fact, there two independent flags indicating interface's readiness: > >IFF_UP and IFF_DRV_RUNNING. The former is controlled by the admin > >and the latter, by the driver. E.g., an interface can be UP but > >not really ready to operate due to h/w reasons, or vice versa. > >Perhaps we should check both flags to see if the interface is, so > >to say, up and running. if_vlan.c has an obvious macro for that, > >and it can go to if_var.h to avoid code duplication if we decide it's > >the right way to take. > > > Thanks for looking at this. > > The purpose of the IFF_UP check is to immediately drop frames destined > for an interface which is administratively configured down. > > Surely if ether_input() is called from the driver, there should be no > need to check IFF_DRV_RUNNING? Indeed if the hardware flips to a state > where it is not running but its internal queues or descriptor rings are > draining, this might cause frames to be lost? Now I see your point, thanks! Well, at least in theory, the driver shouldn't call ether_input() if the interface isn't running. OTOH, the interface shouldn't be getting traffic if it's !UP. However, I suspect that not all drivers handle IFF_UP fully or even can do it at all due to hardware limitations. As I understand it, in an ideal world a !UP interface should be deaf and dumb and not interfering in any way with the network still connected to it physically. Therefore discarding inbound traffic from a !UP interface may be a necessary workaround, but it may not be enough. All that boils down to this: The IFF_UP check in ether_input() is more to a sanity check than to the way for IFF_UP to work. Therefore we can add the IFF_DRV_RUNNING sanity check there, too, for completeness. -- Yar