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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,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 46F05C2D0BF for ; Tue, 10 Dec 2019 17:25:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 192312077B for ; Tue, 10 Dec 2019 17:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Dshz/T+V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbfLJRZA (ORCPT ); Tue, 10 Dec 2019 12:25:00 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:40493 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727892AbfLJRY6 (ORCPT ); Tue, 10 Dec 2019 12:24:58 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 54DCE2232A; Tue, 10 Dec 2019 12:24:58 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 10 Dec 2019 12:24:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=YPXNac4fp71aDfq5eNTVlHrgh56gIoT9O0TtDOP6jsE=; b=Dshz/T+V pgnZ0Mv1wM338Z0FNcMj3LsBBIoZU2nfuPDywaviucGQMxRrj5n08NeUMJmYlGFg duiK99qFjxpXFZX4RMGPoZ/pmxtPj7O5bQjeRkOBw7wyx7MQrnwfrtAUj+olIVH+ VaEQpO3LK9u2KLiUToSUiJ+MOpLOzkj9tttCBS9XsaJegngV6KJjJyv/IyEUmrhJ aqLalSSWGK3B5O2/G7rhCUdyh6OOMcO+TuZtsTrEK3Qt7Ms6iE7L+SR1BE+NBcwb tpb2efP8Gj45a8ze8vCCMEMnWVJHm63Ws/9nx/XGMpsa+ol+Yhea2i1xfJalFSS/ DYlUkntf28VB+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecukfhppeduleefrdegjedrudeihedrvdehudenucfrrghrrghmpe hmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrghenucevlhhushhtvghr ufhiiigvpeei X-ME-Proxy: Received: from splinter.mtl.com (unknown [193.47.165.251]) by mail.messagingengine.com (Postfix) with ESMTPA id ECEDD8005B; Tue, 10 Dec 2019 12:24:56 -0500 (EST) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, dsahern@gmail.com, roopa@cumulusnetworks.com, mlxsw@mellanox.com, Ido Schimmel Subject: [PATCH net-next 7/9] ipv4: Only Replay routes of interest to new listeners Date: Tue, 10 Dec 2019 19:24:00 +0200 Message-Id: <20191210172402.463397-8-idosch@idosch.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191210172402.463397-1-idosch@idosch.org> References: <20191210172402.463397-1-idosch@idosch.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel When a new listener is registered to the FIB notification chain it receives a dump of all the available routes in the system. Instead, make sure to only replay the IPv4 routes that are actually used in the data path and are of any interest to the new listener. Signed-off-by: Ido Schimmel --- net/ipv4/fib_trie.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 60947a44d363..eff45e7795ba 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -2096,6 +2096,7 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb, struct netlink_ext_ack *extack) { struct fib_alias *fa; + int last_slen = -1; int err; hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) { @@ -2115,6 +2116,16 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb, fa, extack); if (err) return err; + + if (fa->fa_slen == last_slen) + continue; + + last_slen = fa->fa_slen; + err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_REPLACE_TMP, + l->key, KEYLENGTH - fa->fa_slen, + fa, extack); + if (err) + return err; } return 0; } -- 2.23.0