tcp: kill eff_sacks "cache", the sole user can calculate itself
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Sat, 28 Feb 2009 04:44:38 +0000 (04:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Mar 2009 11:00:16 +0000 (03:00 -0800)
Also fixes insignificant bug that would cause sending of stale
SACK block (would occur in some corner cases).

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/tcp.h
include/net/tcp.h
net/ipv4/tcp_input.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c

index 0cd99e6baca5b4cb947672483ba4d128274358b5..4b86ad71e054b3e61715c3a001883f328f88b994 100644 (file)
@@ -218,7 +218,6 @@ struct tcp_options_received {
                snd_wscale : 4, /* Window scaling received from sender  */
                rcv_wscale : 4; /* Window scaling to send to receiver   */
 /*     SACKs data      */
-       u8      eff_sacks;      /* Size of SACK array to send with next packet */
        u8      num_sacks;      /* Number of SACK blocks                */
        u16     user_mss;       /* mss requested by user in ioctl */
        u16     mss_clamp;      /* Maximal mss, negotiated at connection setup */
index 0366a559afec035d503e2428a2658a1a4d2843d1..055e4946d4c8ade886cad3679cac8dc52b9f5b63 100644 (file)
@@ -926,7 +926,6 @@ extern void tcp_done(struct sock *sk);
 static inline void tcp_sack_reset(struct tcp_options_received *rx_opt)
 {
        rx_opt->dsack = 0;
-       rx_opt->eff_sacks = 0;
        rx_opt->num_sacks = 0;
 }
 
index 03f5ede872243baf461dbaa607957734052ed4fa..e4442a293eb074fa302b6887be92859846c59975 100644 (file)
@@ -4099,7 +4099,6 @@ static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq)
                tp->rx_opt.dsack = 1;
                tp->duplicate_sack[0].start_seq = seq;
                tp->duplicate_sack[0].end_seq = end_seq;
-               tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + 1;
        }
 }
 
@@ -4154,8 +4153,6 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp)
                         * Decrease num_sacks.
                         */
                        tp->rx_opt.num_sacks--;
-                       tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks +
-                                              tp->rx_opt.dsack;
                        for (i = this_sack; i < tp->rx_opt.num_sacks; i++)
                                sp[i] = sp[i + 1];
                        continue;
@@ -4218,7 +4215,6 @@ new_sack:
        sp->start_seq = seq;
        sp->end_seq = end_seq;
        tp->rx_opt.num_sacks++;
-       tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
 }
 
 /* RCV.NXT advances, some SACKs should be eaten. */
@@ -4232,7 +4228,6 @@ static void tcp_sack_remove(struct tcp_sock *tp)
        /* Empty ofo queue, hence, all the SACKs are eaten. Clear. */
        if (skb_queue_empty(&tp->out_of_order_queue)) {
                tp->rx_opt.num_sacks = 0;
-               tp->rx_opt.eff_sacks = tp->rx_opt.dsack;
                return;
        }
 
@@ -4253,11 +4248,8 @@ static void tcp_sack_remove(struct tcp_sock *tp)
                this_sack++;
                sp++;
        }
-       if (num_sacks != tp->rx_opt.num_sacks) {
+       if (num_sacks != tp->rx_opt.num_sacks)
                tp->rx_opt.num_sacks = num_sacks;
-               tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks +
-                                      tp->rx_opt.dsack;
-       }
 }
 
 /* This one checks to see if we can put data from the
@@ -4333,10 +4325,8 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
 
        TCP_ECN_accept_cwr(tp, skb);
 
-       if (tp->rx_opt.dsack) {
+       if (tp->rx_opt.dsack)
                tp->rx_opt.dsack = 0;
-               tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks;
-       }
 
        /*  Queue data for delivery to the user.
         *  Packets in sequence go to the receive queue.
@@ -4456,7 +4446,6 @@ drop:
                if (tcp_is_sack(tp)) {
                        tp->rx_opt.num_sacks = 1;
                        tp->rx_opt.dsack     = 0;
-                       tp->rx_opt.eff_sacks = 1;
                        tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq;
                        tp->selective_acks[0].end_seq =
                                                TCP_SKB_CB(skb)->end_seq;
index f67effbb102be04ae72b759fa24bef202612f296..bb3d8b35f19a0f21a6e17262a852861ac3a11549 100644 (file)
@@ -434,9 +434,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
                newtp->rx_opt.saw_tstamp = 0;
 
                newtp->rx_opt.dsack = 0;
-               newtp->rx_opt.eff_sacks = 0;
-
                newtp->rx_opt.num_sacks = 0;
+
                newtp->urg_data = 0;
 
                if (sock_flag(newsk, SOCK_KEEPOPEN))
index 61445b57610cd98e00249bc85ff96793563b2103..1555bb73b6389e33205e9d448f9ce8408c255d01 100644 (file)
@@ -441,10 +441,8 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp,
                        *ptr++ = htonl(sp[this_sack].end_seq);
                }
 
-               if (tp->rx_opt.dsack) {
+               if (tp->rx_opt.dsack)
                        tp->rx_opt.dsack = 0;
-                       tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks;
-               }
        }
 }
 
@@ -550,6 +548,7 @@ static unsigned tcp_established_options(struct sock *sk, struct sk_buff *skb,
        struct tcp_skb_cb *tcb = skb ? TCP_SKB_CB(skb) : NULL;
        struct tcp_sock *tp = tcp_sk(sk);
        unsigned size = 0;
+       unsigned int eff_sacks;
 
 #ifdef CONFIG_TCP_MD5SIG
        *md5 = tp->af_specific->md5_lookup(sk, sk);
@@ -568,10 +567,11 @@ static unsigned tcp_established_options(struct sock *sk, struct sk_buff *skb,
                size += TCPOLEN_TSTAMP_ALIGNED;
        }
 
-       if (unlikely(tp->rx_opt.eff_sacks)) {
+       eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
+       if (unlikely(eff_sacks)) {
                const unsigned remaining = MAX_TCP_OPTION_SPACE - size;
                opts->num_sack_blocks =
-                       min_t(unsigned, tp->rx_opt.eff_sacks,
+                       min_t(unsigned, eff_sacks,
                              (remaining - TCPOLEN_SACK_BASE_ALIGNED) /
                              TCPOLEN_SACK_PERBLOCK);
                size += TCPOLEN_SACK_BASE_ALIGNED +
@@ -1418,7 +1418,7 @@ static int tcp_mtu_probe(struct sock *sk)
            icsk->icsk_mtup.probe_size ||
            inet_csk(sk)->icsk_ca_state != TCP_CA_Open ||
            tp->snd_cwnd < 11 ||
-           tp->rx_opt.eff_sacks)
+           tp->rx_opt.num_sacks || tp->rx_opt.dsack)
                return -1;
 
        /* Very simple search strategy: just double the MSS. */