From owner-freebsd-arch@FreeBSD.ORG Thu May 29 04:04:28 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BD3ED452; Thu, 29 May 2014 04:04:28 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 5859F2676; Thu, 29 May 2014 04:04:27 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.8/8.14.8) with ESMTP id s4T44Ptg087664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 29 May 2014 08:04:25 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.8/8.14.8/Submit) id s4T44PtP087663; Thu, 29 May 2014 08:04:25 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 29 May 2014 08:04:25 +0400 From: Gleb Smirnoff To: Rui Paulo Subject: Re: Roadmap for ifnet(9) for FreeBSD 11 Message-ID: <20140529040425.GT50679@glebius.int.ru> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Anuranjan Shukla , "freebsd-arch@FreeBSD.org Arch" , Marcel Moolenaar X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2014 04:04:28 -0000 On Wed, May 28, 2014 at 08:48:11PM -0700, Rui Paulo wrote: R> On May 28, 2014, at 9:34, Marcel Moolenaar wrote: R> R> > All, R> > R> > The ifnet structure represents a network interface. Right now it R> > is known to all NIC drivers as well as to all protocols. This R> > means that whenever we change the structure, we need at minimum R> > recompile all drivers, but usually also change them. This severely R> > slow downs the development in this area and also makes it hard, if R> > not, impossible to merge things back to stable branches. R> > R> > There were at least 3 efforts on fixing this: R> > R> > 1) Juniper’s JUNOS is a FreeBSD based operating system that has R> > its own (alternative) network stack, but that leverages the R> > network drivers from FreeBSD. Juniper mechanically changed all R> > ifnet dereferences to to accessor methods. This could have R> > been incorporated as early as 2011, but lacked good follow R> > through. Marcel Moolenaar was prime contact for this. R> > R> > 2) Andre Oppermann was sponsored in 2013 by the FreeBSD R> > Foundation to make ifnet(9) opaque. This is not complete as of R> > the time of this writing. R> > R> > 3) Gleb Smirnoff also planned to work on opaque ifnet(9), but R> > that always has been delayed due to 1) and 2). R> R> This is indeed needed, but it would be nice to understand what would happen if the community has comments about your patch. Will Juniper be able to integrate back those comments? For example, I think the type "if_t" should be "ifnet_t". Another comment I have is: why do you have to cast if_t to (struct ifnet *) in all the accessor methods? It would be better to create a private header typedef'ing if_t to struct ifnet, avoiding the copy & paste casting. Because for now patch supports compiling unconverted drivers. This requires to pass 'void *' as argument. When all drivers are converted, this will be removed. In if_var.h we would have: struct ifnet; typedef struct ifnet * if_t; All casts to (struct ifnet *) will go away. Speaking of the 'if_t' vs "ifnet_t'. The pros of if_t are: - The functions in API all begin with 'if_', so we are inline with that. - Once a driver is converted 'grep ifnet if_driver.c' will return 0, but will return 1 on unconverted driver. That's nice. - We had a really nice comment in if_var.h that originates from 4.4BSD: /* * Structure defining a network interface. * * (Would like to call this struct ``if'', but C isn't PL/1.) */ Originally the idea was to have 'struct if', but that is impossible. So the 'net' prefix was added as a workaround, that we do not need to carry now. And yes, the 'net' is a tautology. All stuff resides in the sys/net directory, so no need to repeat 'net' again. In the kernel the word 'interface' applies only to network interfaces, no need to repeat 'net' extra time. - It is shorter. -- Totus tuus, Glebius.