Commit e0867e38 authored by Eric Dumazet's avatar Eric Dumazet Committed by Kleber Sacilotto de Souza

net: dccp: switch rx_tstamp_last_feedback to monotonic clock

BugLink: https://bugs.launchpad.net/bugs/1790884

[ Upstream commit 0ce4e70f ]

To compute delays, better not use time of the day which can
be changed by admins or malicious programs.

Also change ccid3_first_li() to use s64 type for delta variable
to avoid potential overflows.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Cc: dccp@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent e0e6665f
...@@ -599,7 +599,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, ...@@ -599,7 +599,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
{ {
struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
ktime_t now = ktime_get_real(); ktime_t now = ktime_get();
s64 delta = 0; s64 delta = 0;
switch (fbtype) { switch (fbtype) {
...@@ -631,7 +631,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk, ...@@ -631,7 +631,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
return; return;
} }
ccid3_pr_debug("Interval %ldusec, X_recv=%u, 1/p=%u\n", (long)delta, ccid3_pr_debug("Interval %lldusec, X_recv=%u, 1/p=%u\n", delta,
hc->rx_x_recv, hc->rx_pinv); hc->rx_x_recv, hc->rx_pinv);
hc->rx_tstamp_last_feedback = now; hc->rx_tstamp_last_feedback = now;
...@@ -678,7 +678,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) ...@@ -678,7 +678,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
static u32 ccid3_first_li(struct sock *sk) static u32 ccid3_first_li(struct sock *sk)
{ {
struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk); struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
u32 x_recv, p, delta; u32 x_recv, p;
s64 delta;
u64 fval; u64 fval;
if (hc->rx_rtt == 0) { if (hc->rx_rtt == 0) {
...@@ -686,7 +687,9 @@ static u32 ccid3_first_li(struct sock *sk) ...@@ -686,7 +687,9 @@ static u32 ccid3_first_li(struct sock *sk)
hc->rx_rtt = DCCP_FALLBACK_RTT; hc->rx_rtt = DCCP_FALLBACK_RTT;
} }
delta = ktime_to_us(net_timedelta(hc->rx_tstamp_last_feedback)); delta = ktime_us_delta(ktime_get(), hc->rx_tstamp_last_feedback);
if (delta <= 0)
delta = 1;
x_recv = scaled_div32(hc->rx_bytes_recv, delta); x_recv = scaled_div32(hc->rx_bytes_recv, delta);
if (x_recv == 0) { /* would also trigger divide-by-zero */ if (x_recv == 0) { /* would also trigger divide-by-zero */
DCCP_WARN("X_recv==0\n"); DCCP_WARN("X_recv==0\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment