From patchwork Thu Dec 26 06:00:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duan Jiong X-Patchwork-Id: 305204 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 81D7B2C009C for ; Thu, 26 Dec 2013 17:00:47 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751034Ab3LZGAn (ORCPT ); Thu, 26 Dec 2013 01:00:43 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:35254 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750745Ab3LZGAm (ORCPT ); Thu, 26 Dec 2013 01:00:42 -0500 X-IronPort-AV: E=Sophos;i="4.95,553,1384272000"; d="scan'208";a="9329286" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 26 Dec 2013 13:57:07 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id rBQ60coK007317; Thu, 26 Dec 2013 14:00:41 +0800 Received: from [10.167.225.86] ([10.167.225.86]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013122613595753-721384 ; Thu, 26 Dec 2013 13:59:57 +0800 Message-ID: <52BBC5F9.4050904@cn.fujitsu.com> Date: Thu, 26 Dec 2013 14:00:25 +0800 From: Duan Jiong User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: David Miller CC: netdev@vger.kernel.org Subject: [PATCH] ipv6: shouldn't dump the expired routes X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/26 13:59:57, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/12/26 14:00:00, Serialize complete at 2013/12/26 14:00:00 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If we execute the command "ip -6 route show table all", those routes that have been expired will be dumped. But as everyone knows, those expired routes will not be used, and they will be deleted by the kernel. So why we still need to dump they, and just don't dump them. Signed-off-by: Duan Jiong --- include/net/ip6_route.h | 2 ++ net/ipv6/ip6_fib.c | 3 +++ net/ipv6/route.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index c2626ce..32fa188 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -103,6 +103,8 @@ void fib6_force_start_gc(struct net *net); struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, const struct in6_addr *addr, bool anycast); +bool rt6_check_expired(const struct rt6_info *rt); + /* * support functions for ND * diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 5550a81..f57a6bb 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -278,6 +278,9 @@ static int fib6_dump_node(struct fib6_walker_t *w) struct rt6_info *rt; for (rt = w->leaf; rt; rt = rt->dst.rt6_next) { + if (rt6_check_expired(rt)) + continue; + res = rt6_dump_route(rt, w->args); if (res < 0) { /* Frame is full, suspend walking */ diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 89b2735..abf5f05 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -348,7 +348,7 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, } } -static bool rt6_check_expired(const struct rt6_info *rt) +bool rt6_check_expired(const struct rt6_info *rt) { if (rt->rt6i_flags & RTF_EXPIRES) { if (time_after(jiffies, rt->dst.expires))