diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1517,6 +1517,21 @@ } } +/* + * Drop space held by incoming segment. + */ +static inline void +tcp_do_segment_drop(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th) +{ + INP_WLOCK_ASSERT(tptoinpcb(tp)); + TCP_PROBE3(debug__input, tp, th, m); + + if (tp != NULL) { + INP_WUNLOCK(tptoinpcb(tp)); + } + m_freem(m); +} + void tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, int drop_hdrlen, int tlen, uint8_t iptos) @@ -1562,7 +1577,7 @@ "sysctl setting)\n", s, __func__); free(s, M_TCPLOG); } - goto drop; + return tcp_do_segment_drop(tp, m, th); } /* @@ -1728,7 +1743,7 @@ "segment silently dropped\n", s, __func__); free(s, M_TCPLOG); } - goto drop; + return tcp_do_segment_drop(tp, m, th); } } /* @@ -2010,9 +2025,9 @@ /* non-initial SYN is ignored */ if ((tcp_timer_active(tp, TT_DELACK) || tcp_timer_active(tp, TT_REXMT))) - goto drop; + return tcp_do_segment_drop(tp, m, th); } else if (!(thflags & (TH_ACK|TH_FIN|TH_RST))) { - goto drop; + return tcp_do_segment_drop(tp, m, th); } } break; @@ -2040,9 +2055,9 @@ tp = tcp_drop(tp, ECONNREFUSED); } if (thflags & TH_RST) - goto drop; + return tcp_do_segment_drop(tp, m, th); if (!(thflags & TH_SYN)) - goto drop; + return tcp_do_segment_drop(tp, m, th); tp->irs = th->th_seq; tcp_rcvseqinit(tp); @@ -2209,7 +2224,7 @@ m = NULL; } } - goto drop; + return tcp_do_segment_drop(tp, m, th); } /* @@ -2230,7 +2245,7 @@ tcp_send_challenge_ack(tp, th, m); m = NULL; } - goto drop; + return tcp_do_segment_drop(tp, m, th); } /* @@ -2259,7 +2274,7 @@ TCPSTAT_INC(tcps_pawsdrop); if (tlen) goto dropafterack; - goto drop; + return tcp_do_segment_drop(tp, m, th); } } @@ -2428,7 +2443,7 @@ } else if (tp->t_flags & TF_ACKNOW) goto dropafterack; else - goto drop; + return tcp_do_segment_drop(tp, m, th); } /* @@ -2467,7 +2482,7 @@ TCPSTAT_INC(tcps_rcvacktooold); tcp_send_challenge_ack(tp, th, m); m = NULL; - goto drop; + return tcp_do_segment_drop(tp, m, th); } } switch (tp->t_state) { @@ -2677,7 +2692,7 @@ tp->snd_cwnd += maxseg; } (void) tcp_output(tp); - goto drop; + return tcp_do_segment_drop(tp, m, th); } else if (tp->t_dupacks == tcprexmtthresh || (tp->t_flags & TF_SACK_PERMIT && V_tcp_do_newsack && @@ -2749,7 +2764,7 @@ if (SEQ_GT(th->th_ack, tp->snd_una)) { goto resume_partialack; } - goto drop; + return tcp_do_segment_drop(tp, m, th); } tp->snd_nxt = th->th_ack; tp->snd_cwnd = maxseg; @@ -2762,7 +2777,7 @@ (tp->t_dupacks - tp->snd_limited); if (SEQ_GT(onxt, tp->snd_nxt)) tp->snd_nxt = onxt; - goto drop; + return tcp_do_segment_drop(tp, m, th); } else if (V_tcp_do_rfc3042) { /* * Process first and second duplicate @@ -2820,7 +2835,7 @@ ++tp->snd_limited; } tp->snd_cwnd = oldcwnd; - goto drop; + return tcp_do_segment_drop(tp, m, th); } } break; @@ -3106,7 +3121,7 @@ case TCPS_LAST_ACK: if (ourfinisacked) { tp = tcp_close(tp); - goto drop; + return tcp_do_segment_drop(tp, m, th); } break; } @@ -3452,17 +3467,6 @@ INP_WUNLOCK(inp); } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); - return; - -drop: - /* - * Drop space held by incoming segment and return. - */ - TCP_PROBE3(debug__input, tp, th, m); - if (tp != NULL) { - INP_WUNLOCK(inp); - } - m_freem(m); } /*