From: dsahern@kernel.org
To: netdev@vger.kernel.org
Cc: idosch@mellanox.com, jiri@mellanox.com,
jakub.kicinski@netronome.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 2/3] netdevsim: Add extack error message for devlink reload
Date: Mon, 4 Jun 2018 15:15:02 -0700 [thread overview]
Message-ID: <20180604221503.20329-3-dsahern@kernel.org> (raw)
In-Reply-To: <20180604221503.20329-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
devlink reset command can fail if a FIB resource limit is set to a value
lower than the current occupancy. Return a proper message indicating the
reason for the failure.
$ devlink resource sh netdevsim/netdevsim0
netdevsim/netdevsim0:
name IPv4 size unlimited unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
resources:
name fib size unlimited occ 43 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
name fib-rules size unlimited occ 4 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
name IPv6 size unlimited unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
resources:
name fib size unlimited occ 54 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
name fib-rules size unlimited occ 3 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
$ devlink resource set netdevsim/netdevsim0 path /IPv4/fib size 40
$ devlink dev reload netdevsim/netdevsim0
Error: netdevsim: New size is less than current occupancy.
devlink answers: Invalid argument
Signed-off-by: David Ahern <dsahern@gmail.com>
---
drivers/net/netdevsim/devlink.c | 4 ++--
drivers/net/netdevsim/fib.c | 9 ++++++---
drivers/net/netdevsim/netdevsim.h | 3 ++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/netdevsim/devlink.c b/drivers/net/netdevsim/devlink.c
index e8366cf372ff..ba663e5af168 100644
--- a/drivers/net/netdevsim/devlink.c
+++ b/drivers/net/netdevsim/devlink.c
@@ -163,7 +163,7 @@ static int nsim_devlink_reload(struct devlink *devlink,
err = devlink_resource_size_get(devlink, res_ids[i], &val);
if (!err) {
- err = nsim_fib_set_max(net, res_ids[i], val);
+ err = nsim_fib_set_max(net, res_ids[i], val, extack);
if (err)
return err;
}
@@ -181,7 +181,7 @@ static void nsim_devlink_net_reset(struct net *net)
int i;
for (i = 0; i < ARRAY_SIZE(res_ids); ++i) {
- if (nsim_fib_set_max(net, res_ids[i], (u64)-1)) {
+ if (nsim_fib_set_max(net, res_ids[i], (u64)-1, NULL)) {
pr_err("Failed to reset limit for resource %u\n",
res_ids[i]);
}
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
index 9bfe9e151e13..f61d094746c0 100644
--- a/drivers/net/netdevsim/fib.c
+++ b/drivers/net/netdevsim/fib.c
@@ -64,7 +64,8 @@ u64 nsim_fib_get_val(struct net *net, enum nsim_resource_id res_id, bool max)
return max ? entry->max : entry->num;
}
-int nsim_fib_set_max(struct net *net, enum nsim_resource_id res_id, u64 val)
+int nsim_fib_set_max(struct net *net, enum nsim_resource_id res_id, u64 val,
+ struct netlink_ext_ack *extack)
{
struct nsim_fib_data *fib_data = net_generic(net, nsim_fib_net_id);
struct nsim_fib_entry *entry;
@@ -90,10 +91,12 @@ int nsim_fib_set_max(struct net *net, enum nsim_resource_id res_id, u64 val)
/* not allowing a new max to be less than curren occupancy
* --> no means of evicting entries
*/
- if (val < entry->num)
+ if (val < entry->num) {
+ NL_SET_ERR_MSG_MOD(extack, "New size is less than current occupancy");
err = -EINVAL;
- else
+ } else {
entry->max = val;
+ }
return err;
}
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index 3a8581af3b85..8ca50b72c328 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -126,7 +126,8 @@ void nsim_devlink_exit(void);
int nsim_fib_init(void);
void nsim_fib_exit(void);
u64 nsim_fib_get_val(struct net *net, enum nsim_resource_id res_id, bool max);
-int nsim_fib_set_max(struct net *net, enum nsim_resource_id res_id, u64 val);
+int nsim_fib_set_max(struct net *net, enum nsim_resource_id res_id, u64 val,
+ struct netlink_ext_ack *extack);
#else
static inline int nsim_devlink_setup(struct netdevsim *ns)
{
--
2.11.0
next prev parent reply other threads:[~2018-06-04 22:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 22:15 [PATCH net-next 0/3] devlink: Add extack messages for reload and port split/unsplit dsahern
2018-06-04 22:15 ` [PATCH net-next 1/3] devlink: Add extack to reload and port_{un,}split operations dsahern
2018-06-05 7:50 ` Jiri Pirko
2018-06-04 22:15 ` dsahern [this message]
2018-06-04 22:47 ` [PATCH net-next 2/3] netdevsim: Add extack error message for devlink reload Jakub Kicinski
2018-06-04 22:15 ` [PATCH net-next 3/3] mlxsw: Add extack messages for port_{un,}split failures dsahern
2018-06-05 5:56 ` Ido Schimmel
2018-06-05 7:52 ` [PATCH net-next 3/3] mlxsw: Add extack messages for port_{un,}split failures^[ Jiri Pirko
2018-06-05 8:05 ` [PATCH net-next 3/3] mlxsw: Add extack messages for port_{un,}split failures? Ido Schimmel
2018-06-05 8:18 ` Jiri Pirko
2018-06-05 14:24 ` David Miller
2018-06-05 14:58 ` David Ahern
2018-06-05 15:05 ` David Miller
2018-06-05 15:05 ` Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180604221503.20329-3-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=jakub.kicinski@netronome.com \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.