TF_NEEDSYN flag never set.

Barry Spinney spinney at tilera.com
Sun Apr 28 22:33:01 UTC 2013


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>)




More information about the freebsd-net mailing list