Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753339AbcLKIH3 (ORCPT ); Sun, 11 Dec 2016 03:07:29 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:26330 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbcLKIH2 (ORCPT ); Sun, 11 Dec 2016 03:07:28 -0500 Date: Sun, 11 Dec 2016 09:07:18 +0100 From: Willy Tarreau To: "Jason A. Donenfeld" Cc: David Miller , Dave Taht , Netdev , linux-mips@linux-mips.org, LKML , WireGuard mailing list Subject: Re: Misalignment, MIPS, and ip_hdr(skb)->version Message-ID: <20161211080718.GA7253@1wt.eu> References: <20161207.145240.1636297838792223189.davem@davemloft.net> <20161207.193716.50344961208535056.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1318 Lines: 30 Hi Jason, On Thu, Dec 08, 2016 at 11:20:04PM +0100, Jason A. Donenfeld wrote: > Hi David, > > On Thu, Dec 8, 2016 at 1:37 AM, David Miller wrote: > > You really have to land the IP header on a proper 4 byte boundary. > > > > I would suggest pushing 3 dummy garbage bytes of padding at the front > > or the end of your header. > > Are you sure 3 bytes to get 4 byte alignment is really the best? It's always the best. However there's another option which should be considered : maybe it's difficult but not impossible to move some bits from the current protocol to remove one byte. That's not always easy, and sometimes you cannot do it just for one bit. However after you run through this exercise, if you notice there's really no way to shave this extra byte, you'll realize there's no room left for future extensions and you'll more easily accept to add 3 empty bytes for this, typically protocol version, tags, qos or flagss that you'll be happy to rely on for future versions of your protocol. Also while it can feel like you're making your protocol less efficient, keep in mind that these 3 bytes only matter for small packets, and Ethernet already pads small frames to 64 bytes, so in practice any IP packet smaller than 46 bytes will not bring any extra savings. Best regards, Willy