diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2012-10-08 00:56:54 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-28 10:56:16 -0700 |
commit | 0dbade79f4fbb1035c3c846cdd358a67db67a2ce (patch) | |
tree | 4341487a2dac31d7104d6ac45f398d938763eaf9 | |
parent | 2db8263a627414aa2f6a60f80ec99178f12f757b (diff) | |
download | linux-stable-0dbade79f4fbb1035c3c846cdd358a67db67a2ce.tar.gz linux-stable-0dbade79f4fbb1035c3c846cdd358a67db67a2ce.tar.bz2 linux-stable-0dbade79f4fbb1035c3c846cdd358a67db67a2ce.zip |
ipv4: Don't report stale pmtu values to userspace
[ Upstream commit ee9a8f7ab2edf801b8b514c310455c94acc232f6 ]
We report cached pmtu values even if they are already expired.
Change this to not report these values after they are expired
and fix a race in the expire time calculation, as suggested by
Eric Dumazet.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/ipv4/route.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 11814ad59fa6..94775f14e40d 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2187,8 +2187,18 @@ 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) { + unsigned long now = jiffies; + + if (time_before(now, expires)) + expires -= now; + else + expires = 0; + } + memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); - if (rt->rt_pmtu) + if (rt->rt_pmtu && expires) metrics[RTAX_MTU - 1] = rt->rt_pmtu; if (rtnetlink_put_metrics(skb, metrics) < 0) goto nla_put_failure; @@ -2198,13 +2208,6 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, goto nla_put_failure; error = rt->dst.error; - expires = rt->dst.expires; - if (expires) { - if (time_before(jiffies, expires)) - expires -= jiffies; - else - expires = 0; - } if (rt_is_input_route(rt)) { if (nla_put_u32(skb, RTA_IIF, rt->rt_iif)) |