diff mbox

ipv6: fix rt6_update_expires

Message ID 20120416133439.GB18159@midget.suse.cz
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Bohac April 16, 2012, 1:34 p.m. UTC
Commit 1716a961 (ipv6: fix problem with expired dst cache) broke PMTU
discovery. rt6_update_expires() calls dst_set_expires(), which only updates
dst->expires if it has not been set previously (expires == 0) or if the new
expires is earlier than the current dst->expires.

rt6_update_expires() needs to zero rt->dst.expires, otherwise it will contain
ivalid data left over from rt->dst.from and will confuse dst_set_expires().

Signed-off-by: Jiri Bohac <jbohac@suse.cz>

Comments

Gao feng April 18, 2012, 2:24 a.m. UTC | #1
于 2012年04月16日 21:34, Jiri Bohac 写道:
> 
> Commit 1716a961 (ipv6: fix problem with expired dst cache) broke PMTU
> discovery. rt6_update_expires() calls dst_set_expires(), which only updates
> dst->expires if it has not been set previously (expires == 0) or if the new
> expires is earlier than the current dst->expires.
> 
> rt6_update_expires() needs to zero rt->dst.expires, otherwise it will contain
> ivalid data left over from rt->dst.from and will confuse dst_set_expires().
> 
> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
> 
> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
> index ad4126f..68c1f94 100644
> --- a/include/net/ip6_fib.h
> +++ b/include/net/ip6_fib.h
> @@ -143,8 +143,13 @@ static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
>  
>  static inline void rt6_update_expires(struct rt6_info *rt, int timeout)
>  {
> -	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
> -		dst_release(rt->dst.from);
> +	if (!(rt->rt6i_flags & RTF_EXPIRES)) {
> +		if (rt->dst.from)
> +			dst_release(rt->dst.from);
> +		/* dst_set_expires relies on expires == 0 
> +                  if it has not been set previously */
> +		rt->dst.expires = 0;
> +	}
>  
>  	dst_set_expires(&rt->dst, timeout);
>  	rt->rt6i_flags |= RTF_EXPIRES;
> 

looks good to me, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 18, 2012, 2:32 a.m. UTC | #2
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Wed, 18 Apr 2012 10:24:48 +0800

> 于 2012年04月16日 21:34, Jiri Bohac 写道:
>> 
>> Commit 1716a961 (ipv6: fix problem with expired dst cache) broke PMTU
>> discovery. rt6_update_expires() calls dst_set_expires(), which only updates
>> dst->expires if it has not been set previously (expires == 0) or if the new
>> expires is earlier than the current dst->expires.
>> 
>> rt6_update_expires() needs to zero rt->dst.expires, otherwise it will contain
>> ivalid data left over from rt->dst.from and will confuse dst_set_expires().
>> 
>> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
 ...
> looks good to me, thanks.

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index ad4126f..68c1f94 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -143,8 +143,13 @@  static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
 
 static inline void rt6_update_expires(struct rt6_info *rt, int timeout)
 {
-	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
-		dst_release(rt->dst.from);
+	if (!(rt->rt6i_flags & RTF_EXPIRES)) {
+		if (rt->dst.from)
+			dst_release(rt->dst.from);
+		/* dst_set_expires relies on expires == 0 
+                  if it has not been set previously */
+		rt->dst.expires = 0;
+	}
 
 	dst_set_expires(&rt->dst, timeout);
 	rt->rt6i_flags |= RTF_EXPIRES;