lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190615140751.17661-9-idosch@idosch.org>
Date:   Sat, 15 Jun 2019 17:07:42 +0300
From:   Ido Schimmel <idosch@...sch.org>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, dsahern@...il.com, jiri@...lanox.com,
        alexpe@...lanox.com, mlxsw@...lanox.com,
        Ido Schimmel <idosch@...lanox.com>
Subject: [PATCH net-next 08/17] netdevsim: Adjust accounting for IPv6 multipath notifications

From: Ido Schimmel <idosch@...lanox.com>

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 <idosch@...lanox.com>
Acked-by: Jiri Pirko <jiri@...lanox.com>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ