[DCCP]: Fix the ACK and SEQ window variables settings
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Sun, 21 Aug 2005 08:36:45 +0000 (05:36 -0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 29 Aug 2005 23:03:42 +0000 (16:03 -0700)
This is from a first audit, more eyeballs are more than welcome.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dccp/dccp.h
net/dccp/input.c
net/dccp/ipv4.c
net/dccp/minisocks.c
net/dccp/timer.c

index aab72b8d07038df8191c51c6a8668a2095ce22f0..33968a9422f2ac5cd3e3aa29acc495e2eb23a093 100644 (file)
@@ -340,13 +340,11 @@ static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack,
 static inline void dccp_update_gsr(struct sock *sk, u64 seq)
 {
        struct dccp_sock *dp = dccp_sk(sk);
-       u64 tmp_gsr;
 
-       dccp_set_seqno(&tmp_gsr,
+       dp->dccps_gsr = seq;
+       dccp_set_seqno(&dp->dccps_swl,
                       (dp->dccps_gsr + 1 -
                        (dp->dccps_options.dccpo_sequence_window / 4)));
-       dp->dccps_gsr = seq;
-       dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr));
        dccp_set_seqno(&dp->dccps_swh,
                       (dp->dccps_gsr +
                        (3 * dp->dccps_options.dccpo_sequence_window) / 4));
@@ -355,13 +353,11 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
 static inline void dccp_update_gss(struct sock *sk, u64 seq)
 {
        struct dccp_sock *dp = dccp_sk(sk);
-       u64 tmp_gss;
 
-       dccp_set_seqno(&tmp_gss,
+       dp->dccps_awh = dp->dccps_gss = seq;
+       dccp_set_seqno(&dp->dccps_awl,
                       (dp->dccps_gss -
                        dp->dccps_options.dccpo_sequence_window + 1));
-       dp->dccps_awl = max48(tmp_gss, dp->dccps_iss);
-       dp->dccps_awh = dp->dccps_gss = seq;
 }
 
 extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb);
index ce8396b126d242c70f6b7a72e311ec10432844a0..5847cf454e2657119b0d3c9bd32790e68e372d7d 100644 (file)
@@ -314,7 +314,19 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
                }
 
                dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
-               dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
+               dccp_update_gsr(sk, dp->dccps_isr);
+               /*
+                * SWL and AWL are initially adjusted so that they are not less than
+                * the initial Sequence Numbers received and sent, respectively:
+                *      SWL := max(GSR + 1 - floor(W/4), ISR),
+                *      AWL := max(GSS - W' + 1, ISS).
+                * These adjustments MUST be applied only at the beginning of the
+                * connection.
+                *
+                * AWL was adjusted in dccp_v4_connect -acme
+                */
+               dccp_set_seqno(&dp->dccps_swl,
+                              max48(dp->dccps_swl, dp->dccps_isr));
 
                if (ccid_hc_rx_init(dp->dccps_hc_rx_ccid, sk) != 0 ||
                    ccid_hc_tx_init(dp->dccps_hc_tx_ccid, sk) != 0) {
index 02ebf1f39f384d629518462e68971c35bc0b9eda..647e669a1266265a253fad61230a4bcaecfbe715 100644 (file)
@@ -309,6 +309,16 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
                                                            usin->sin_port);
        dccp_update_gss(sk, dp->dccps_iss);
 
+       /*
+        * SWL and AWL are initially adjusted so that they are not less than
+        * the initial Sequence Numbers received and sent, respectively:
+        *      SWL := max(GSR + 1 - floor(W/4), ISR),
+        *      AWL := max(GSS - W' + 1, ISS).
+        * These adjustments MUST be applied only at the beginning of the
+        * connection.
+        */
+       dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
+
        inet->id = dp->dccps_iss ^ jiffies;
 
        err = dccp_connect(sk);
index b8e67207e97e15995b6a1dcaa538c39ea23bdf14..ce5dff4ac22ea9435a15b20a9da054487879aefe 100644 (file)
@@ -146,6 +146,19 @@ out_free:
                newdp->dccps_iss = dreq->dreq_iss;
                dccp_update_gss(newsk, dreq->dreq_iss);
 
+               /*
+                * SWL and AWL are initially adjusted so that they are not less than
+                * the initial Sequence Numbers received and sent, respectively:
+                *      SWL := max(GSR + 1 - floor(W/4), ISR),
+                *      AWL := max(GSS - W' + 1, ISS).
+                * These adjustments MUST be applied only at the beginning of the
+                * connection.
+                */
+               dccp_set_seqno(&newdp->dccps_swl,
+                              max48(newdp->dccps_swl, newdp->dccps_isr));
+               dccp_set_seqno(&newdp->dccps_awl,
+                              max48(newdp->dccps_awl, newdp->dccps_iss));
+
                dccp_init_xmit_timers(newsk);
 
                DCCP_INC_STATS_BH(DCCP_MIB_PASSIVEOPENS);
index 47b1616e61894584ac23c298a8204e9d69ca7bc4..aa34b576e22827b038ab11a6a6e750def8786c0c 100644 (file)
@@ -144,7 +144,7 @@ static void dccp_retransmit_timer(struct sock *sk)
        /*
         * sk->sk_send_head has to have one skb with
         * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP
-        * packet types (REQUEST, RESPONSE, the ACK in the 3way hanshake
+        * packet types (REQUEST, RESPONSE, the ACK in the 3way handshake
         * (PARTOPEN timer), etc).
         */
        BUG_TRAP(sk->sk_send_head != NULL);