From owner-freebsd-hackers Sun Apr 21 06:51:31 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id GAA19128 for hackers-outgoing; Sun, 21 Apr 1996 06:51:31 -0700 (PDT) Received: from ledoux.arbld.unimelb.EDU.AU (ledoux.arbld.unimelb.EDU.AU [128.250.133.13]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id GAA19123 for ; Sun, 21 Apr 1996 06:51:28 -0700 (PDT) Received: (from uucp@localhost) by ledoux.arbld.unimelb.EDU.AU (8.6.12/8.6.12) id XAA26730 for ; Sun, 21 Apr 1996 23:51:26 +1000 Received: from vitruvius.arbld.unimelb.edu.au(128.250.136.1) by ledoux.arbld.unimelb.EDU.AU via smap (V1.3) id sma026726; Sun Apr 21 23:51:05 1996 Received: (from darrenr@localhost) by vitruvius.arbld.unimelb.EDU.AU (8.6.12/8.6.12) id XAA10529 for hackers@freebsd.org; Sun, 21 Apr 1996 23:51:03 +1000 From: Darren Reed Message-Id: <199604211351.XAA10529@vitruvius.arbld.unimelb.EDU.AU> Subject: one less checksum ? (fwd) To: hackers@freebsd.org Date: Sun, 21 Apr 1996 23:51:03 +1000 (EST) X-Mailer: ELM [version 2.4 PL24] 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 ? darren *** ip_input.c.orig Wed Sep 6 20:31:35 1995 --- ip_input.c Sun Apr 21 12:12:53 1996 *************** *** 197,204 **** } ip = mtod(m, struct ip *); } ! ip->ip_sum = in_cksum(m, hlen); ! if (ip->ip_sum) { ipstat.ips_badsum++; goto bad; } --- 201,207 ---- } ip = mtod(m, struct ip *); } ! if (in_cksum(m, hlen)) { ipstat.ips_badsum++; goto bad; } *** ip_output.c.orig Wed Sep 6 20:31:40 1995 --- ip_output.c Sun Apr 21 19:41:53 1996 *************** *** 319,326 **** if ((u_short)ip->ip_len <= ifp->if_mtu) { ip->ip_len = htons((u_short)ip->ip_len); ip->ip_off = htons((u_short)ip->ip_off); ! ip->ip_sum = 0; ! ip->ip_sum = in_cksum(m, hlen); error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, ro->ro_rt); goto done; --- 338,352 ---- if ((u_short)ip->ip_len <= ifp->if_mtu) { ip->ip_len = htons((u_short)ip->ip_len); ip->ip_off = htons((u_short)ip->ip_off); ! if (flags & IP_FORWARDING) { ! u_long sum = (u_long)ip->ip_sum; ! sum++; ! sum += (sum >> 16); ! ip->ip_sum = (u_short)(sum & 0x0000ffff); ! } else { ! ip->ip_sum = 0; ! ip->ip_sum = in_cksum(m, hlen); ! } error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, ro->ro_rt); goto done;