From owner-freebsd-hackers Sun Apr 21 13:31:35 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id NAA05019 for hackers-outgoing; Sun, 21 Apr 1996 13:31:35 -0700 (PDT) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id NAA05012 for ; Sun, 21 Apr 1996 13:31:28 -0700 (PDT) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id WAA29029; Sun, 21 Apr 1996 22:26:10 +0200 From: Luigi Rizzo Message-Id: <199604212026.WAA29029@labinfo.iet.unipi.it> Subject: Re: one less checksum ? (fwd) To: darrenr@vitruvius.arbld.unimelb.edu.au (Darren Reed) Date: Sun, 21 Apr 1996 22:26:10 +0200 (MET DST) Cc: hackers@FreeBSD.ORG In-Reply-To: <199604211351.XAA10529@vitruvius.arbld.unimelb.EDU.AU> from "Darren Reed" at Apr 21, 96 11:50:44 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Is there any reason why the result of in_cksum() is stored in ip_sum in > ipintr() ? > > A small gain can be observed if this is not done, for forwarded packets, > by altering the checksum in ip_output() if IP_FORWARDING is set rather > than recalculating the entire header checksum. Is this worthwhile ? TCP/IP Illustrated vol.1 suggests something similar, so I'd say it is worthwhile. Garret Wollman should be looking after this code right in these days. But I don't understand how you relate your code (which looks correct) with the above comment. It looks like your code is computing the checksum in the same place, just with a more efficient algorithm. The same code fragments suggest some more optimizations when if_forwarding is enabled, e.g. don't convert header fields (ip_len and ip_off) for back and forth from network format. Luigi