* Return value of 1, the TCB is unlocked and most * likely gone, return value of 0, the TCP is still * locked. */
| 9939 | * locked. |
| 9940 | */ |
| 9941 | static int |
| 9942 | rack_do_closing(struct mbuf *m, struct tcphdr *th, struct socket *so, |
| 9943 | struct tcpcb *tp, struct tcpopt *to, int32_t drop_hdrlen, int32_t tlen, |
| 9944 | uint32_t tiwin, int32_t thflags, int32_t nxt_pkt, uint8_t iptos) |
| 9945 | { |
| 9946 | int32_t ret_val = 0; |
| 9947 | int32_t ourfinisacked = 0; |
| 9948 | |
| 9949 | ctf_calc_rwin(so, tp); |
| 9950 | |
| 9951 | if ((thflags & TH_RST) || |
| 9952 | (tp->t_fin_is_rst && (thflags & TH_FIN))) |
| 9953 | return (ctf_process_rst(m, th, so, tp)); |
| 9954 | /* |
| 9955 | * RFC5961 Section 4.2 Send challenge ACK for any SYN in |
| 9956 | * synchronized state. |
| 9957 | */ |
| 9958 | if (thflags & TH_SYN) { |
| 9959 | ctf_challenge_ack(m, th, tp, &ret_val); |
| 9960 | return (ret_val); |
| 9961 | } |
| 9962 | /* |
| 9963 | * RFC 1323 PAWS: If we have a timestamp reply on this segment and |
| 9964 | * it's less than ts_recent, drop it. |
| 9965 | */ |
| 9966 | if ((to->to_flags & TOF_TS) != 0 && tp->ts_recent && |
| 9967 | TSTMP_LT(to->to_tsval, tp->ts_recent)) { |
| 9968 | if (ctf_ts_check(m, th, tp, tlen, thflags, &ret_val)) |
| 9969 | return (ret_val); |
| 9970 | } |
| 9971 | if (ctf_drop_checks(to, m, th, tp, &tlen, &thflags, &drop_hdrlen, &ret_val)) { |
| 9972 | return (ret_val); |
| 9973 | } |
| 9974 | /* |
| 9975 | * If new data are received on a connection after the user processes |
| 9976 | * are gone, then RST the other end. |
| 9977 | */ |
| 9978 | if ((so->so_state & SS_NOFDREF) && tlen) { |
| 9979 | if (rack_check_data_after_close(m, tp, &tlen, th, so)) |
| 9980 | return (1); |
| 9981 | } |
| 9982 | /* |
| 9983 | * If last ACK falls within this segment's sequence numbers, record |
| 9984 | * its timestamp. NOTE: 1) That the test incorporates suggestions |
| 9985 | * from the latest proposal of the tcplw@cray.com list (Braden |
| 9986 | * 1993/04/26). 2) That updating only on newer timestamps interferes |
| 9987 | * with our earlier PAWS tests, so this check should be solely |
| 9988 | * predicated on the sequence space of this segment. 3) That we |
| 9989 | * modify the segment boundary check to be Last.ACK.Sent <= SEG.SEQ |
| 9990 | * + SEG.Len instead of RFC1323's Last.ACK.Sent < SEG.SEQ + |
| 9991 | * SEG.Len, This modified check allows us to overcome RFC1323's |
| 9992 | * limitations as described in Stevens TCP/IP Illustrated Vol. 2 |
| 9993 | * p.869. In such cases, we can still calculate the RTT correctly |
| 9994 | * when RCV.NXT == Last.ACK.Sent. |
| 9995 | */ |
| 9996 | if ((to->to_flags & TOF_TS) != 0 && |
| 9997 | SEQ_LEQ(th->th_seq, tp->last_ack_sent) && |
| 9998 | SEQ_LEQ(tp->last_ack_sent, th->th_seq + tlen + |
nothing calls this directly
no test coverage detected