diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 4adc8d859f3..9844ba17623 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1133,6 +1133,9 @@ tcp_default_fb_fini(struct tcpcb *tp, int tcb_is_purged) MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); MALLOC_DEFINE(M_TCPFUNCTIONS, "tcpfunc", "TCP function set memory"); +#ifdef TCP_REQUEST_TRK +MALLOC_DEFINE(M_TCPREQTRK, "tcpreqtrk", "TCP request tracking"); +#endif static struct mtx isn_mtx; @@ -2445,6 +2448,12 @@ tcp_discardcb(struct tcpcb *tp) #ifdef STATS stats_blob_destroy(tp->t_stats); #endif +#ifdef TCP_REQUEST_TRK + if (tp->t_tcpreq_info != NULL) { + free(tp->t_tcpreq_info, M_TCPREQTRK); + tp->t_tcpreq_info = NULL; + } +#endif CC_ALGO(tp) = NULL; if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { @@ -4890,6 +4899,14 @@ tcp_req_alloc_req_full(struct tcpcb *tp, struct tcp_snd_req *req, uint64_t ts, i struct tcp_sendfile_track *fil; int i, allocated; + /* Allocate the request tracking array on demand */ + if (tp->t_tcpreq_info == NULL) { + tp->t_tcpreq_info = malloc( + sizeof(*tp->t_tcpreq_info) * MAX_TCP_TRK_REQ, + M_TCPREQTRK, M_NOWAIT | M_ZERO); + if (tp->t_tcpreq_info == NULL) + return (NULL); + } /* In case the stack does not check for completions do so now */ tcp_req_check_for_comp(tp, tp->snd_una); /* Check for stale entries */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 987bb98c19a..a1b0519ceac 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -493,7 +493,7 @@ struct tcpcb { uint32_t tcp_hybrid_start; /* Num of times we started hybrid pacing */ uint32_t tcp_hybrid_stop; /* Num of times we stopped hybrid pacing */ uint32_t tcp_hybrid_error; /* Num of times we failed to start hybrid pacing */ - struct tcp_sendfile_track t_tcpreq_info[MAX_TCP_TRK_REQ]; + struct tcp_sendfile_track *t_tcpreq_info; #endif #ifdef TCP_ACCOUNTING uint64_t tcp_cnt_counters[TCP_NUM_CNT_COUNTERS];