Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d06e021d71d95aae402340dc3d9f79f9c8ad11d7
Commit:     d06e021d71d95aae402340dc3d9f79f9c8ad11d7
Parent:     19b2b486580f5939688d3e225acdc0f4b291ed0d
Author:     David S. Miller <[EMAIL PROTECTED]>
AuthorDate: Mon Jun 18 22:43:06 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Oct 10 16:47:51 2007 -0700

    [TCP]: Extract DSACK detection code from tcp_sacktag_write_queue().
    
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/ipv4/tcp_input.c |   56 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0aa1724..5187870 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -960,6 +960,39 @@ static void tcp_update_reordering(struct sock *sk, const 
int metric,
  * Both of these heuristics are not used in Loss state, when we cannot
  * account for retransmits accurately.
  */
+static int tcp_check_dsack(struct tcp_sock *tp, struct sk_buff *ack_skb,
+                          struct tcp_sack_block_wire *sp, int num_sacks,
+                          u32 prior_snd_una)
+{
+       u32 start_seq_0 = ntohl(get_unaligned(&sp[0].start_seq));
+       u32 end_seq_0 = ntohl(get_unaligned(&sp[0].end_seq));
+       int dup_sack = 0;
+
+       if (before(start_seq_0, TCP_SKB_CB(ack_skb)->ack_seq)) {
+               dup_sack = 1;
+               tp->rx_opt.sack_ok |= 4;
+               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV);
+       } else if (num_sacks > 1) {
+               u32 end_seq_1 = ntohl(get_unaligned(&sp[1].end_seq));
+               u32 start_seq_1 = ntohl(get_unaligned(&sp[1].start_seq));
+
+               if (!after(end_seq_0, end_seq_1) &&
+                   !before(start_seq_0, start_seq_1)) {
+                       dup_sack = 1;
+                       tp->rx_opt.sack_ok |= 4;
+                       NET_INC_STATS_BH(LINUX_MIB_TCPDSACKOFORECV);
+               }
+       }
+
+       /* D-SACK for already forgotten data... Do dumb counting. */
+       if (dup_sack &&
+           !after(end_seq_0, prior_snd_una) &&
+           after(end_seq_0, tp->undo_marker))
+               tp->undo_retrans--;
+
+       return dup_sack;
+}
+
 static int
 tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 
prior_snd_una)
 {
@@ -985,27 +1018,10 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff 
*ack_skb, u32 prior_snd_
        }
        prior_fackets = tp->fackets_out;
 
-       /* Check for D-SACK. */
-       if (before(ntohl(sp[0].start_seq), TCP_SKB_CB(ack_skb)->ack_seq)) {
-               flag |= FLAG_DSACKING_ACK;
-               found_dup_sack = 1;
-               tp->rx_opt.sack_ok |= 4;
-               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKRECV);
-       } else if (num_sacks > 1 &&
-                       !after(ntohl(sp[0].end_seq), ntohl(sp[1].end_seq)) &&
-                       !before(ntohl(sp[0].start_seq), 
ntohl(sp[1].start_seq))) {
+       found_dup_sack = tcp_check_dsack(tp, ack_skb, sp,
+                                        num_sacks, prior_snd_una);
+       if (found_dup_sack)
                flag |= FLAG_DSACKING_ACK;
-               found_dup_sack = 1;
-               tp->rx_opt.sack_ok |= 4;
-               NET_INC_STATS_BH(LINUX_MIB_TCPDSACKOFORECV);
-       }
-
-       /* D-SACK for already forgotten data...
-        * Do dumb counting. */
-       if (found_dup_sack &&
-                       !after(ntohl(sp[0].end_seq), prior_snd_una) &&
-                       after(ntohl(sp[0].end_seq), tp->undo_marker))
-               tp->undo_retrans--;
 
        /* Eliminate too old ACKs, but take into
         * account more or less fresh ones, they can
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to