* Return 0 if we did not update the RTT time, return * 1 if we did. */
| 6862 | * 1 if we did. |
| 6863 | */ |
| 6864 | static int |
| 6865 | bbr_update_rtt(struct tcpcb *tp, struct tcp_bbr *bbr, |
| 6866 | struct bbr_sendmap *rsm, struct tcpopt *to, uint32_t cts, int32_t ack_type, uint32_t th_ack) |
| 6867 | { |
| 6868 | int32_t i; |
| 6869 | uint32_t t, uts = 0; |
| 6870 | |
| 6871 | if ((rsm->r_flags & BBR_ACKED) || |
| 6872 | (rsm->r_flags & BBR_WAS_RENEGED) || |
| 6873 | (rsm->r_flags & BBR_RXT_CLEARED)) { |
| 6874 | /* Already done */ |
| 6875 | return (0); |
| 6876 | } |
| 6877 | if (rsm->r_rtr_cnt == 1) { |
| 6878 | /* |
| 6879 | * Only one transmit. Hopefully the normal case. |
| 6880 | */ |
| 6881 | if (TSTMP_GT(cts, rsm->r_tim_lastsent[0])) |
| 6882 | t = cts - rsm->r_tim_lastsent[0]; |
| 6883 | else |
| 6884 | t = 1; |
| 6885 | if ((int)t <= 0) |
| 6886 | t = 1; |
| 6887 | bbr->r_ctl.rc_last_rtt = t; |
| 6888 | bbr_update_bbr_info(bbr, rsm, t, cts, to->to_tsecr, 0, |
| 6889 | BBR_RTT_BY_EXACTMATCH, rsm->r_tim_lastsent[0], ack_type, to); |
| 6890 | return (1); |
| 6891 | } |
| 6892 | /* Convert to usecs */ |
| 6893 | if ((bbr_can_use_ts_for_rtt == 1) && |
| 6894 | (bbr->rc_use_google == 1) && |
| 6895 | (ack_type == BBR_CUM_ACKED) && |
| 6896 | (to->to_flags & TOF_TS) && |
| 6897 | (to->to_tsecr != 0)) { |
| 6898 | t = tcp_tv_to_mssectick(&bbr->rc_tv) - to->to_tsecr; |
| 6899 | if (t < 1) |
| 6900 | t = 1; |
| 6901 | t *= MS_IN_USEC; |
| 6902 | bbr_update_bbr_info(bbr, rsm, t, cts, to->to_tsecr, 0, |
| 6903 | BBR_RTT_BY_TIMESTAMP, |
| 6904 | rsm->r_tim_lastsent[(rsm->r_rtr_cnt-1)], |
| 6905 | ack_type, to); |
| 6906 | return (1); |
| 6907 | } |
| 6908 | uts = bbr_ts_convert(to->to_tsecr); |
| 6909 | if ((to->to_flags & TOF_TS) && |
| 6910 | (to->to_tsecr != 0) && |
| 6911 | (ack_type == BBR_CUM_ACKED) && |
| 6912 | ((rsm->r_flags & BBR_OVERMAX) == 0)) { |
| 6913 | /* |
| 6914 | * Now which timestamp does it match? In this block the ACK |
| 6915 | * may be coming from a previous transmission. |
| 6916 | */ |
| 6917 | uint32_t fudge; |
| 6918 | |
| 6919 | fudge = BBR_TIMER_FUDGE; |
| 6920 | for (i = 0; i < rsm->r_rtr_cnt; i++) { |
| 6921 | if ((SEQ_GEQ(uts, (rsm->r_tim_lastsent[i] - fudge))) && |
no test coverage detected