--- sys/netinet/tcp_syncache.c (revision 50) +++ sys/netinet/tcp_syncache.c (working copy) @@ -97,6 +97,11 @@ #include +#include +#include +#include +#include + static VNET_DEFINE(int, tcp_syncookies) = 1; #define V_tcp_syncookies VNET(tcp_syncookies) SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, syncookies, CTLFLAG_RW, @@ -200,6 +205,11 @@ #define SCH_UNLOCK(sch) mtx_unlock(&(sch)->sch_mtx) #define SCH_LOCK_ASSERT(sch) mtx_assert(&(sch)->sch_mtx, MA_OWNED) +struct stack *st; +struct mtx st_mtx; +struct sbuf st_sb; +char st_trace[65536]; + /* * Requires the syncache entry to be already removed from the bucket list. */ @@ -223,6 +233,10 @@ { int i; + st = stack_create(); + mtx_init(&st_mtx, "tcp_sc_stack", NULL, MTX_DEF); + sbuf_new(&st_sb, st_trace, sizeof(st_trace), SBUF_FIXEDLEN); + V_tcp_syncache.cache_count = 0; V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE; V_tcp_syncache.bucket_limit = TCP_SYNCACHE_BUCKETLIMIT; @@ -277,6 +291,10 @@ struct syncache *sc, *nsc; int i; + sbuf_delete(&st_sb); + mtx_destroy(&st_mtx); + stack_destroy(st); + /* Cleanup hash buckets: stop timers, free entries, destroy locks. */ for (i = 0; i < V_tcp_syncache.hashsize; i++) { @@ -949,11 +967,27 @@ *lsop = syncache_socket(sc, *lsop, m); - if (*lsop == NULL) + if (*lsop == NULL) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) + log(LOG_DEBUG, "%s; %s: SEQ %u, ACK %u, syncache_socket() " + "failed\n", s, __func__, th->th_seq, th->th_ack); TCPSTAT_INC(tcps_sc_aborted); - else + } + else { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) + log(LOG_DEBUG, "%s; %s: SEQ %u, ACK %u, syncache_socket() " + "succeed\n", s, __func__, th->th_seq, th->th_ack); TCPSTAT_INC(tcps_sc_completed); + } + mtx_lock(&st_mtx); + stack_save(st); + stack_sbuf_print(&st_sb, st); + sbuf_finish(&st_sb); + log(LOG_DEBUG, "%s", sbuf_data(&st_sb)); + sbuf_clear(&st_sb); + mtx_unlock(&st_mtx); + /* how do we find the inp for the new socket? */ if (sc != &scs) syncache_free(sc);