Commit 03ace394ac9bcad38043a381ae5f4860b9c9fa1c

Authored by Arnaldo Carvalho de Melo
Committed by David S. Miller
1 parent a3054d48b9

[DCCP]: Fix the ACK and SEQ window variables settings

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>

Showing 5 changed files with 41 additions and 10 deletions Side-by-side Diff

... ... @@ -340,13 +340,11 @@
340 340 static inline void dccp_update_gsr(struct sock *sk, u64 seq)
341 341 {
342 342 struct dccp_sock *dp = dccp_sk(sk);
343   - u64 tmp_gsr;
344 343  
345   - dccp_set_seqno(&tmp_gsr,
  344 + dp->dccps_gsr = seq;
  345 + dccp_set_seqno(&dp->dccps_swl,
346 346 (dp->dccps_gsr + 1 -
347 347 (dp->dccps_options.dccpo_sequence_window / 4)));
348   - dp->dccps_gsr = seq;
349   - dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr));
350 348 dccp_set_seqno(&dp->dccps_swh,
351 349 (dp->dccps_gsr +
352 350 (3 * dp->dccps_options.dccpo_sequence_window) / 4));
353 351  
354 352  
... ... @@ -355,13 +353,11 @@
355 353 static inline void dccp_update_gss(struct sock *sk, u64 seq)
356 354 {
357 355 struct dccp_sock *dp = dccp_sk(sk);
358   - u64 tmp_gss;
359 356  
360   - dccp_set_seqno(&tmp_gss,
  357 + dp->dccps_awh = dp->dccps_gss = seq;
  358 + dccp_set_seqno(&dp->dccps_awl,
361 359 (dp->dccps_gss -
362 360 dp->dccps_options.dccpo_sequence_window + 1));
363   - dp->dccps_awl = max48(tmp_gss, dp->dccps_iss);
364   - dp->dccps_awh = dp->dccps_gss = seq;
365 361 }
366 362  
367 363 extern void dccp_insert_options(struct sock *sk, struct sk_buff *skb);
... ... @@ -314,7 +314,19 @@
314 314 }
315 315  
316 316 dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
317   - dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  317 + dccp_update_gsr(sk, dp->dccps_isr);
  318 + /*
  319 + * SWL and AWL are initially adjusted so that they are not less than
  320 + * the initial Sequence Numbers received and sent, respectively:
  321 + * SWL := max(GSR + 1 - floor(W/4), ISR),
  322 + * AWL := max(GSS - W' + 1, ISS).
  323 + * These adjustments MUST be applied only at the beginning of the
  324 + * connection.
  325 + *
  326 + * AWL was adjusted in dccp_v4_connect -acme
  327 + */
  328 + dccp_set_seqno(&dp->dccps_swl,
  329 + max48(dp->dccps_swl, dp->dccps_isr));
318 330  
319 331 if (ccid_hc_rx_init(dp->dccps_hc_rx_ccid, sk) != 0 ||
320 332 ccid_hc_tx_init(dp->dccps_hc_tx_ccid, sk) != 0) {
... ... @@ -309,6 +309,16 @@
309 309 usin->sin_port);
310 310 dccp_update_gss(sk, dp->dccps_iss);
311 311  
  312 + /*
  313 + * SWL and AWL are initially adjusted so that they are not less than
  314 + * the initial Sequence Numbers received and sent, respectively:
  315 + * SWL := max(GSR + 1 - floor(W/4), ISR),
  316 + * AWL := max(GSS - W' + 1, ISS).
  317 + * These adjustments MUST be applied only at the beginning of the
  318 + * connection.
  319 + */
  320 + dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
  321 +
312 322 inet->id = dp->dccps_iss ^ jiffies;
313 323  
314 324 err = dccp_connect(sk);
net/dccp/minisocks.c
... ... @@ -146,6 +146,19 @@
146 146 newdp->dccps_iss = dreq->dreq_iss;
147 147 dccp_update_gss(newsk, dreq->dreq_iss);
148 148  
  149 + /*
  150 + * SWL and AWL are initially adjusted so that they are not less than
  151 + * the initial Sequence Numbers received and sent, respectively:
  152 + * SWL := max(GSR + 1 - floor(W/4), ISR),
  153 + * AWL := max(GSS - W' + 1, ISS).
  154 + * These adjustments MUST be applied only at the beginning of the
  155 + * connection.
  156 + */
  157 + dccp_set_seqno(&newdp->dccps_swl,
  158 + max48(newdp->dccps_swl, newdp->dccps_isr));
  159 + dccp_set_seqno(&newdp->dccps_awl,
  160 + max48(newdp->dccps_awl, newdp->dccps_iss));
  161 +
149 162 dccp_init_xmit_timers(newsk);
150 163  
151 164 DCCP_INC_STATS_BH(DCCP_MIB_PASSIVEOPENS);
... ... @@ -144,7 +144,7 @@
144 144 /*
145 145 * sk->sk_send_head has to have one skb with
146 146 * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP
147   - * packet types (REQUEST, RESPONSE, the ACK in the 3way hanshake
  147 + * packet types (REQUEST, RESPONSE, the ACK in the 3way handshake
148 148 * (PARTOPEN timer), etc).
149 149 */
150 150 BUG_TRAP(sk->sk_send_head != NULL);