* [PATCH] ipv4: Fix flushing of cached routing informations
@ 2012-10-18 5:27 Steffen Klassert
2012-10-18 6:52 ` Julian Anastasov
0 siblings, 1 reply; 6+ messages in thread
From: Steffen Klassert @ 2012-10-18 5:27 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Currently we can not flush cached pmtu/redirect informations via
the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
of the old route and reset the nh exeption if the old route is
expired when we bind a new route to a nh exeption.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 432f4bb..defb98d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1163,8 +1163,17 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
spin_lock_bh(&fnhe_lock);
if (daddr == fnhe->fnhe_daddr) {
- struct rtable *orig;
+ struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
+ rcu_assign_pointer(fnhe->fnhe_rth, rt);
+ if (orig) {
+ if (rt_is_expired(orig)) {
+ fnhe->fnhe_gw = 0;
+ fnhe->fnhe_pmtu = 0;
+ fnhe->fnhe_expires = 0;
+ }
+ rt_free(orig);
+ }
if (fnhe->fnhe_pmtu) {
unsigned long expires = fnhe->fnhe_expires;
unsigned long diff = expires - jiffies;
@@ -1181,11 +1190,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
} else if (!rt->rt_gateway)
rt->rt_gateway = daddr;
- orig = rcu_dereference(fnhe->fnhe_rth);
- rcu_assign_pointer(fnhe->fnhe_rth, rt);
- if (orig)
- rt_free(orig);
-
fnhe->fnhe_stamp = jiffies;
ret = true;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ipv4: Fix flushing of cached routing informations
2012-10-18 5:27 [PATCH] ipv4: Fix flushing of cached routing informations Steffen Klassert
@ 2012-10-18 6:52 ` Julian Anastasov
2012-10-18 6:54 ` Steffen Klassert
2012-10-18 7:17 ` [PATCH v2] " Steffen Klassert
0 siblings, 2 replies; 6+ messages in thread
From: Julian Anastasov @ 2012-10-18 6:52 UTC (permalink / raw)
To: Steffen Klassert; +Cc: David Miller, netdev
Hello,
On Thu, 18 Oct 2012, Steffen Klassert wrote:
> Currently we can not flush cached pmtu/redirect informations via
> the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
> of the old route and reset the nh exeption if the old route is
> expired when we bind a new route to a nh exeption.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
> net/ipv4/route.c | 16 ++++++++++------
> 1 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 432f4bb..defb98d 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1163,8 +1163,17 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
> spin_lock_bh(&fnhe_lock);
>
> if (daddr == fnhe->fnhe_daddr) {
> - struct rtable *orig;
> + struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
> + rcu_assign_pointer(fnhe->fnhe_rth, rt);
May be the above rcu_assign_pointer should be after
... if (!rt->rt_gateway)
rt->rt_gateway = daddr;
part. It is possible another __mkroute_output
caller to get the cached fnhe->fnhe_rth without valid
rt->rt_gateway. rcu_assign_pointer should be after all
writes to rt.
> + if (orig) {
> + if (rt_is_expired(orig)) {
> + fnhe->fnhe_gw = 0;
> + fnhe->fnhe_pmtu = 0;
> + fnhe->fnhe_expires = 0;
> + }
> + rt_free(orig);
> + }
> if (fnhe->fnhe_pmtu) {
> unsigned long expires = fnhe->fnhe_expires;
> unsigned long diff = expires - jiffies;
> @@ -1181,11 +1190,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
> } else if (!rt->rt_gateway)
> rt->rt_gateway = daddr;
>
> - orig = rcu_dereference(fnhe->fnhe_rth);
> - rcu_assign_pointer(fnhe->fnhe_rth, rt);
> - if (orig)
> - rt_free(orig);
> -
> fnhe->fnhe_stamp = jiffies;
> ret = true;
> }
> --
> 1.7.0.4
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ipv4: Fix flushing of cached routing informations
2012-10-18 6:52 ` Julian Anastasov
@ 2012-10-18 6:54 ` Steffen Klassert
2012-10-18 7:17 ` [PATCH v2] " Steffen Klassert
1 sibling, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2012-10-18 6:54 UTC (permalink / raw)
To: Julian Anastasov; +Cc: David Miller, netdev
On Thu, Oct 18, 2012 at 09:52:37AM +0300, Julian Anastasov wrote:
>
> Hello,
>
> On Thu, 18 Oct 2012, Steffen Klassert wrote:
>
> > Currently we can not flush cached pmtu/redirect informations via
> > the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
> > of the old route and reset the nh exeption if the old route is
> > expired when we bind a new route to a nh exeption.
> >
> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> > ---
> > net/ipv4/route.c | 16 ++++++++++------
> > 1 files changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > index 432f4bb..defb98d 100644
> > --- a/net/ipv4/route.c
> > +++ b/net/ipv4/route.c
> > @@ -1163,8 +1163,17 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
> > spin_lock_bh(&fnhe_lock);
> >
> > if (daddr == fnhe->fnhe_daddr) {
> > - struct rtable *orig;
> > + struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
> > + rcu_assign_pointer(fnhe->fnhe_rth, rt);
>
> May be the above rcu_assign_pointer should be after
>
> ... if (!rt->rt_gateway)
> rt->rt_gateway = daddr;
>
> part. It is possible another __mkroute_output
> caller to get the cached fnhe->fnhe_rth without valid
> rt->rt_gateway. rcu_assign_pointer should be after all
> writes to rt.
Right, I'll send an updated version.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] ipv4: Fix flushing of cached routing informations
2012-10-18 6:52 ` Julian Anastasov
2012-10-18 6:54 ` Steffen Klassert
@ 2012-10-18 7:17 ` Steffen Klassert
2012-10-18 7:40 ` Eric Dumazet
2012-10-18 19:35 ` David Miller
1 sibling, 2 replies; 6+ messages in thread
From: Steffen Klassert @ 2012-10-18 7:17 UTC (permalink / raw)
To: Julian Anastasov; +Cc: David Miller, netdev
Currently we can not flush cached pmtu/redirect informations via
the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
of the old route and reset the nh exeption if the old route is
expired when we bind a new route to a nh exeption.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/route.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 432f4bb..a8c6512 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1163,8 +1163,12 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
spin_lock_bh(&fnhe_lock);
if (daddr == fnhe->fnhe_daddr) {
- struct rtable *orig;
-
+ struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
+ if (orig && rt_is_expired(orig)) {
+ fnhe->fnhe_gw = 0;
+ fnhe->fnhe_pmtu = 0;
+ fnhe->fnhe_expires = 0;
+ }
if (fnhe->fnhe_pmtu) {
unsigned long expires = fnhe->fnhe_expires;
unsigned long diff = expires - jiffies;
@@ -1181,7 +1185,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
} else if (!rt->rt_gateway)
rt->rt_gateway = daddr;
- orig = rcu_dereference(fnhe->fnhe_rth);
rcu_assign_pointer(fnhe->fnhe_rth, rt);
if (orig)
rt_free(orig);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ipv4: Fix flushing of cached routing informations
2012-10-18 7:17 ` [PATCH v2] " Steffen Klassert
@ 2012-10-18 7:40 ` Eric Dumazet
2012-10-18 19:35 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2012-10-18 7:40 UTC (permalink / raw)
To: Steffen Klassert; +Cc: Julian Anastasov, David Miller, netdev
On Thu, 2012-10-18 at 09:17 +0200, Steffen Klassert wrote:
> Currently we can not flush cached pmtu/redirect informations via
> the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
> of the old route and reset the nh exeption if the old route is
> expired when we bind a new route to a nh exeption.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
> net/ipv4/route.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 432f4bb..a8c6512 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -1163,8 +1163,12 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
> spin_lock_bh(&fnhe_lock);
>
> if (daddr == fnhe->fnhe_daddr) {
> - struct rtable *orig;
> -
> + struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
> + if (orig && rt_is_expired(orig)) {
> + fnhe->fnhe_gw = 0;
> + fnhe->fnhe_pmtu = 0;
> + fnhe->fnhe_expires = 0;
> + }
> if (fnhe->fnhe_pmtu) {
> unsigned long expires = fnhe->fnhe_expires;
> unsigned long diff = expires - jiffies;
> @@ -1181,7 +1185,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
> } else if (!rt->rt_gateway)
> rt->rt_gateway = daddr;
>
> - orig = rcu_dereference(fnhe->fnhe_rth);
> rcu_assign_pointer(fnhe->fnhe_rth, rt);
> if (orig)
> rt_free(orig);
Seems good to me. I'll have to rebase my patch, changing these
rcu_dereference() to rcu_dereference_protected() variant.
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ipv4: Fix flushing of cached routing informations
2012-10-18 7:17 ` [PATCH v2] " Steffen Klassert
2012-10-18 7:40 ` Eric Dumazet
@ 2012-10-18 19:35 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2012-10-18 19:35 UTC (permalink / raw)
To: steffen.klassert; +Cc: ja, netdev
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Thu, 18 Oct 2012 09:17:44 +0200
> Currently we can not flush cached pmtu/redirect informations via
> the ipv4_sysctl_rtcache_flush sysctl. We need to check the rt_genid
> of the old route and reset the nh exeption if the old route is
> expired when we bind a new route to a nh exeption.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-18 19:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-18 5:27 [PATCH] ipv4: Fix flushing of cached routing informations Steffen Klassert
2012-10-18 6:52 ` Julian Anastasov
2012-10-18 6:54 ` Steffen Klassert
2012-10-18 7:17 ` [PATCH v2] " Steffen Klassert
2012-10-18 7:40 ` Eric Dumazet
2012-10-18 19:35 ` 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).