From: Eric Dumazet <eric.dumazet@gmail.com>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH 3/3] ipv4: Don't report stale pmtu values to userspace
Date: Mon, 08 Oct 2012 11:55:44 +0200 [thread overview]
Message-ID: <1349690144.21172.3024.camel@edumazet-glaptop> (raw)
In-Reply-To: <20121008084853.GE15622@secunet.com>
On Mon, 2012-10-08 at 10:48 +0200, Steffen Klassert wrote:
> We report cached pmtu values even if they are already expired.
> Change this to not report these values after they are expired.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
> net/ipv4/route.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 741df67..24b52dd 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2187,8 +2187,16 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
> nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway))
> goto nla_put_failure;
>
> + expires = rt->dst.expires;
> + if (expires) {
> + if (time_before(jiffies, expires))
> + expires -= jiffies;
Seeing this racy code, we could fix it as well.
jiffies is volatile and can change between the test and subtraction.
So we could in theory get strange result.
I suggest using :
if (expires) {
unsigned long now = jiffies;
if (time_before(now, expires))
expires -= now;
else
expires = 0;
}
or
if (expires)
expires = max_t(signed long, 0L, expires - jiffies);
> + else
> + expires = 0;
> + }
> +
next prev parent reply other threads:[~2012-10-08 9:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-08 8:46 [PATCH 0/3] ipv4: pmtu fixes Steffen Klassert
2012-10-08 8:47 ` [PATCH 1/3] ipv4: Always invalidate or update the route on pmtu events Steffen Klassert
2012-10-08 8:48 ` [PATCH 2/3] ipv4: Don't create nh exeption when the device mtu is smaller than the reported pmtu Steffen Klassert
2012-10-08 8:48 ` [PATCH 3/3] ipv4: Don't report stale pmtu values to userspace Steffen Klassert
2012-10-08 9:55 ` Eric Dumazet [this message]
2012-10-08 10:38 ` Steffen Klassert
2012-10-08 10:56 ` [PATCH v2 " Steffen Klassert
2012-10-08 18:47 ` [PATCH 0/3] ipv4: pmtu fixes 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=1349690144.21172.3024.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox