From patchwork Mon May 27 11:16:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Teras X-Patchwork-Id: 246577 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4622D2C02EE for ; Mon, 27 May 2013 21:14:59 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757927Ab3E0LOy (ORCPT ); Mon, 27 May 2013 07:14:54 -0400 Received: from mail-ee0-f53.google.com ([74.125.83.53]:62049 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757672Ab3E0LOr (ORCPT ); Mon, 27 May 2013 07:14:47 -0400 Received: by mail-ee0-f53.google.com with SMTP id c1so3764258eek.26 for ; Mon, 27 May 2013 04:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=PmKFdf9YE8LQ0DEmol6AB5cs0RSuOGph0jBIHj16kTE=; b=Csa69IjJrHiz/9Ukion2BR7iHF5g4olTDw2AxbM3BCYqJXFr/+ozeqbsv6gyqCe1cL 17gqddoFvkcWuBbPtRcz9ZT/DVCTqjk3EmLGzHwfjvLqgISi6ueU961jYMpDHg4Wpjyk HYw8ZxFZbya2vwgBbY5FJ96TAcIZSn5t2sAU3QgRtKhH+pJSBj/vqa8cKOixw695wNqn lm2VJ1jmZKhdMtCBddeS9JCr4HsLKgHH2LtI+LSR7zN2l8kcbFodpSSDtFfbhZQ1MZzG x6MCnTIQdk19MHw3wGP67LX58b1ztBf7LYJFpLJZE+efCQIZDaYMnsvFPlS4U0aDPlwX vO1A== X-Received: by 10.15.45.196 with SMTP id b44mr20189877eew.6.1369653285983; Mon, 27 May 2013 04:14:45 -0700 (PDT) Received: from vostro.util.wtbts.net ([83.145.235.199]) by mx.google.com with ESMTPSA id e1sm6514935eem.10.2013.05.27.04.14.44 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 04:14:45 -0700 (PDT) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: netdev@vger.kernel.org Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= , Steffen Klassert Subject: [PATCH net-next 5/6] ipv4: use separate genid for next hop exceptions Date: Mon, 27 May 2013 14:16:15 +0300 Message-Id: <1369653376-4731-6-git-send-email-timo.teras@iki.fi> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1369653376-4731-1-git-send-email-timo.teras@iki.fi> References: <1369653376-4731-1-git-send-email-timo.teras@iki.fi> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org commit 13d82bf5 (ipv4: Fix flushing of cached routing informations) added the support to flush learned pmtu information. However, using rt_genid is quite heavy as it is bumped on route add/change and multicast events amongst other places. These can happen quote often, especially if using dynamic routing protocols. While this is ok with routes (as they are just recreated locally), the pmtu information is learned from remote systems and the icmp notification can come with long delays. It is worthy to have separate genid to avoid excessive pmtu resets. Cc: Steffen Klassert Signed-off-by: Timo Teräs --- include/net/ip_fib.h | 1 + include/net/net_namespace.h | 11 +++++++++++ net/ipv4/route.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index e49db91..44424e9 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -51,6 +51,7 @@ struct rtable; struct fib_nh_exception { struct fib_nh_exception __rcu *fnhe_next; + int fnhe_genid; __be32 fnhe_daddr; u32 fnhe_pmtu; __be32 fnhe_gw; diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index b176978..495bc57 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -118,6 +118,7 @@ struct net { struct netns_ipvs *ipvs; struct sock *diag_nlsk; atomic_t rt_genid; + atomic_t fnhe_genid; }; /* @@ -340,4 +341,14 @@ static inline void rt_genid_bump(struct net *net) atomic_inc(&net->rt_genid); } +static inline int fnhe_genid(struct net *net) +{ + return atomic_read(&net->fnhe_genid); +} + +static inline void fnhe_genid_bump(struct net *net) +{ + atomic_inc(&net->fnhe_genid); +} + #endif /* __NET_NET_NAMESPACE_H */ diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a4082be..403e283 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -658,6 +658,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, fnhe->fnhe_next = hash->chain; rcu_assign_pointer(hash->chain, fnhe); } + fnhe->fnhe_genid = fnhe_genid(dev_net(nh->nh_dev)); fnhe->fnhe_daddr = daddr; fnhe->fnhe_gw = gw; fnhe->fnhe_pmtu = pmtu; @@ -1236,8 +1237,11 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, spin_lock_bh(&fnhe_lock); if (daddr == fnhe->fnhe_daddr) { + int genid = fnhe_genid(dev_net(rt->dst.dev)); struct rtable *orig = rcu_dereference(fnhe->fnhe_rth); - if (orig && rt_is_expired(orig)) { + + if (fnhe->fnhe_genid != genid) { + fnhe->fnhe_genid = genid; fnhe->fnhe_gw = 0; fnhe->fnhe_pmtu = 0; fnhe->fnhe_expires = 0; @@ -2443,8 +2447,11 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { + struct net *net = (struct net *)__ctl->extra1; + if (write) { - rt_cache_flush((struct net *)__ctl->extra1); + rt_cache_flush(net); + fnhe_genid_bump(net); return 0; } @@ -2619,6 +2626,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = { static __net_init int rt_genid_init(struct net *net) { atomic_set(&net->rt_genid, 0); + atomic_set(&net->fnhe_genid, 0); get_random_bytes(&net->ipv4.dev_addr_genid, sizeof(net->ipv4.dev_addr_genid)); return 0;