All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6: change route cache aging logic
@ 2018-01-26 19:40 Wei Wang
  2018-01-26 20:05 ` Martin KaFai Lau
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wei Wang @ 2018-01-26 19:40 UTC (permalink / raw)
  To: David Miller, netdev
  Cc: Eric Dumazet, Martin KaFai Lau, Paolo Abeni, Wei Wang

From: Wei Wang <weiwan@google.com>

In current route cache aging logic, if a route has both RTF_EXPIRE and
RTF_GATEWAY set, the route will only be removed if the neighbor cache
has no RTN_ROUTE flag. Otherwise, even if the route has expired, it
won't get deleted.
Fix this logic to always check if the route has expired first and then
do the gateway neighbor cache check if previous check decide to not
remove the exception entry.

Fixes: 1859bac04fb6 ("ipv6: remove from fib tree aged out RTF_CACHE dst")
Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv6/route.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 0458b761f3c5..a560fb1d0230 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1586,12 +1586,19 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 	 * EXPIRES exceptions - e.g. pmtu-generated ones are pruned when
 	 * expired, independently from their aging, as per RFC 8201 section 4
 	 */
-	if (!(rt->rt6i_flags & RTF_EXPIRES) &&
-	    time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
-		RT6_TRACE("aging clone %p\n", rt);
+	if (!(rt->rt6i_flags & RTF_EXPIRES)) {
+		if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
+			RT6_TRACE("aging clone %p\n", rt);
+			rt6_remove_exception(bucket, rt6_ex);
+			return;
+		}
+	} else if (time_after(jiffies, rt->dst.expires)) {
+		RT6_TRACE("purging expired route %p\n", rt);
 		rt6_remove_exception(bucket, rt6_ex);
 		return;
-	} else if (rt->rt6i_flags & RTF_GATEWAY) {
+	}
+
+	if (rt->rt6i_flags & RTF_GATEWAY) {
 		struct neighbour *neigh;
 		__u8 neigh_flags = 0;
 
@@ -1606,11 +1613,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 			rt6_remove_exception(bucket, rt6_ex);
 			return;
 		}
-	} else if (__rt6_check_expired(rt)) {
-		RT6_TRACE("purging expired route %p\n", rt);
-		rt6_remove_exception(bucket, rt6_ex);
-		return;
 	}
+
 	gc_args->more++;
 }
 
-- 
2.16.0.rc1.238.g530d649a79-goog

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: change route cache aging logic
  2018-01-26 19:40 [PATCH net] ipv6: change route cache aging logic Wei Wang
@ 2018-01-26 20:05 ` Martin KaFai Lau
  2018-01-26 20:31   ` Wei Wang
  2018-01-27  9:39 ` Paolo Abeni
  2018-01-29 19:23 ` David Miller
  2 siblings, 1 reply; 5+ messages in thread
From: Martin KaFai Lau @ 2018-01-26 20:05 UTC (permalink / raw)
  To: Wei Wang; +Cc: David Miller, netdev, Eric Dumazet, Paolo Abeni

On Fri, Jan 26, 2018 at 11:40:17AM -0800, Wei Wang wrote:
> From: Wei Wang <weiwan@google.com>
> 
> In current route cache aging logic, if a route has both RTF_EXPIRE and
> RTF_GATEWAY set, the route will only be removed if the neighbor cache
> has no RTN_ROUTE flag. Otherwise, even if the route has expired, it
You meant NTF_ROUTER instead of RTN_ROUTE?

> won't get deleted.
> Fix this logic to always check if the route has expired first and then
> do the gateway neighbor cache check if previous check decide to not
> remove the exception entry.
> 
> Fixes: 1859bac04fb6 ("ipv6: remove from fib tree aged out RTF_CACHE dst")
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Nice catch!

Acked-by: Martin KaFai Lau <kafai@fb.com>

> ---
>  net/ipv6/route.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 0458b761f3c5..a560fb1d0230 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1586,12 +1586,19 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>  	 * EXPIRES exceptions - e.g. pmtu-generated ones are pruned when
>  	 * expired, independently from their aging, as per RFC 8201 section 4
>  	 */
> -	if (!(rt->rt6i_flags & RTF_EXPIRES) &&
> -	    time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
> -		RT6_TRACE("aging clone %p\n", rt);
> +	if (!(rt->rt6i_flags & RTF_EXPIRES)) {
> +		if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
> +			RT6_TRACE("aging clone %p\n", rt);
> +			rt6_remove_exception(bucket, rt6_ex);
> +			return;
> +		}
> +	} else if (time_after(jiffies, rt->dst.expires)) {
> +		RT6_TRACE("purging expired route %p\n", rt);
>  		rt6_remove_exception(bucket, rt6_ex);
>  		return;
> -	} else if (rt->rt6i_flags & RTF_GATEWAY) {
> +	}
> +
> +	if (rt->rt6i_flags & RTF_GATEWAY) {
>  		struct neighbour *neigh;
>  		__u8 neigh_flags = 0;
>  
> @@ -1606,11 +1613,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>  			rt6_remove_exception(bucket, rt6_ex);
>  			return;
>  		}
> -	} else if (__rt6_check_expired(rt)) {
> -		RT6_TRACE("purging expired route %p\n", rt);
> -		rt6_remove_exception(bucket, rt6_ex);
> -		return;
>  	}
> +
>  	gc_args->more++;
>  }
>  
> -- 
> 2.16.0.rc1.238.g530d649a79-goog
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: change route cache aging logic
  2018-01-26 20:05 ` Martin KaFai Lau
@ 2018-01-26 20:31   ` Wei Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Wang @ 2018-01-26 20:31 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: David Miller, Linux Kernel Network Developers, Eric Dumazet, Paolo Abeni

On Fri, Jan 26, 2018 at 12:05 PM, Martin KaFai Lau <kafai@fb.com> wrote:
> On Fri, Jan 26, 2018 at 11:40:17AM -0800, Wei Wang wrote:
>> From: Wei Wang <weiwan@google.com>
>>
>> In current route cache aging logic, if a route has both RTF_EXPIRE and
>> RTF_GATEWAY set, the route will only be removed if the neighbor cache
>> has no RTN_ROUTE flag. Otherwise, even if the route has expired, it
> You meant NTF_ROUTER instead of RTN_ROUTE?
>
Yes. NTF_ROUTER flag. Sorry...

>> won't get deleted.
>> Fix this logic to always check if the route has expired first and then
>> do the gateway neighbor cache check if previous check decide to not
>> remove the exception entry.
>>
>> Fixes: 1859bac04fb6 ("ipv6: remove from fib tree aged out RTF_CACHE dst")
>> Signed-off-by: Wei Wang <weiwan@google.com>
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Nice catch!
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
>
>> ---
>>  net/ipv6/route.c | 20 ++++++++++++--------
>>  1 file changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index 0458b761f3c5..a560fb1d0230 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -1586,12 +1586,19 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>>        * EXPIRES exceptions - e.g. pmtu-generated ones are pruned when
>>        * expired, independently from their aging, as per RFC 8201 section 4
>>        */
>> -     if (!(rt->rt6i_flags & RTF_EXPIRES) &&
>> -         time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
>> -             RT6_TRACE("aging clone %p\n", rt);
>> +     if (!(rt->rt6i_flags & RTF_EXPIRES)) {
>> +             if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
>> +                     RT6_TRACE("aging clone %p\n", rt);
>> +                     rt6_remove_exception(bucket, rt6_ex);
>> +                     return;
>> +             }
>> +     } else if (time_after(jiffies, rt->dst.expires)) {
>> +             RT6_TRACE("purging expired route %p\n", rt);
>>               rt6_remove_exception(bucket, rt6_ex);
>>               return;
>> -     } else if (rt->rt6i_flags & RTF_GATEWAY) {
>> +     }
>> +
>> +     if (rt->rt6i_flags & RTF_GATEWAY) {
>>               struct neighbour *neigh;
>>               __u8 neigh_flags = 0;
>>
>> @@ -1606,11 +1613,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>>                       rt6_remove_exception(bucket, rt6_ex);
>>                       return;
>>               }
>> -     } else if (__rt6_check_expired(rt)) {
>> -             RT6_TRACE("purging expired route %p\n", rt);
>> -             rt6_remove_exception(bucket, rt6_ex);
>> -             return;
>>       }
>> +
>>       gc_args->more++;
>>  }
>>
>> --
>> 2.16.0.rc1.238.g530d649a79-goog
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: change route cache aging logic
  2018-01-26 19:40 [PATCH net] ipv6: change route cache aging logic Wei Wang
  2018-01-26 20:05 ` Martin KaFai Lau
@ 2018-01-27  9:39 ` Paolo Abeni
  2018-01-29 19:23 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2018-01-27  9:39 UTC (permalink / raw)
  To: Wei Wang, David Miller, netdev; +Cc: Eric Dumazet, Martin KaFai Lau

On Fri, 2018-01-26 at 11:40 -0800, Wei Wang wrote:
> From: Wei Wang <weiwan@google.com>
> 
> In current route cache aging logic, if a route has both RTF_EXPIRE and
> RTF_GATEWAY set, the route will only be removed if the neighbor cache
> has no RTN_ROUTE flag. Otherwise, even if the route has expired, it
> won't get deleted.
> Fix this logic to always check if the route has expired first and then
> do the gateway neighbor cache check if previous check decide to not
> remove the exception entry.
> 
> Fixes: 1859bac04fb6 ("ipv6: remove from fib tree aged out RTF_CACHE dst")
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Thank you for the fix!

LGTM

Acked-by: Paolo Abeni <pabeni@redhat.com>

Cheers,

/P

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] ipv6: change route cache aging logic
  2018-01-26 19:40 [PATCH net] ipv6: change route cache aging logic Wei Wang
  2018-01-26 20:05 ` Martin KaFai Lau
  2018-01-27  9:39 ` Paolo Abeni
@ 2018-01-29 19:23 ` David Miller
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-01-29 19:23 UTC (permalink / raw)
  To: weiwan; +Cc: netdev, edumazet, kafai, pabeni

From: Wei Wang <weiwan@google.com>
Date: Fri, 26 Jan 2018 11:40:17 -0800

> From: Wei Wang <weiwan@google.com>
> 
> In current route cache aging logic, if a route has both RTF_EXPIRE and
> RTF_GATEWAY set, the route will only be removed if the neighbor cache
> has no RTN_ROUTE flag. Otherwise, even if the route has expired, it
> won't get deleted.
> Fix this logic to always check if the route has expired first and then
> do the gateway neighbor cache check if previous check decide to not
> remove the exception entry.
> 
> Fixes: 1859bac04fb6 ("ipv6: remove from fib tree aged out RTF_CACHE dst")
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-29 19:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 19:40 [PATCH net] ipv6: change route cache aging logic Wei Wang
2018-01-26 20:05 ` Martin KaFai Lau
2018-01-26 20:31   ` Wei Wang
2018-01-27  9:39 ` Paolo Abeni
2018-01-29 19:23 ` David Miller

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.