netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries
@ 2017-10-19 14:07 Paolo Abeni
  2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Paolo Abeni @ 2017-10-19 14:07 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Wei Wang, Eric Dumazet, Hannes Frederic Sowa,
	Martin KaFai Lau

This series addresses 2 different but related issues with RTF_CACHE introduced
by the recent refactory.

patch 1 restore the gc timer for such routes
patch 2 removes the aged out dst from the fib tree, properly coping with pMTU
routes

v1 -> v2:
 - dropped the  for ip route show cache
 - avoid touching dst.obsolete when the dst is aged out

v2 -> v3:
 - take care of pMTU exceptions

Paolo Abeni (2):
  ipv6: start fib6 gc on RTF_CACHE dst creation
  ipv6: remove from fib tree aged out RTF_CACHE dst

 net/ipv6/route.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

-- 
2.13.6

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

* [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation
  2017-10-19 14:07 [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries Paolo Abeni
@ 2017-10-19 14:07 ` Paolo Abeni
  2017-10-19 20:13   ` Wei Wang
  2017-10-19 21:01   ` Martin KaFai Lau
  2017-10-19 14:07 ` [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst Paolo Abeni
  2017-10-21  0:40 ` [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries David Miller
  2 siblings, 2 replies; 8+ messages in thread
From: Paolo Abeni @ 2017-10-19 14:07 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Wei Wang, Eric Dumazet, Hannes Frederic Sowa,
	Martin KaFai Lau

After the commit 2b760fcf5cfb ("ipv6: hook up exception table
to store dst cache"), the fib6 gc is not started after the
creation of a RTF_CACHE via a redirect or pmtu update, since
fib6_add() isn't invoked anymore for such dsts.

We need the fib6 gc to run periodically to clean the RTF_CACHE,
or the dst will stay there forever.

Fix it by explicitly calling fib6_force_start_gc() on successful
exception creation. gc_args->more accounting will ensure that
the gc timer will run for whatever time needed to properly
clean the table.

v2 -> v3:
 - clarified the commit message

Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv6/route.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 01a103c23a6c..5c27313803d2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1340,8 +1340,10 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 	spin_unlock_bh(&rt6_exception_lock);
 
 	/* Update fn->fn_sernum to invalidate all cached dst */
-	if (!err)
+	if (!err) {
 		fib6_update_sernum(ort);
+		fib6_force_start_gc(net);
+	}
 
 	return err;
 }
-- 
2.13.6

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

* [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst
  2017-10-19 14:07 [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries Paolo Abeni
  2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
@ 2017-10-19 14:07 ` Paolo Abeni
  2017-10-19 20:19   ` Wei Wang
  2017-10-19 21:02   ` Martin KaFai Lau
  2017-10-21  0:40 ` [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries David Miller
  2 siblings, 2 replies; 8+ messages in thread
From: Paolo Abeni @ 2017-10-19 14:07 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Wei Wang, Eric Dumazet, Hannes Frederic Sowa,
	Martin KaFai Lau

The commit 2b760fcf5cfb ("ipv6: hook up exception table to store
dst cache") partially reverted the commit 1e2ea8ad37be ("ipv6: set
dst.obsolete when a cached route has expired").

As a result, RTF_CACHE dst referenced outside the fib tree will
not be removed until the next sernum change; dst_check() does not
fail on aged-out dst, and dst->__refcnt can't decrease: the aged
out dst will stay valid for a potentially unlimited time after the
timeout expiration.

This change explicitly removes RTF_CACHE dst from the fib tree when
aged out. The rt6_remove_exception() logic will then obsolete the
dst and other entities will drop the related reference on next
dst_check().

pMTU exceptions are not aged-out, and are removed from the exception
table only when the - usually considerably longer - ip6_rt_mtu_expires
timeout expires.

v1 -> v2:
  - do not touch dst.obsolete in rt6_remove_exception(), not needed
v2 -> v3:
  - take care of pMTU exceptions, too

Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/ipv6/route.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 5c27313803d2..87a15cbd0e8b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1575,7 +1575,13 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
 {
 	struct rt6_info *rt = rt6_ex->rt6i;
 
-	if (atomic_read(&rt->dst.__refcnt) == 1 &&
+	/* we are pruning and obsoleting aged-out and non gateway exceptions
+	 * even if others have still references to them, so that on next
+	 * dst_check() such references can be dropped.
+	 * 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);
 		rt6_remove_exception(bucket, rt6_ex);
@@ -1595,6 +1601,10 @@ 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.13.6

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

* Re: [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation
  2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
@ 2017-10-19 20:13   ` Wei Wang
  2017-10-19 21:01   ` Martin KaFai Lau
  1 sibling, 0 replies; 8+ messages in thread
From: Wei Wang @ 2017-10-19 20:13 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Linux Kernel Network Developers, David S. Miller, Eric Dumazet,
	Hannes Frederic Sowa, Martin KaFai Lau

On Thu, Oct 19, 2017 at 7:07 AM, Paolo Abeni <pabeni@redhat.com> wrote:
> After the commit 2b760fcf5cfb ("ipv6: hook up exception table
> to store dst cache"), the fib6 gc is not started after the
> creation of a RTF_CACHE via a redirect or pmtu update, since
> fib6_add() isn't invoked anymore for such dsts.
>
> We need the fib6 gc to run periodically to clean the RTF_CACHE,
> or the dst will stay there forever.
>
> Fix it by explicitly calling fib6_force_start_gc() on successful
> exception creation. gc_args->more accounting will ensure that
> the gc timer will run for whatever time needed to properly
> clean the table.
>
> v2 -> v3:
>  - clarified the commit message
>
> Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---

Acked-by: Wei Wang <weiwan@google.com>

>  net/ipv6/route.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 01a103c23a6c..5c27313803d2 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1340,8 +1340,10 @@ static int rt6_insert_exception(struct rt6_info *nrt,
>         spin_unlock_bh(&rt6_exception_lock);
>
>         /* Update fn->fn_sernum to invalidate all cached dst */
> -       if (!err)
> +       if (!err) {
>                 fib6_update_sernum(ort);
> +               fib6_force_start_gc(net);
> +       }
>
>         return err;
>  }
> --
> 2.13.6
>

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

* Re: [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst
  2017-10-19 14:07 ` [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst Paolo Abeni
@ 2017-10-19 20:19   ` Wei Wang
  2017-10-19 21:02   ` Martin KaFai Lau
  1 sibling, 0 replies; 8+ messages in thread
From: Wei Wang @ 2017-10-19 20:19 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Linux Kernel Network Developers, David S. Miller, Eric Dumazet,
	Hannes Frederic Sowa, Martin KaFai Lau

On Thu, Oct 19, 2017 at 7:07 AM, Paolo Abeni <pabeni@redhat.com> wrote:
> The commit 2b760fcf5cfb ("ipv6: hook up exception table to store
> dst cache") partially reverted the commit 1e2ea8ad37be ("ipv6: set
> dst.obsolete when a cached route has expired").
>
> As a result, RTF_CACHE dst referenced outside the fib tree will
> not be removed until the next sernum change; dst_check() does not
> fail on aged-out dst, and dst->__refcnt can't decrease: the aged
> out dst will stay valid for a potentially unlimited time after the
> timeout expiration.
>
> This change explicitly removes RTF_CACHE dst from the fib tree when
> aged out. The rt6_remove_exception() logic will then obsolete the
> dst and other entities will drop the related reference on next
> dst_check().
>
> pMTU exceptions are not aged-out, and are removed from the exception
> table only when the - usually considerably longer - ip6_rt_mtu_expires
> timeout expires.
>
> v1 -> v2:
>   - do not touch dst.obsolete in rt6_remove_exception(), not needed
> v2 -> v3:
>   - take care of pMTU exceptions, too
>
> Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---

Acked-by: Wei Wang <weiwan@google.com>


>  net/ipv6/route.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 5c27313803d2..87a15cbd0e8b 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1575,7 +1575,13 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
>  {
>         struct rt6_info *rt = rt6_ex->rt6i;
>
> -       if (atomic_read(&rt->dst.__refcnt) == 1 &&
> +       /* we are pruning and obsoleting aged-out and non gateway exceptions
> +        * even if others have still references to them, so that on next
> +        * dst_check() such references can be dropped.
> +        * 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);
>                 rt6_remove_exception(bucket, rt6_ex);
> @@ -1595,6 +1601,10 @@ 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.13.6
>

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

* Re: [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation
  2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
  2017-10-19 20:13   ` Wei Wang
@ 2017-10-19 21:01   ` Martin KaFai Lau
  1 sibling, 0 replies; 8+ messages in thread
From: Martin KaFai Lau @ 2017-10-19 21:01 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: netdev, David S. Miller, Wei Wang, Eric Dumazet,
	Hannes Frederic Sowa

On Thu, Oct 19, 2017 at 02:07:10PM +0000, Paolo Abeni wrote:
> After the commit 2b760fcf5cfb ("ipv6: hook up exception table
> to store dst cache"), the fib6 gc is not started after the
> creation of a RTF_CACHE via a redirect or pmtu update, since
> fib6_add() isn't invoked anymore for such dsts.
> 
> We need the fib6 gc to run periodically to clean the RTF_CACHE,
> or the dst will stay there forever.
> 
> Fix it by explicitly calling fib6_force_start_gc() on successful
> exception creation. gc_args->more accounting will ensure that
> the gc timer will run for whatever time needed to properly
> clean the table.
> 
> v2 -> v3:
>  - clarified the commit message
> 
> Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst
  2017-10-19 14:07 ` [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst Paolo Abeni
  2017-10-19 20:19   ` Wei Wang
@ 2017-10-19 21:02   ` Martin KaFai Lau
  1 sibling, 0 replies; 8+ messages in thread
From: Martin KaFai Lau @ 2017-10-19 21:02 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: netdev, David S. Miller, Wei Wang, Eric Dumazet,
	Hannes Frederic Sowa

On Thu, Oct 19, 2017 at 02:07:11PM +0000, Paolo Abeni wrote:
> The commit 2b760fcf5cfb ("ipv6: hook up exception table to store
> dst cache") partially reverted the commit 1e2ea8ad37be ("ipv6: set
> dst.obsolete when a cached route has expired").
> 
> As a result, RTF_CACHE dst referenced outside the fib tree will
> not be removed until the next sernum change; dst_check() does not
> fail on aged-out dst, and dst->__refcnt can't decrease: the aged
> out dst will stay valid for a potentially unlimited time after the
> timeout expiration.
> 
> This change explicitly removes RTF_CACHE dst from the fib tree when
> aged out. The rt6_remove_exception() logic will then obsolete the
> dst and other entities will drop the related reference on next
> dst_check().
> 
> pMTU exceptions are not aged-out, and are removed from the exception
> table only when the - usually considerably longer - ip6_rt_mtu_expires
> timeout expires.
> 
> v1 -> v2:
>   - do not touch dst.obsolete in rt6_remove_exception(), not needed
> v2 -> v3:
>   - take care of pMTU exceptions, too
> 
> Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>

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

* Re: [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries
  2017-10-19 14:07 [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries Paolo Abeni
  2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
  2017-10-19 14:07 ` [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst Paolo Abeni
@ 2017-10-21  0:40 ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-10-21  0:40 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, weiwan, edumazet, hannes, kafai

From: Paolo Abeni <pabeni@redhat.com>
Date: Thu, 19 Oct 2017 16:07:09 +0200

> This series addresses 2 different but related issues with RTF_CACHE introduced
> by the recent refactory.
> 
> patch 1 restore the gc timer for such routes
> patch 2 removes the aged out dst from the fib tree, properly coping with pMTU
> routes
> 
> v1 -> v2:
>  - dropped the  for ip route show cache
>  - avoid touching dst.obsolete when the dst is aged out
> 
> v2 -> v3:
>  - take care of pMTU exceptions

Series applied, thank you.

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

end of thread, other threads:[~2017-10-21  0:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-19 14:07 [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries Paolo Abeni
2017-10-19 14:07 ` [PATCH net-next v3 1/2] ipv6: start fib6 gc on RTF_CACHE dst creation Paolo Abeni
2017-10-19 20:13   ` Wei Wang
2017-10-19 21:01   ` Martin KaFai Lau
2017-10-19 14:07 ` [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst Paolo Abeni
2017-10-19 20:19   ` Wei Wang
2017-10-19 21:02   ` Martin KaFai Lau
2017-10-21  0:40 ` [PATCH net-next v3 0/2] ipv6: fixes for RTF_CACHE entries David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).