From owner-freebsd-net@FreeBSD.ORG Sun Apr 28 23:05:03 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 12F9B2EA for ; Sun, 28 Apr 2013 23:05:03 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-ie0-x231.google.com (mail-ie0-x231.google.com [IPv6:2607:f8b0:4001:c03::231]) by mx1.freebsd.org (Postfix) with ESMTP id DC2311A5A for ; Sun, 28 Apr 2013 23:05:02 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id 9so6767263iec.36 for ; Sun, 28 Apr 2013 16:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=L0kIrN91jkT4TcDOuvecUQGhyxCg9qUqL7QifSyv0Ek=; b=SScj9re72y9Xf40Ua74yX1Sxop+uqoLAJQY7YKxBwJFXvZWGWd7qnI2nu2aKJI7BMl 7sPypIqaVCP5Vcgcnv/CNDmBvzMhCEPSiYn8GJ8kRQVDTgDR8eW7bCMOHCF3k/1kp3eM 2zQrgdM548Kgv+8DF4j4MypSOuMBGwvvYVsDH4o7dxyRNKE0pscOdz7nmu/vUeftkjCh FbrLt9pNOyw8DdHBkua0YdwvnNosfpD9tUWaTTIaGAwznDxhQf7vOX8I9dzTnMtRM/6n Qz/japhqmgwecibdDksoRdvvslpRcQPQOOH1BaEErPVDfYTn07lahIXuLyPwnl/UAtZv y4Lg== X-Received: by 10.42.64.69 with SMTP id f5mr28046489ici.29.1367190302674; Sun, 28 Apr 2013 16:05:02 -0700 (PDT) Received: from gloom ([66.11.160.35]) by mx.google.com with ESMTPSA id c2sm14726452igv.1.2013.04.28.16.05.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Apr 2013 16:05:01 -0700 (PDT) Date: Sun, 28 Apr 2013 19:04:54 -0400 From: Mark Johnston To: Barry Spinney Subject: Re: TF_NEEDSYN flag never set. Message-ID: <20130428230454.GA31215@gloom> References: <73BC01C897E9F642AC962BF311A45ACB100B0057@USMAExch1.tad.internal.tilera.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73BC01C897E9F642AC962BF311A45ACB100B0057@USMAExch1.tad.internal.tilera.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "freebsd-net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2013 23:05:03 -0000 On Sun, Apr 28, 2013 at 10:31:48PM +0000, Barry Spinney wrote: > I am sorry if this is a dumb question, but I was trying to understand the FreeBSD TCP stack, > and In particular I was trying to understand the use of the TF_NEEDSYN flag. This flag > is referenced a number of times in tcp_input.c and tcp_output.c, but I don't think that > it can ever be set. > > In particular grepping through the "../src/sys/netinet", one discovers that the only code > that can set this flag is lines 1018 and 1020 of tcp_input.c. But, it appears to me that > none of the lines in tcp_input.c from 999 thru 1023 are even reachable! The reason they > are not reachable is because just ahead of them are the following lines: > > if (!syncache_add(&inc, &to, th, &so, m)) > goto drop; > if (so == NULL) { > ... // uninteresting lines, but no gotos > return; > } > ... /unreachable code here > > > Studying syncache_add (in file tcp_syncache.c), reveals three return statements. > One of the returns, returns the value 0, which will cause the "goto drop" to be executed. > The other two returns, return both the value 1 AND set "*sop = NULL", which should cause > the following "if (so == NULL)" to execute the subsequent return statement. > > Is this intentional? (i.e. dead code awaiting future development?), or a bug? > Or I am going blind to something obvious? > > Thanx Barry Spinney. > > (p.s. I doubt it matters which version of code, but to be precise this is from the > /pub/FreeBSD/development/tarballs named "src_stable_6.tar.gz" dated "4/21/2013 01:15 AM", > gotten from ftp1.us.freebsd.org) That tarball presumably contains sources for the stable branch of FreeBSD 6, which probably isn't what you're looking for - the last release from that branch was in 2008. The relevant code in FreeBSD-CURRENT is different and your observations don't seem to apply there. Based on a comment added in r156125, you seem to be correct though. :) http://svnweb.freebsd.org/base?view=revision&revision=156125 I'd suggest fetching src_current.tar.gz from the FTP same directory and looking at that instead - you're more likely to get replies to questions about the current tip of development.