netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).