From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 23 13:31:32 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D860416A4CF; Wed, 23 Mar 2005 13:31:32 +0000 (GMT) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id B008443D5A; Wed, 23 Mar 2005 13:31:31 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received-SPF: pass (mp2.macomnet.net: domain of maxim@macomnet.ru designates 127.0.0.1 as permitted sender) receiver=mp2.macomnet.net; client_ip=127.0.0.1; envelope-from=maxim@macomnet.ru; Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.12.11/8.12.11) with ESMTP id j2NDVTag004457; Wed, 23 Mar 2005 16:31:29 +0300 (MSK) (envelope-from maxim@macomnet.ru) Date: Wed, 23 Mar 2005 16:31:29 +0300 (MSK) From: Maxim Konovalov To: Vijay.Singh@nokia.com In-Reply-To: Message-ID: <20050323155414.S99626@mp2.macomnet.net> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org cc: silby@freebsd.org cc: andre@freebsd.org Subject: Re: ip_reass() - possibly incorrect goto X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2005 13:31:33 -0000 On Tue, 22 Mar 2005, 12:08-0800, Vijay.Singh@nokia.com wrote: > Hi hackers, I am looking at the ip_reass() routine. In case of the > 1st fragment we create the reassembly queue. After the queue has > been inserted in the hash bucket, the if () code does a " goto > inserted". Should this be changed to "goto done" instead? Any code > that is executed for the 1st fragment, like frag per packet limiting > and complete reassembly are not valid. Am I mistaken? Yep, it seems you are right. The second micro optimization - drop the fragment early if maxfragsperpacket == 0. Andre, Mike, what do you think? Index: ip_input.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v retrieving revision 1.299 diff -u -r1.299 ip_input.c --- ip_input.c 16 Mar 2005 05:27:19 -0000 1.299 +++ ip_input.c 23 Mar 2005 13:12:00 -0000 @@ -801,8 +801,8 @@ u_int8_t ecn, ecn0; u_short hash; - /* If maxnipq is 0, never accept fragments. */ - if (maxnipq == 0) { + /* If maxnipq or maxfragsperpacket are 0, never accept fragments. */ + if (maxnipq == 0 || maxfragsperpacket == 0) { ipstat.ips_fragments++; ipstat.ips_fragdropped++; m_freem(m); @@ -918,7 +918,7 @@ fp->ipq_dst = ip->ip_dst; fp->ipq_frags = m; m->m_nextpkt = NULL; - goto inserted; + goto done; } else { fp->ipq_nfrags++; #ifdef MAC @@ -998,8 +998,6 @@ m_freem(q); } -inserted: - /* * Check for complete reassembly and perform frag per packet * limiting. %%% -- Maxim Konovalov