TF_NEEDSYN flag never set.

Mark Johnston markjdb at gmail.com
Sun Apr 28 23:05:03 UTC 2013


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<ftp://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.


More information about the freebsd-net mailing list