All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net] tcp: fix wraparound issue in tcp_lp
Date: Mon, 1 May 2017 16:56:43 -0700	[thread overview]
Message-ID: <20170501165643.698aa0b5@xeon-e3> (raw)
In-Reply-To: <1493677788.31837.25.camel@edumazet-glaptop3.roam.corp.google.com>

On Mon, 01 May 2017 15:29:48 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> From: Eric Dumazet <edumazet@google.com>
> 
> Be careful when comparing tcp_time_stamp to some u32 quantity,
> otherwise result can be surprising.
> 
> Fixes: 7c106d7e782b ("[TCP]: TCP Low Priority congestion control")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  net/ipv4/tcp_lp.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
> index 046fd3910873306d74207615d6997e1c847ea361..d6fb6c067af4641f232b94e7c590c212648e8173 100644
> --- a/net/ipv4/tcp_lp.c
> +++ b/net/ipv4/tcp_lp.c
> @@ -264,13 +264,15 @@ static void tcp_lp_pkts_acked(struct sock *sk, const struct ack_sample *sample)
>  {
>  	struct tcp_sock *tp = tcp_sk(sk);
>  	struct lp *lp = inet_csk_ca(sk);
> +	u32 delta;
>  
>  	if (sample->rtt_us > 0)
>  		tcp_lp_rtt_sample(sk, sample->rtt_us);
>  
>  	/* calc inference */
> -	if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
> -		lp->inference = 3 * (tcp_time_stamp - tp->rx_opt.rcv_tsecr);
> +	delta = tcp_time_stamp - tp->rx_opt.rcv_tsecr;
> +	if ((s32)delta > 0)
> +		lp->inference = 3 * delta;

Agreed time wraparound would cause problems.
But why not use existing time_after() macro here?

  reply	other threads:[~2017-05-01 23:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-01 22:29 [PATCH net] tcp: fix wraparound issue in tcp_lp Eric Dumazet
2017-05-01 23:56 ` Stephen Hemminger [this message]
2017-05-02  0:31   ` Neal Cardwell
2017-05-02  1:04   ` Eric Dumazet
2017-05-02  1:58     ` Eric Dumazet
2017-05-02 19:07 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170501165643.698aa0b5@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.