diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-12-09 21:24:57 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-11 17:34:58 -0500 |
commit | 9e8efc824098c241a1cde81f5558d222cb6f9369 (patch) | |
tree | 443c107edcac509a93857184f1d2e00933369dcb /net/dccp/ccids | |
parent | 7af5af3013f84693a7af581e3c8b32f9db493cf5 (diff) |
[DCCP] ccid3: BUG-FIX - conversion errors
This fixes conversion errors which arose by not properly type-casting
from u32 to __u64. Fixed by explicitly casting each type which is not
__u64, or by performing operation after assignment.
The patch further adds missing debug information to track the current
value of X_recv.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index d23af7b475a0..6bc77ff20908 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -123,18 +123,19 @@ static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now) | |||
123 | 123 | ||
124 | if (hctx->ccid3hctx_p > 0) { | 124 | if (hctx->ccid3hctx_p > 0) { |
125 | 125 | ||
126 | hctx->ccid3hctx_x = min_t(u64, hctx->ccid3hctx_x_calc << 6, | 126 | hctx->ccid3hctx_x = min(((__u64)hctx->ccid3hctx_x_calc) << 6, |
127 | hctx->ccid3hctx_x_recv * 2 ); | 127 | hctx->ccid3hctx_x_recv * 2 ); |
128 | hctx->ccid3hctx_x = max_t(u64, hctx->ccid3hctx_x, | 128 | hctx->ccid3hctx_x = max(hctx->ccid3hctx_x, |
129 | (hctx->ccid3hctx_s << 6)/TFRC_T_MBI); | 129 | (((__u64)hctx->ccid3hctx_s) << 6) / |
130 | TFRC_T_MBI); | ||
130 | 131 | ||
131 | } else if (timeval_delta(now, &hctx->ccid3hctx_t_ld) - | 132 | } else if (timeval_delta(now, &hctx->ccid3hctx_t_ld) - |
132 | (suseconds_t)hctx->ccid3hctx_rtt >= 0 ) { | 133 | (suseconds_t)hctx->ccid3hctx_rtt >= 0 ) { |
133 | 134 | ||
134 | hctx->ccid3hctx_x = max(2 * min(hctx->ccid3hctx_x, | 135 | hctx->ccid3hctx_x = |
135 | hctx->ccid3hctx_x_recv), | 136 | max(2 * min(hctx->ccid3hctx_x, hctx->ccid3hctx_x_recv), |
136 | scaled_div(hctx->ccid3hctx_s << 6, | 137 | scaled_div(((__u64)hctx->ccid3hctx_s) << 6, |
137 | hctx->ccid3hctx_rtt )); | 138 | hctx->ccid3hctx_rtt ) ); |
138 | hctx->ccid3hctx_t_ld = *now; | 139 | hctx->ccid3hctx_t_ld = *now; |
139 | } | 140 | } |
140 | 141 | ||
@@ -207,8 +208,9 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
207 | switch (hctx->ccid3hctx_state) { | 208 | switch (hctx->ccid3hctx_state) { |
208 | case TFRC_SSTATE_NO_FBACK: | 209 | case TFRC_SSTATE_NO_FBACK: |
209 | /* RFC 3448, 4.4: Halve send rate directly */ | 210 | /* RFC 3448, 4.4: Halve send rate directly */ |
210 | hctx->ccid3hctx_x = max_t(u32, hctx->ccid3hctx_x / 2, | 211 | hctx->ccid3hctx_x = max(hctx->ccid3hctx_x / 2, |
211 | (hctx->ccid3hctx_s << 6)/TFRC_T_MBI); | 212 | (((__u64)hctx->ccid3hctx_s) << 6) / |
213 | TFRC_T_MBI); | ||
212 | 214 | ||
213 | ccid3_pr_debug("%s(%p, state=%s), updated tx rate to %u " | 215 | ccid3_pr_debug("%s(%p, state=%s), updated tx rate to %u " |
214 | "bytes/s\n", dccp_role(sk), sk, | 216 | "bytes/s\n", dccp_role(sk), sk, |
@@ -226,7 +228,7 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
226 | */ | 228 | */ |
227 | if (!hctx->ccid3hctx_idle || | 229 | if (!hctx->ccid3hctx_idle || |
228 | (hctx->ccid3hctx_x_recv >= 4 * | 230 | (hctx->ccid3hctx_x_recv >= 4 * |
229 | scaled_div(hctx->ccid3hctx_s << 6, hctx->ccid3hctx_rtt))) { | 231 | scaled_div(((__u64)hctx->ccid3hctx_s) << 6, hctx->ccid3hctx_rtt))) { |
230 | struct timeval now; | 232 | struct timeval now; |
231 | 233 | ||
232 | ccid3_pr_debug("%s(%p, state=%s), not idle\n", | 234 | ccid3_pr_debug("%s(%p, state=%s), not idle\n", |
@@ -249,15 +251,16 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
249 | hctx->ccid3hctx_x_calc > (hctx->ccid3hctx_x_recv >> 5)) { | 251 | hctx->ccid3hctx_x_calc > (hctx->ccid3hctx_x_recv >> 5)) { |
250 | 252 | ||
251 | hctx->ccid3hctx_x_recv = | 253 | hctx->ccid3hctx_x_recv = |
252 | max_t(u64, hctx->ccid3hctx_x_recv / 2, | 254 | max(hctx->ccid3hctx_x_recv / 2, |
253 | (hctx->ccid3hctx_s << 6) / | 255 | (((__u64)hctx->ccid3hctx_s) << 6) / |
254 | (2*TFRC_T_MBI)); | 256 | (2*TFRC_T_MBI)); |
255 | 257 | ||
256 | if (hctx->ccid3hctx_p == 0) | 258 | if (hctx->ccid3hctx_p == 0) |
257 | dccp_timestamp(sk, &now); | 259 | dccp_timestamp(sk, &now); |
258 | } else | 260 | } else { |
259 | hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc << 4; | 261 | hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc; |
260 | 262 | hctx->ccid3hctx_x_recv <<= 4; | |
263 | } | ||
261 | /* Now recalculate X [RFC 3448, 4.3, step (4)] */ | 264 | /* Now recalculate X [RFC 3448, 4.3, step (4)] */ |
262 | ccid3_hc_tx_update_x(sk, &now); | 265 | ccid3_hc_tx_update_x(sk, &now); |
263 | } | 266 | } |
@@ -320,7 +323,8 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb) | |||
320 | 323 | ||
321 | /* Set initial sending rate X/s to 1pps (X is scaled by 2^6) */ | 324 | /* Set initial sending rate X/s to 1pps (X is scaled by 2^6) */ |
322 | ccid3_hc_tx_update_s(hctx, skb->len); | 325 | ccid3_hc_tx_update_s(hctx, skb->len); |
323 | hctx->ccid3hctx_x = hctx->ccid3hctx_s << 6; | 326 | hctx->ccid3hctx_x = hctx->ccid3hctx_s; |
327 | hctx->ccid3hctx_x <<= 6; | ||
324 | 328 | ||
325 | /* First timeout, according to [RFC 3448, 4.2], is 1 second */ | 329 | /* First timeout, according to [RFC 3448, 4.2], is 1 second */ |
326 | hctx->ccid3hctx_t_ipi = USEC_PER_SEC; | 330 | hctx->ccid3hctx_t_ipi = USEC_PER_SEC; |
@@ -421,7 +425,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
421 | } | 425 | } |
422 | 426 | ||
423 | /* Update receive rate in units of 64 * bytes/second */ | 427 | /* Update receive rate in units of 64 * bytes/second */ |
424 | hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate << 6; | 428 | hctx->ccid3hctx_x_recv = opt_recv->ccid3or_receive_rate; |
429 | hctx->ccid3hctx_x_recv <<= 6; | ||
425 | 430 | ||
426 | /* Update loss event rate */ | 431 | /* Update loss event rate */ |
427 | pinv = opt_recv->ccid3or_loss_event_rate; | 432 | pinv = opt_recv->ccid3or_loss_event_rate; |
@@ -460,15 +465,15 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
460 | * Larger Initial Windows [RFC 4342, sec. 5] | 465 | * Larger Initial Windows [RFC 4342, sec. 5] |
461 | * We deviate in that we use `s' instead of `MSS'. | 466 | * We deviate in that we use `s' instead of `MSS'. |
462 | */ | 467 | */ |
463 | u16 w_init = min( 4 * hctx->ccid3hctx_s, | 468 | __u64 w_init = min( 4 * hctx->ccid3hctx_s, |
464 | max(2 * hctx->ccid3hctx_s, 4380)); | 469 | max(2 * hctx->ccid3hctx_s, 4380)); |
465 | hctx->ccid3hctx_rtt = r_sample; | 470 | hctx->ccid3hctx_rtt = r_sample; |
466 | hctx->ccid3hctx_x = scaled_div(w_init<< 6, r_sample); | 471 | hctx->ccid3hctx_x = scaled_div(w_init << 6, r_sample); |
467 | hctx->ccid3hctx_t_ld = now; | 472 | hctx->ccid3hctx_t_ld = now; |
468 | 473 | ||
469 | ccid3_update_send_time(hctx); | 474 | ccid3_update_send_time(hctx); |
470 | 475 | ||
471 | ccid3_pr_debug("%s(%p), s=%u, w_init=%u, " | 476 | ccid3_pr_debug("%s(%p), s=%u, w_init=%llu, " |
472 | "R_sample=%ldus, X=%u\n", dccp_role(sk), | 477 | "R_sample=%ldus, X=%u\n", dccp_role(sk), |
473 | sk, hctx->ccid3hctx_s, w_init, r_sample, | 478 | sk, hctx->ccid3hctx_s, w_init, r_sample, |
474 | (unsigned)(hctx->ccid3hctx_x >> 6)); | 479 | (unsigned)(hctx->ccid3hctx_x >> 6)); |
@@ -487,11 +492,12 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
487 | ccid3_hc_tx_update_x(sk, &now); | 492 | ccid3_hc_tx_update_x(sk, &now); |
488 | 493 | ||
489 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%ldus), s=%u, " | 494 | ccid3_pr_debug("%s(%p), RTT=%uus (sample=%ldus), s=%u, " |
490 | "p=%u, X_calc=%u, X=%u\n", dccp_role(sk), | 495 | "p=%u, X_calc=%u, X_recv=%u, X=%u\n", dccp_role(sk), |
491 | sk, hctx->ccid3hctx_rtt, r_sample, | 496 | sk, hctx->ccid3hctx_rtt, r_sample, |
492 | hctx->ccid3hctx_s, hctx->ccid3hctx_p, | 497 | hctx->ccid3hctx_s, hctx->ccid3hctx_p, |
493 | hctx->ccid3hctx_x_calc, | 498 | hctx->ccid3hctx_x_calc, |
494 | (unsigned)(hctx->ccid3hctx_x >> 6)); | 499 | (unsigned)(hctx->ccid3hctx_x_recv >> 6), |
500 | (unsigned)(hctx->ccid3hctx_x >> 6) ); | ||
495 | } | 501 | } |
496 | 502 | ||
497 | /* unschedule no feedback timer */ | 503 | /* unschedule no feedback timer */ |