From owner-freebsd-current@FreeBSD.ORG Fri Jan 10 18:22:39 2014 Return-Path: Delivered-To: current@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 ESMTPS id 8D7C19CB; Fri, 10 Jan 2014 18:22:39 +0000 (UTC) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 0D44F12C8; Fri, 10 Jan 2014 18:22:33 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 93EFB7300A; Fri, 10 Jan 2014 19:24:48 +0100 (CET) Date: Fri, 10 Jan 2014 19:24:48 +0100 From: Luigi Rizzo To: Gleb Smirnoff , wollman@freebsd.org Subject: Re: unused in_cksum_update() ? Message-ID: <20140110182448.GA62317@onelab2.iet.unipi.it> References: <20140109192114.GA49934@onelab2.iet.unipi.it> <20140110103140.GD73147@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140110103140.GD73147@FreeBSD.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: current@freebsd.org, net@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 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: Fri, 10 Jan 2014 18:22:39 -0000 On Fri, Jan 10, 2014 at 02:31:40PM +0400, Gleb Smirnoff wrote: > On Thu, Jan 09, 2014 at 08:21:14PM +0100, Luigi Rizzo wrote: > L> a lot of arch-specific headers (sys/${ARCH}/include/in_cksum.h) > L> have a lengthy definition for > L> > L> in_cksum_update(struct ip *ip) > L> > L> which seems completely unused in our source tree. > L> Time to remove it perhaps ? > L> > L> grep cannot find any use at least since stable/8 > > I'd prefer not to hurry with its removal. Might be that pf will use it. > Since it lives in a header file, it doesn't add a single bit to kernel > size. we should care more about obfuscation and correcteness, and this is a killer in both respects. Depending on $arch the function is not even available or wrong: In particular, the basic code follows the description in http://tools.ietf.org/html/rfc1141A with ntohs/htons to deal with endianness (note that the '256' should not be converted): tmp = ntohs(sum)+256; tmp = tmp + (tmp >> 16); sum = htons(tmp); // also truncates high bits It is correctly implemented (but in a totally generic way, so no point to have it in the arch-specific files) for amd64, i386, ia64, mips, powerpc; it is not implemented for arm, and it is wrong for sparc64 (where the 256 is incorrectly replaced by a 1). In terms of usage: the svn repo suggests that it was added in r15884 in 1996 (stable/2.2 is the first branch where it appears): http://svnweb.freebsd.org/base/head/sys/i386/include/in_cksum.h?r1=15884&r2=15883&pathrev=15884 as far as i can tell never used anywhere, and copied from place to place when we started to support different architectures. Shall we wait until it becomes 18 ? :) I am adding Garret to the list as he may have more details. cheers luigi