From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 667F0C282DD for ; Fri, 10 Jan 2020 17:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FD7120721 for ; Fri, 10 Jan 2020 17:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578675620; bh=fcF2Z0VWRYg6YqmRTCZGD/aAhbfa8rxUsLaBDZY+QfY=; h=From:To:Cc:Subject:Date:List-ID:From; b=1R/1URXUNImp5vAMU0RW682Q2++4UyDDxNa4cm/jsDnlTMTRil++3SgF1tQxQNx7H 96QEUZOq5ixuySEFe9o+PAParm8icGsrxvNSki25/uJ+/12yHVZurCk9WZzbMIIb4H 1uSp2If/3dfo9nsrXEPo3XvrCX0oHJQ2/J1ATugQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728513AbgAJRAT (ORCPT ); Fri, 10 Jan 2020 12:00:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:37308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgAJRAT (ORCPT ); Fri, 10 Jan 2020 12:00:19 -0500 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F48920673; Fri, 10 Jan 2020 17:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578675618; bh=fcF2Z0VWRYg6YqmRTCZGD/aAhbfa8rxUsLaBDZY+QfY=; h=From:To:Cc:Subject:Date:From; b=Bqk1d49HP3PEsy1ojwD4Pa6aOELCy8/aeKzc91zQTmVfDhhIrakPHSLWaN6XXoF2j kFOyPbu4CLuOISJOP/xBMZ0zdH0G0NFUs93KPhkVO7XRfEOhs7rJvq9RVTaVz2Bg9B qA1bhKyPjNSvVyV1LsBVSTWH+J6dn2soDfZ/3zI8= From: David Ahern To: davem@davemloft.net, jakub.kicinski@netronome.com Cc: netdev@vger.kernel.org, haegar@sdinet.de, David Ahern Subject: [PATCH net] ipv4: Detect rollover in specific fib table dump Date: Fri, 10 Jan 2020 09:03:58 -0800 Message-Id: <20200110170358.29474-1-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Sven-Haegar reported looping on fib dumps when 255.255.255.255 route has been added to a table. The looping is caused by the key rolling over from FFFFFFFF to 0. When dumping a specific table only, we need a means to detect when the table dump is done. The key and count saved to cb args are both 0 only at the start of the table dump. If key is 0 and count > 0, then we are in the rollover case. Detect and return to avoid looping. This only affects dumps of a specific table; for dumps of all tables (the case prior to the change in the Fixes tag) inet_dump_fib moved the entry counter to the next table and reset the cb args used by fib_table_dump and fn_trie_dump_leaf, so the rollover ffffffff back to 0 did not cause looping with the dumps. Fixes: effe67926624 ("net: Enable kernel side filtering of route dumps") Reported-by: Sven-Haegar Koch Signed-off-by: David Ahern --- net/ipv4/fib_trie.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index b9df9c09b84e..195469a13371 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -2193,6 +2193,12 @@ int fib_table_dump(struct fib_table *tb, struct sk_buff *skb, int count = cb->args[2]; t_key key = cb->args[3]; + /* First time here, count and key are both always 0. Count > 0 + * and key == 0 means the dump has wrapped around and we are done. + */ + if (count && !key) + return skb->len; + while ((l = leaf_walk_rcu(&tp, key)) != NULL) { int err; -- 2.11.0