From owner-freebsd-net Thu Mar 7 12:31:19 2002 Delivered-To: freebsd-net@freebsd.org Received: from smtpout.mac.com (smtpout.mac.com [204.179.120.89]) by hub.freebsd.org (Postfix) with ESMTP id 036C737B404 for ; Thu, 7 Mar 2002 12:31:13 -0800 (PST) Received: from smtp-relay01.mac.com (server-source-si02 [10.13.10.6]) by smtpout.mac.com (8.12.1/8.10.2/1.0) with ESMTP id g27KVCth000556 for ; Thu, 7 Mar 2002 12:31:12 -0800 (PST) Received: from asmtp01.mac.com ([10.13.10.65]) by smtp-relay01.mac.com (Netscape Messaging Server 4.15 relay01 Jun 21 2001 23:53:48) with ESMTP id GSMEC000.FQF for ; Thu, 7 Mar 2002 12:31:12 -0800 Received: from grinch ([12.234.224.67]) by asmtp01.mac.com (Netscape Messaging Server 4.15 asmtp01 Jun 21 2001 23:53:48) with ESMTP id GSMEBZ00.E9E for ; Thu, 7 Mar 2002 12:31:11 -0800 Date: Thu, 7 Mar 2002 12:31:10 -0800 Subject: Re: icmp related question Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v475) From: "Justin C. Walker" To: Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <42D1F914-320A-11D6-BB09-00306544D642@mac.com> X-Mailer: Apple Mail (2.475) Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Thursday, March 7, 2002, at 02:05 AM, Kshitij Gunjikar wrote: > Hi All, > Hi I'm studying code for ICMP . > > there is a piece of code in icmp_input which just returns when we find > the > ICMP packet length lesser than allowed. > > if (icmplen < ICMP_MINLEN) { > icmpstat.icps_tooshort++; > goto freeit; > } > i = hlen + min(icmplen, ICMP_ADVLENMIN); > if (m->m_len < i && (m = m_pullup(m, i)) == 0) { > icmpstat.icps_tooshort++; > return; > } > where #define ICMPADVELMIN (8 + sizeof(struct ip) + 8) > and icmplen = ip->ip_len ; > > > why the return? Shouldn't there be a freeing of the msg.i.e call the > m_freem(m) instead of return ? If you look at the last 'if' statement, you'll notice that the call to m_pullup() has returned NULL, which means that the mbuf has been freed already (or, in any case, at this point in the code, there is no mbuf to free, due to the assignment). Regards, Justin -- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | When LuteFisk is outlawed | Only outlaws will have | LuteFisk *--------------------------------------*-------------------------------* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message