tcp: Add rxt_flags for spurious retransmit detection
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 10 May 2012 07:45:29 +0000 (15:45 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 11 May 2012 09:30:03 +0000 (17:30 +0800)
This saves another 5 bits in the t_flags

sys/netinet/tcp_input.c
sys/netinet/tcp_timer.c
sys/netinet/tcp_var.h

index 873b812..1ee3499 100644 (file)
@@ -1195,7 +1195,7 @@ after_listen:
                                 */
                                if (tcp_do_eifel_detect &&
                                    (to.to_flags & TOF_TS) && to.to_tsecr &&
-                                   (tp->t_flags & TF_FIRSTACCACK)) {
+                                   (tp->rxt_flags & TRXT_F_FIRSTACCACK)) {
                                        /* Eifel detection applicable. */
                                        if (to.to_tsecr < tp->t_rexmtTS) {
                                                tcp_revert_congestion_state(tp);
@@ -1209,8 +1209,8 @@ after_listen:
                                        tcp_revert_congestion_state(tp);
                                        ++tcpstat.tcps_rttdetected;
                                }
-                               tp->t_flags &= ~(TF_FIRSTACCACK |
-                                                TF_FASTREXMT | TF_EARLYREXMT);
+                               tp->rxt_flags &= ~(TRXT_F_FIRSTACCACK |
+                                   TRXT_F_FASTREXMT | TRXT_F_EARLYREXMT);
                                /*
                                 * Recalculate the retransmit timer / rtt.
                                 *
@@ -2000,7 +2000,7 @@ fastretransmit:
                                if (tcp_do_eifel_detect &&
                                    (tp->t_flags & TF_RCVD_TSTMP)) {
                                        tcp_save_congestion_state(tp);
-                                       tp->t_flags |= TF_FASTREXMT;
+                                       tp->rxt_flags |= TRXT_F_FASTREXMT;
                                }
                                /*
                                 * We know we're losing at the current
@@ -2047,7 +2047,8 @@ fastretransmit:
                                        if (!tcp_sack_limitedxmit(tp) &&
                                            need_early_retransmit(tp, ownd)) {
                                                ++tcpstat.tcps_sndearlyrexmit;
-                                               tp->t_flags |= TF_EARLYREXMT;
+                                               tp->rxt_flags |=
+                                                   TRXT_F_EARLYREXMT;
                                                goto fastretransmit;
                                        }
                                }
@@ -2092,7 +2093,7 @@ fastretransmit:
                                        ++tcpstat.tcps_sndlimited;
                                } else if (need_early_retransmit(tp, ownd)) {
                                        ++tcpstat.tcps_sndearlyrexmit;
-                                       tp->t_flags |= TF_EARLYREXMT;
+                                       tp->rxt_flags |= TRXT_F_EARLYREXMT;
                                        goto fastretransmit;
                                }
                        }
@@ -2142,7 +2143,7 @@ process_ACK:
 
                if (tcp_do_eifel_detect && acked > 0 &&
                    (to.to_flags & TOF_TS) && (to.to_tsecr != 0) &&
-                   (tp->t_flags & TF_FIRSTACCACK)) {
+                   (tp->rxt_flags & TRXT_F_FIRSTACCACK)) {
                        /* Eifel detection applicable. */
                        if (to.to_tsecr < tp->t_rexmtTS) {
                                ++tcpstat.tcps_eifeldetected;
@@ -2191,7 +2192,8 @@ process_ACK:
                        goto step6;
 
                /* Stop looking for an acceptable ACK since one was received. */
-               tp->t_flags &= ~(TF_FIRSTACCACK | TF_FASTREXMT | TF_EARLYREXMT);
+               tp->rxt_flags &= ~(TRXT_F_FIRSTACCACK |
+                   TRXT_F_FASTREXMT | TRXT_F_EARLYREXMT);
 
                if (acked > so->so_snd.ssb_cc) {
                        tp->snd_wnd -= so->so_snd.ssb_cc;
@@ -2842,7 +2844,8 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt, tcp_seq ack)
 
        tcpstat.tcps_rttupdated++;
        tp->t_rttupdated++;
-       if ((tp->t_flags & TF_REBASERTO) && SEQ_GT(ack, tp->snd_max_prev)) {
+       if ((tp->rxt_flags & TRXT_F_REBASERTO) &&
+           SEQ_GT(ack, tp->snd_max_prev)) {
 #ifdef DEBUG_EIFEL_RESPONSE
                kprintf("srtt/rttvar, prev %d/%d, cur %d/%d, ",
                    tp->t_srtt_prev, tp->t_rttvar_prev,
@@ -2851,7 +2854,7 @@ tcp_xmit_timer(struct tcpcb *tp, int rtt, tcp_seq ack)
 
                tcpstat.tcps_eifelresponse++;
                rebaserto = 1;
-               tp->t_flags &= ~TF_REBASERTO;
+               tp->rxt_flags &= ~TRXT_F_REBASERTO;
                tp->t_srtt = max(tp->t_srtt_prev, (rtt << TCP_RTT_SHIFT));
                tp->t_rttvar = max(tp->t_rttvar_prev,
                    (rtt << (TCP_RTTVAR_SHIFT - 1)));
index e6546bc..e825816 100644 (file)
@@ -472,15 +472,15 @@ tcp_save_congestion_state(struct tcpcb *tp)
            (tcp_eifel_rtoinc << TCP_RTT_SHIFT);
        tp->t_rttvar_prev = tp->t_rttvar;
        tp->snd_max_prev = tp->snd_max;
-       tp->t_flags &= ~TF_REBASERTO;
+       tp->rxt_flags &= ~TRXT_F_REBASERTO;
 
        if (IN_FASTRECOVERY(tp))
-               tp->t_flags |= TF_WASFRECOVERY;
+               tp->rxt_flags |= TRXT_F_WASFRECOVERY;
        else
-               tp->t_flags &= ~TF_WASFRECOVERY;
+               tp->rxt_flags &= ~TRXT_F_WASFRECOVERY;
        if (tp->t_flags & TF_RCVD_TSTMP) {
                tp->t_rexmtTS = ticks;
-               tp->t_flags |= TF_FIRSTACCACK;
+               tp->rxt_flags |= TRXT_F_FIRSTACCACK;
        }
 #ifdef later
        tcp_sack_save_scoreboard(&tp->scb);
@@ -494,17 +494,17 @@ tcp_revert_congestion_state(struct tcpcb *tp)
        tp->snd_wacked = tp->snd_wacked_prev;
        tp->snd_ssthresh = tp->snd_ssthresh_prev;
        tp->snd_recover = tp->snd_recover_prev;
-       if (tp->t_flags & TF_WASFRECOVERY)
+       if (tp->rxt_flags & TRXT_F_WASFRECOVERY)
                ENTER_FASTRECOVERY(tp);
-       if (tp->t_flags & TF_FASTREXMT) {
+       if (tp->rxt_flags & TRXT_F_FASTREXMT) {
                ++tcpstat.tcps_sndfastrexmitbad;
-               if (tp->t_flags & TF_EARLYREXMT)
+               if (tp->rxt_flags & TRXT_F_EARLYREXMT)
                        ++tcpstat.tcps_sndearlyrexmitbad;
        } else {
                ++tcpstat.tcps_sndrtobad;
                tp->snd_last = ticks;
                if (tcp_do_eifel_response)
-                       tp->t_flags |= TF_REBASERTO;
+                       tp->rxt_flags |= TRXT_F_REBASERTO;
        }
        tp->t_badrxtwin = 0;
        tp->t_rxtshift = 0;
@@ -550,7 +550,7 @@ tcp_timer_rexmt_handler(struct tcpcb *tp)
                 */
                tp->t_badrxtwin = ticks + (tp->t_srtt >> (TCP_RTT_SHIFT + 1));
                tcp_save_congestion_state(tp);
-               tp->t_flags &= ~(TF_FASTREXMT | TF_EARLYREXMT);
+               tp->rxt_flags &= ~(TRXT_F_FASTREXMT | TRXT_F_EARLYREXMT);
        }
        if (tp->t_state == TCPS_SYN_SENT || tp->t_state == TCPS_SYN_RECEIVED) {
                /*
index f7417d9..b0bffe5 100644 (file)
@@ -170,14 +170,14 @@ struct tcpcb {
 #define TF_SIGNATURE   0x00004000      /* require MD5 digests (RFC2385) */
 #define TF_UNUSED001   0x00008000
 #define        TF_MORETOCOME   0x00010000      /* More data to be appended to sock */
-#define        TF_REBASERTO    0x00020000      /* Recalculate RTO based on new RTT */
+#define        TF_UNUSED005    0x00020000
 #define        TF_LASTIDLE     0x00040000      /* connection was previously idle */
 #define        TF_RXWIN0SENT   0x00080000      /* sent a receiver win 0 in response */
 #define        TF_FASTRECOVERY 0x00100000      /* in NewReno Fast Recovery */
-#define        TF_WASFRECOVERY 0x00200000      /* was in NewReno Fast Recovery */
-#define        TF_FIRSTACCACK  0x00400000      /* Look for 1st acceptable ACK. */
-#define        TF_FASTREXMT    0x00800000      /* Did Fast Retransmit. */
-#define        TF_EARLYREXMT   0x01000000      /* Did Early (Fast) Retransmit. */
+#define        TF_UNUSED006    0x00200000
+#define        TF_UNUSED007    0x00400000
+#define        TF_UNUSED008    0x00800000
+#define        TF_UNUSED009    0x01000000
 #define        TF_FORCE        0x02000000      /* Set if forcing out a byte */
 #define TF_ONOUTPUTQ   0x04000000      /* on t_outputq list */
 #define TF_UNUSED002   0x08000000
@@ -246,6 +246,12 @@ struct tcpcb {
        tcp_seq last_ack_sent;
 
 /* experimental */
+       u_int   rxt_flags;
+#define        TRXT_F_REBASERTO        0x0001  /* Recalculate RTO based on new RTT */
+#define        TRXT_F_WASFRECOVERY     0x0002  /* was in NewReno Fast Recovery */
+#define        TRXT_F_FIRSTACCACK      0x0004  /* Look for 1st acceptable ACK. */
+#define        TRXT_F_FASTREXMT        0x0008  /* Did Fast Retransmit. */
+#define        TRXT_F_EARLYREXMT       0x0010  /* Did Early (Fast) Retransmit. */
        int     t_srtt_prev;            /* adjusted SRTT prior to retransmit */
        int     t_rttvar_prev;          /* RTTVAR prior to retransmit */
        int     t_rxtcur_prev;          /* rexmt timeout prior to retransmit */