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=-8.7 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,URIBL_BLOCKED,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 DC0A4C31E50 for ; Sat, 15 Jun 2019 14:09:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC5FE2080A for ; Sat, 15 Jun 2019 14:09:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PCy7wmir" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbfFOOJd (ORCPT ); Sat, 15 Jun 2019 10:09:33 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:50783 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbfFOOJd (ORCPT ); Sat, 15 Jun 2019 10:09:33 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 87BCB21EAE; Sat, 15 Jun 2019 10:09:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 15 Jun 2019 10:09:32 -0400 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= fm3; bh=PNjEL9NgRlmRfio2zVd0VgYsZO+aCYvHZKgBOwz5+ok=; b=PCy7wmir JfE2jRZDPh4XRI0T1KoZCiLm7sfI6Xv/LcZqHyQcaeiva8AI3HeftpvARv4y7pAq KfbPzCG1MMYx/ETuxp0ogtPm32qI8POao9/+aM9R442PvlmUSnbPHdtqNnYXHg9d lN+BBDIE4L44zqflL6uswBlqC8Fq5h5JZsONYSHZb40Bu+E9bAhe5G+Tm3qBaRh4 J4KX6n/uuBmL1DeP27inbUSRBicP0FSN3vTzkSPv4K7vBMU0HrsdhRlDSaGFXFyC cUkIzSQ2qrJzW0BmTl+F3xffHf/vqZCIvSH7Leofma4K9NdsS0+vhcc8KeMut91a 5RM11LQoAlLo/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeifedgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecukfhppeejledrudejkedrgeefrddvudeknecurfgrrhgrmhepmh grihhlfhhrohhmpehiughoshgthhesihguohhstghhrdhorhhgnecuvehluhhsthgvrhfu ihiivgepje X-ME-Proxy: Received: from splinter.mtl.com (bzq-79-178-43-218.red.bezeqint.net [79.178.43.218]) by mail.messagingengine.com (Postfix) with ESMTPA id A3675380085; Sat, 15 Jun 2019 10:09:29 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, dsahern@gmail.com, jiri@mellanox.com, alexpe@mellanox.com, mlxsw@mellanox.com, Ido Schimmel Subject: [PATCH net-next 08/17] netdevsim: Adjust accounting for IPv6 multipath notifications Date: Sat, 15 Jun 2019 17:07:42 +0300 Message-Id: <20190615140751.17661-9-idosch@idosch.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190615140751.17661-1-idosch@idosch.org> References: <20190615140751.17661-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 Prepare the driver to process IPv6 multipath routes. Increase / decrease the resource usage based on the number of nexthops notified in an IPv6 multipath notification. Signed-off-by: Ido Schimmel Acked-by: Jiri Pirko --- drivers/net/netdevsim/fib.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c index 83ba5113210d..6e5498ef3855 100644 --- a/drivers/net/netdevsim/fib.c +++ b/drivers/net/netdevsim/fib.c @@ -137,19 +137,20 @@ static int nsim_fib_rule_event(struct nsim_fib_data *data, } static int nsim_fib_account(struct nsim_fib_entry *entry, bool add, + unsigned int num_rt, struct netlink_ext_ack *extack) { int err = 0; if (add) { - if (entry->num < entry->max) { - entry->num++; + if (entry->num + num_rt < entry->max) { + entry->num += num_rt; } else { err = -ENOSPC; NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported fib entries"); } } else { - entry->num--; + entry->num -= num_rt; } return err; @@ -159,14 +160,20 @@ static int nsim_fib_event(struct nsim_fib_data *data, struct fib_notifier_info *info, bool add) { struct netlink_ext_ack *extack = info->extack; + struct fib6_entry_notifier_info *fen6_info; + unsigned int num_rt = 1; int err = 0; switch (info->family) { case AF_INET: - err = nsim_fib_account(&data->ipv4.fib, add, extack); + err = nsim_fib_account(&data->ipv4.fib, add, num_rt, extack); break; case AF_INET6: - err = nsim_fib_account(&data->ipv6.fib, add, extack); + fen6_info = container_of(info, struct fib6_entry_notifier_info, + info); + if (fen6_info->multipath_rt) + num_rt = fen6_info->nsiblings + 1; + err = nsim_fib_account(&data->ipv6.fib, add, num_rt, extack); break; } -- 2.20.1