From owner-svn-src-all@FreeBSD.ORG Fri Nov 1 03:19:31 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 14822862; Fri, 1 Nov 2013 03:19:31 +0000 (UTC) (envelope-from jmg@h2.funkthat.com) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E274826FE; Fri, 1 Nov 2013 03:19:30 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id rA13JTJq062484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Oct 2013 20:19:30 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id rA13JSKw062483; Thu, 31 Oct 2013 20:19:28 -0700 (PDT) (envelope-from jmg) Date: Thu, 31 Oct 2013 20:19:28 -0700 From: John-Mark Gurney To: Luigi Rizzo Subject: Re: svn commit: r257455 - head/sys/net Message-ID: <20131101031928.GH58155@funkthat.com> References: <201310311546.r9VFkAIb049844@svn.freebsd.org> <20131031180336.GA62132@onelab2.iet.unipi.it> <5272AAC4.4030700@freebsd.org> <1383247645.31172.29.camel@revolution.hippie.lan> <20131031200502.GB83212@onelab2.iet.unipi.it> <20131031204916.GF58155@funkthat.com> <20131031211337.GA83561@onelab2.iet.unipi.it> <20131031221457.GG58155@funkthat.com> <20131031224106.GA84783@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131031224106.GA84783@onelab2.iet.unipi.it> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Thu, 31 Oct 2013 20:19:30 -0700 (PDT) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Andre Oppermann , Ian Lepore X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Nov 2013 03:19:31 -0000 Luigi Rizzo wrote this message on Thu, Oct 31, 2013 at 23:41 +0100: > On Thu, Oct 31, 2013 at 03:14:57PM -0700, John-Mark Gurney wrote: > > Luigi Rizzo wrote this message on Thu, Oct 31, 2013 at 22:13 +0100: > > > On Thu, Oct 31, 2013 at 01:49:16PM -0700, John-Mark Gurney wrote: > > > > Luigi Rizzo wrote this message on Thu, Oct 31, 2013 at 21:05 +0100: > > > > > On Thu, Oct 31, 2013 at 01:27:25PM -0600, Ian Lepore wrote: > > > > > ... > > > > > > Is there any chance all this reworking might get us to a position where > > > > > > the protocol header in an mbuf doesn't have to be 32-bit aligned > > > > > > anymore? We pay a pretty heavy price for that requirement in the > > > > > > drivers of the least capable hardware we support, the systems that have > > > > > > the least horsepower to spare to make an extra copy of each packet to > > > > > > realign it. > > > > > > > > > > So are you suggesting to use some 'copy_unaligned_32()' function/macro to > > > > > access 32-bit protocol fields in the network stack ? > > > > > (16-bit entries should not be an issue) > > > > > > > > my idea has been to make a change to the various ip/tcp/udp layers > > > > that is dependant upon __NO_STRICT_ALIGNMENT and if we do require > > > > strict alignment to copy the header to a stack buffer to align the > > > > data... > > > > > > I'd rather use accessors functions/macros to read/write > > > the unaligned headers so we can hide the #ifdefs in only > > > one place. > > > > I am/was trying to prevent massive code curn... > > > > > The copy to a stack buffer is probably useful even for readability > > > > Oh, I also realized I left out another part of it... > > > > void > > ip_input(struct mbuf *m) > > { > > #ifndef __NO_STRICT_ALIGNMENT > > struct ip tmpip; > > #endif > > struct ip *ip = NULL; > > > > #ifndef __NO_STRICT_ALIGNMENT > > bcopy(mtod(m, struct ip *), &tmpip, sizeof tmpip); > > ip = &tmpip; > > #else > > ip = mtod(m, struct ip *); > > #endif > > this is exactly what we shold NOT do. > Apart from the source bloat from conditional blocks, > easily someone will try to use ip to point to options > (which are not copied), etc etc. > > Just copy the header unconditionally, or probably just the > source and destination IP which under normal assumptions > (14 byte mac header) are the only ones where alignment breaks. > Then of course options will have similar problems. > > This is why I think we should use accessors if we want > to solve this problem. Can we get those accessors in ASAP and start requiring new code to use them? The longer we wait, the bigger the work when it happens, and longer that people will put it off... I've been waiting for 5+ years for this (and time to work on it)... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."