From owner-freebsd-net@FreeBSD.ORG Thu Jan 9 21:40:55 2014 Return-Path: Delivered-To: net@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 E8AA2DC; Thu, 9 Jan 2014 21:40:55 +0000 (UTC) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id A5A39120F; Thu, 9 Jan 2014 21:40:55 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 3056C7300A; Thu, 9 Jan 2014 22:43:09 +0100 (CET) Date: Thu, 9 Jan 2014 22:43:09 +0100 From: Luigi Rizzo To: Adrian Chadd Subject: Re: unused in_cksum_update() ? Message-ID: <20140109214309.GA51309@onelab2.iet.unipi.it> References: <20140109192114.GA49934@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: "current@freebsd.org" , "net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2014 21:40:56 -0000 On Thu, Jan 09, 2014 at 01:27:52PM -0800, Adrian Chadd wrote: > It's likely used elsewhere; it's the kind of thing you abuse when > doing header rewriting and reinjection. So, what's the NAT and such > code using? natd/libalias has its own code with a DifferentialChecksum() function in sys/netinet/libalias/alias_util.c which adds and subtracts the chunks in the old and new packet. ip_fastfwd.c does it inline: /* * Decrement the TTL and incrementally change the IP header checksum. * Don't bother doing this with hw checksum offloading, it's faster * doing it right here. */ ip->ip_ttl -= IPTTLDEC; if (ip->ip_sum >= (u_int16_t) ~htons(IPTTLDEC << 8)) ip->ip_sum -= ~htons(IPTTLDEC << 8); else ip->ip_sum += htons(IPTTLDEC << 8); ip_forward() relies on the recomputation done in ip_output(). And there is no trace of in_cksum_update() in the entire source tree apart from its definition. cheers luigi