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 62343C43603 for ; Tue, 10 Dec 2019 17:24:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37AF3207FF for ; Tue, 10 Dec 2019 17:24:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Pt4eWcTn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbfLJRYy (ORCPT ); Tue, 10 Dec 2019 12:24:54 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:36401 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbfLJRYx (ORCPT ); Tue, 10 Dec 2019 12:24:53 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7C69E22329; Tue, 10 Dec 2019 12:24:52 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 10 Dec 2019 12:24:52 -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=A3eUxKr6bxprcyjzlZCP6Qce/jTIJoX0D3u4UqIvhjc=; b=Pt4eWcTn wku3yajS8h4FyypqvIhtFkgVBE7CcvzzvIp9Uz5Xwr9BUyAHXiFZPPoa3zP5cZ+H ZbXaUNOihI+Klr135fczDPUZpdaNtuuYQjl2QzklZgmZT504p9o1Qf1Opt3Ljhqn e0BlqnQz0aE7hvgnAucU+wRDR2Ze7UhV+wlNTYTwchy37AWIxl2CnDoNVMsA6zvU hgtq+bCEVmSutCV5Qc6yo4D1Y+VGaHWXrwN+xMH+z55EdVn6LuoMzBMHnaM0ljG7 bHyg357lgB0rDRljE2a7t6Bhw3/gROpJrihXOBelTMFoyXVdmKpkX7Gu+lKEJCDk mDJmNKVwHTzLFQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecukfhppeduleefrdegjedrudeihedrvdehudenucfrrghrrghmpe hmrghilhhfrhhomhepihguohhstghhsehiughoshgthhdrohhrghenucevlhhushhtvghr ufhiiigvpedu X-ME-Proxy: Received: from splinter.mtl.com (unknown [193.47.165.251]) by mail.messagingengine.com (Postfix) with ESMTPA id 1B77480066; Tue, 10 Dec 2019 12:24:50 -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 3/9] ipv4: Notify route if replacing currently offloaded one Date: Tue, 10 Dec 2019 19:23:56 +0200 Message-Id: <20191210172402.463397-4-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 replacing a route, its replacement should only be notified in case the replaced route is of any interest to listeners. In other words, if the replaced route is currently used in the data path, which means it is the first route in the FIB alias list with the given {prefix, prefix length, table ID}. Signed-off-by: Ido Schimmel --- net/ipv4/fib_trie.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 9264d6628e9f..6822aa90657a 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -978,6 +978,27 @@ static struct key_vector *fib_find_node(struct trie *t, return n; } +/* Return the first fib alias matching prefix length and table ID. */ +static struct fib_alias *fib_find_first_alias(struct hlist_head *fah, u8 slen, + u32 tb_id) +{ + struct fib_alias *fa; + + hlist_for_each_entry(fa, fah, fa_list) { + if (fa->fa_slen < slen) + continue; + if (fa->fa_slen != slen) + break; + if (fa->tb_id > tb_id) + continue; + if (fa->tb_id != tb_id) + break; + return fa; + } + + return NULL; +} + /* Return the first fib alias matching TOS with * priority less than or equal to PRIO. */ @@ -1217,6 +1238,17 @@ int fib_table_insert(struct net *net, struct fib_table *tb, new_fa->tb_id = tb->tb_id; new_fa->fa_default = -1; + if (fib_find_first_alias(&l->leaf, fa->fa_slen, + tb->tb_id) == fa) { + enum fib_event_type fib_event; + + fib_event = FIB_EVENT_ENTRY_REPLACE_TMP; + err = call_fib_entry_notifiers(net, fib_event, + key, plen, + new_fa, extack); + if (err) + goto out_free_new_fa; + } err = call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_REPLACE, key, plen, new_fa, -- 2.23.0