diff --git a/usrsctplib/netinet/sctp_constants.h b/usrsctplib/netinet/sctp_constants.h index 69953e9b9..ddd435ee0 100755 --- a/usrsctplib/netinet/sctp_constants.h +++ b/usrsctplib/netinet/sctp_constants.h @@ -657,7 +657,7 @@ extern void getwintimeofday(struct timeval *tv); #define SCTP_DEBUG_PCB4 0x00800000 #define SCTP_DEBUG_INDATA1 0x01000000 #define SCTP_DEBUG_INDATA2 0x02000000 /* unused */ -#define SCTP_DEBUG_INDATA3 0x04000000 /* unused */ +#define SCTP_DEBUG_CLOSING 0x04000000 #define SCTP_DEBUG_CRCOFFLOAD 0x08000000 /* unused */ #define SCTP_DEBUG_USRREQ1 0x10000000 /* unused */ #define SCTP_DEBUG_USRREQ2 0x20000000 /* unused */ diff --git a/usrsctplib/netinet/sctp_pcb.c b/usrsctplib/netinet/sctp_pcb.c index f4429e751..1a81bc21a 100755 --- a/usrsctplib/netinet/sctp_pcb.c +++ b/usrsctplib/netinet/sctp_pcb.c @@ -3024,9 +3024,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) null_key = sctp_alloc_sharedkey(); sctp_insert_sharedkey(&m->shared_keys, null_key); SCTP_INP_WUNLOCK(inp); -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 12); -#endif return (error); } @@ -3891,9 +3889,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) #if defined(__APPLE__) && !defined(__Userspace__) sctp_lock_assert(SCTP_INP_SO(inp)); #endif -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 0); -#endif SCTP_ITERATOR_LOCK(); /* mark any iterators on the list or being processed */ sctp_iterator_inp_being_freed(inp); @@ -4052,9 +4048,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) } /* now is there some left in our SHUTDOWN state? */ if (cnt_in_sd) { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 2); -#endif inp->sctp_socket = NULL; SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); @@ -4120,9 +4114,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) } if (cnt) { /* Ok we have someone out there that will kill us */ -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 3); -#endif SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_INP_INFO_WUNLOCK(); @@ -4138,9 +4130,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) if ((inp->refcount) || (being_refed) || (inp->sctp_flags & SCTP_PCB_FLAGS_CLOSE_IP)) { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 4); -#endif sctp_timer_start(SCTP_TIMER_TYPE_INPKILL, inp, NULL, NULL); SCTP_INP_WUNLOCK(inp); SCTP_ASOC_CREATE_UNLOCK(inp); @@ -4157,9 +4147,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) SCTP_ASOC_CREATE_UNLOCK(inp); SCTP_INP_INFO_WUNLOCK(); -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 5); -#endif #if !(defined(_WIN32) || defined(__Userspace__)) #if !(defined(__FreeBSD__) && !defined(__Userspace__)) rt = ip_pcb->inp_route.ro_rt; @@ -5461,13 +5449,9 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre #endif SCTP_TCB_LOCK_ASSERT(stcb); -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 6); -#endif if (stcb->asoc.state == 0) { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 7); -#endif /* there is no asoc, really TSNH :-0 */ return (1); } @@ -5508,9 +5492,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL); /* no asoc destroyed */ SCTP_TCB_UNLOCK(stcb); -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 8); -#endif return (0); } } @@ -5570,15 +5552,11 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre } SCTP_TCB_UNLOCK(stcb); -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 9); -#endif /* no asoc destroyed */ return (0); } -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, stcb, 10); -#endif /* When I reach here, no others want * to kill the assoc yet.. and I own * the lock. Now its possible an abort @@ -5962,9 +5940,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre } } /* destroyed the asoc */ -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 11); -#endif return (1); } diff --git a/usrsctplib/netinet/sctp_usrreq.c b/usrsctplib/netinet/sctp_usrreq.c index df4424e2f..5155f448d 100755 --- a/usrsctplib/netinet/sctp_usrreq.c +++ b/usrsctplib/netinet/sctp_usrreq.c @@ -682,14 +682,10 @@ sctp_abort(struct socket *so) #if defined(__FreeBSD__) && !defined(__Userspace__) NET_EPOCH_ENTER(et); #endif -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 17); -#endif if (((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0)) { inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP; -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 16); -#endif SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); @@ -888,9 +884,7 @@ sctp_close(struct socket *so) #if defined(__FreeBSD__) && !defined(__Userspace__) NET_EPOCH_ENTER(et); #endif -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 17); -#endif if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP; #if defined(__Userspace__) @@ -899,16 +893,12 @@ sctp_close(struct socket *so) if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || #endif (SCTP_SBAVAIL(&so->so_rcv) > 0)) { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); -#endif SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); } else { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 14); -#endif SCTP_INP_WUNLOCK(inp); sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); @@ -952,22 +942,16 @@ sctp_detach(struct socket *so) } sctp_must_try_again: flags = inp->sctp_flags; -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 17); -#endif if (((flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) && (atomic_cmpset_int(&inp->sctp_flags, flags, (flags | SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP)))) { if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || (SCTP_SBAVAIL(&so->so_rcv) > 0)) { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); -#endif sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_ABORT, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); } else { -#ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); -#endif sctp_inpcb_free(inp, SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE, SCTP_CALLED_AFTER_CMPSET_OFCLOSE); } diff --git a/usrsctplib/netinet/sctputil.c b/usrsctplib/netinet/sctputil.c index af062001d..6fded0cff 100755 --- a/usrsctplib/netinet/sctputil.c +++ b/usrsctplib/netinet/sctputil.c @@ -106,7 +106,7 @@ sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr) void sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc) { -#if defined(SCTP_LOCAL_TRACE_BUF) +#if defined(SCTP_LOCAL_TRACE_BUF) && defined(SCTP_LOG_CLOSING) struct sctp_cwnd_log sctp_clog; sctp_clog.x.close.inp = (void *)inp; @@ -127,6 +127,9 @@ sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc) sctp_clog.x.misc.log3, sctp_clog.x.misc.log4); #endif + SCTPDBG(SCTP_DEBUG_CLOSING, + "Connection closing: inp=%p, flags=%x, stcb=%p, state=%d, loc=%d\n", + inp, inp->sctp_flags, stcb, stcb ? stcb->asoc.state : 0, loc); } void