* [PATCH 1/25]: Fix bug in the calculation of very low sending rates
@ 2007-03-21 18:44 Gerrit Renker
2007-03-26 2:38 ` Ian McDonald
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gerrit Renker @ 2007-03-21 18:44 UTC (permalink / raw)
To: dccp
[CCID 3]: Fix bug in the calculation of very low sending rates
This fixes an error in the calculation of t_ipi when X converges towards
very low sending rates (between 1 and 64 bytes per second).
Although this case may not sound likely, it can be reproduced by connecting,
hitting enter (1 byte sent) and waiting for some time, during which the
nofeedback timer halves the sending rate until finally it reaches the region
1..64 bytes/sec. Computing X is handled correctly (tested separately); but by
dividing X _before_ entering the calculation of t_ipi, X becomes zero as
a result. This in turn triggers a BUG condition caught in scaled_div().
Fixed by replacing with equivalent statement and explicit typecast for good
measure.
Calculation verified and effect of patch tested - reduced never below 1 byte
per 64 seconds afterwards, i.e. not allowing divide-by-zero.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
net/dccp/ccids/ccid3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -102,8 +102,8 @@ static inline u64 rfc3390_initial_rate(s
static inline void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx)
{
/* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */
- hctx->ccid3hctx_t_ipi = scaled_div(hctx->ccid3hctx_s,
- hctx->ccid3hctx_x >> 6);
+ hctx->ccid3hctx_t_ipi = scaled_div32(((u64)hctx->ccid3hctx_s) << 6,
+ hctx->ccid3hctx_x);
/* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */
hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/25]: Fix bug in the calculation of very low sending rates
2007-03-21 18:44 [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
@ 2007-03-26 2:38 ` Ian McDonald
2007-04-10 17:21 ` [PATCH 1/25]: Fix bug in the calculation of very low sending Eddie Kohler
2007-04-11 9:06 ` [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
2 siblings, 0 replies; 4+ messages in thread
From: Ian McDonald @ 2007-03-26 2:38 UTC (permalink / raw)
To: dccp
On 3/22/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
> [CCID 3]: Fix bug in the calculation of very low sending rates
>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
--
Web: http://wand.net.nz/~iam4
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/25]: Fix bug in the calculation of very low sending
2007-03-21 18:44 [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
2007-03-26 2:38 ` Ian McDonald
@ 2007-04-10 17:21 ` Eddie Kohler
2007-04-11 9:06 ` [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
2 siblings, 0 replies; 4+ messages in thread
From: Eddie Kohler @ 2007-04-10 17:21 UTC (permalink / raw)
To: dccp
I'm surprised that this case occurs:
Gerrit Renker wrote:
> [CCID 3]: Fix bug in the calculation of very low sending rates
>
> This fixes an error in the calculation of t_ipi when X converges towards
> very low sending rates (between 1 and 64 bytes per second).
>
> Although this case may not sound likely, it can be reproduced by connecting,
> hitting enter (1 byte sent) and waiting for some time, during which the
> nofeedback timer halves the sending rate until finally it reaches the region
> 1..64 bytes/sec. Computing X is handled correctly (tested separately); but by
> dividing X _before_ entering the calculation of t_ipi, X becomes zero as
> a result. This in turn triggers a BUG condition caught in scaled_div().
According to RFC 4342, the allowed sending rate should never be reduced
below the TCP initial sending rate of two or four packets per RTT,
depending on the packet size, as the result of an idle or slow period.
Hitting enter and then waiting is an idle period.
Since X is the allowed transmit rate, it seems Linux implementation is
not following this at the moment; but perhaps there is code elsewhere
handling this case?
Eddie
> Fixed by replacing with equivalent statement and explicit typecast for good
> measure.
>
> Calculation verified and effect of patch tested - reduced never below 1 byte
> per 64 seconds afterwards, i.e. not allowing divide-by-zero.
>
> Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
> ---
> net/dccp/ccids/ccid3.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- a/net/dccp/ccids/ccid3.c
> +++ b/net/dccp/ccids/ccid3.c
> @@ -102,8 +102,8 @@ static inline u64 rfc3390_initial_rate(s
> static inline void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx)
> {
> /* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */
> - hctx->ccid3hctx_t_ipi = scaled_div(hctx->ccid3hctx_s,
> - hctx->ccid3hctx_x >> 6);
> + hctx->ccid3hctx_t_ipi = scaled_div32(((u64)hctx->ccid3hctx_s) << 6,
> + hctx->ccid3hctx_x);
>
> /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */
> hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
> -
> To unsubscribe from this list: send the line "unsubscribe dccp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/25]: Fix bug in the calculation of very low sending rates
2007-03-21 18:44 [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
2007-03-26 2:38 ` Ian McDonald
2007-04-10 17:21 ` [PATCH 1/25]: Fix bug in the calculation of very low sending Eddie Kohler
@ 2007-04-11 9:06 ` Gerrit Renker
2 siblings, 0 replies; 4+ messages in thread
From: Gerrit Renker @ 2007-04-11 9:06 UTC (permalink / raw)
To: dccp
Quoting Eddie Kohler:
| I'm surprised that this case occurs:
|
| Gerrit Renker wrote:
| > [CCID 3]: Fix bug in the calculation of very low sending rates
| >
| > This fixes an error in the calculation of t_ipi when X converges towards
| > very low sending rates (between 1 and 64 bytes per second).
| >
| > Although this case may not sound likely, it can be reproduced by connecting,
| > hitting enter (1 byte sent) and waiting for some time, during which the
| > nofeedback timer halves the sending rate until finally it reaches the region
| > 1..64 bytes/sec. Computing X is handled correctly (tested separately); but by
| > dividing X _before_ entering the calculation of t_ipi, X becomes zero as
| > a result. This in turn triggers a BUG condition caught in scaled_div().
|
| According to RFC 4342, the allowed sending rate should never be reduced
| below the TCP initial sending rate of two or four packets per RTT,
| depending on the packet size, as the result of an idle or slow period.
|
| Hitting enter and then waiting is an idle period.
|
| Since X is the allowed transmit rate, it seems Linux implementation is
| not following this at the moment; but perhaps there is code elsewhere
| handling this case?
|
Respecting the TCP initial sending rate is handled by rfc3390_initial_rate(), but this
patch is in a different section of the code; the nofeedback timer reducing X.
This patch is not affected by and does not affect the TCP initial rate.
It is a bona-fide bug fix and only concerned with rounding errors. The present code is
wrong and will cause a BUG condition under the described conditions.
| > static inline void ccid3_update_send_interval(struct ccid3_hc_tx_sock *hctx)
| > {
| > /* Calculate new t_ipi = s / X_inst (X_inst is in 64 * bytes/second) */
| > - hctx->ccid3hctx_t_ipi = scaled_div(hctx->ccid3hctx_s,
| > - hctx->ccid3hctx_x >> 6);
| > + hctx->ccid3hctx_t_ipi = scaled_div32(((u64)hctx->ccid3hctx_s) << 6,
| > + hctx->ccid3hctx_x);
The bug here is in scaled_div(hctx->ccid3hctx_s, hctx->ccid3hctx_x >> 6): the right-shift
is done before the division operation is evaluated. Thus sending rates in the range
1/64 bytes/sec ... 1 byte/sec will appear as 0, and consequently trigger "divide-by-zero"
BUG condition in scaled_div. And this case is perfectly possible, due to the definition
of s/t_mbi and s/(2*t_mbi) in RFC 3448, 4.3 - both values would with the above show as 0
when s is very small.
It may be that due to the TCP initial rate this case is rare, but it still represents a
bug condition and must not be allowed to occur.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-11 9:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-21 18:44 [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
2007-03-26 2:38 ` Ian McDonald
2007-04-10 17:21 ` [PATCH 1/25]: Fix bug in the calculation of very low sending Eddie Kohler
2007-04-11 9:06 ` [PATCH 1/25]: Fix bug in the calculation of very low sending rates Gerrit Renker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.