All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch iproute2] devlink: relax dpipe table show dependency on resources
@ 2019-02-20  9:21 Jiri Pirko
  2019-02-21  2:01 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Pirko @ 2019-02-20  9:21 UTC (permalink / raw)
  To: netdev; +Cc: stephen, dsahern, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Dpipe table show command has a depencency on getting resources.
If resource get command is not supported by the driver, dpipe table
show fails. However, resource is only additional information
in dpipe table show output. So relax the dependency and let
the dpipe tables be shown even if resources get command fails.

Fixes: ead180274caf ("devlink: Add support for resource/dpipe relation")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 devlink/devlink.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 3651e90c1159..00a76060b31d 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -4351,7 +4351,8 @@ static int dpipe_table_show(struct dpipe_ctx *ctx, struct nlattr *nl)
 	size = mnl_attr_get_u32(nla_table[DEVLINK_ATTR_DPIPE_TABLE_SIZE]);
 	counters_enabled = !!mnl_attr_get_u8(nla_table[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED]);
 
-	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID];
+	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] &&
+			 ctx->resources;
 	if (resource_valid) {
 		table->resource_id = mnl_attr_get_u64(nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID]);
 		table->resource_valid = true;
@@ -4467,12 +4468,9 @@ static int cmd_dpipe_table_show(struct dl *dl)
 	dl_opts_put(nlh, dl);
 	err = _mnlg_socket_sndrcv(dl->nlg, nlh, cmd_resource_dump_cb,
 				  &resource_ctx);
-	if (err) {
-		pr_err("error get resources %s\n", strerror(resource_ctx.err));
-		goto err_resource_dump;
-	}
+	if (!err)
+		dpipe_ctx.resources = resource_ctx.resources;
 
-	dpipe_ctx.resources = resource_ctx.resources;
 	flags = NLM_F_REQUEST | NLM_F_ACK;
 	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_DPIPE_TABLE_GET, flags);
 	dl_opts_put(nlh, dl);
@@ -4485,8 +4483,6 @@ static int cmd_dpipe_table_show(struct dl *dl)
 	dpipe_ctx_fini(&dpipe_ctx);
 	return 0;
 
-err_resource_dump:
-	resource_ctx_fini(&resource_ctx);
 err_resource_ctx_init:
 err_headers_get:
 	dpipe_ctx_fini(&dpipe_ctx);
-- 
2.14.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch iproute2] devlink: relax dpipe table show dependency on resources
  2019-02-20  9:21 [patch iproute2] devlink: relax dpipe table show dependency on resources Jiri Pirko
@ 2019-02-21  2:01 ` Stephen Hemminger
  2019-02-21  7:02   ` Jiri Pirko
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2019-02-21  2:01 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: netdev, dsahern, mlxsw

On Wed, 20 Feb 2019 10:21:09 +0100
Jiri Pirko <jiri@resnulli.us> wrote:

> -	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID];
> +	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] &&
> +			 ctx->resources;

When you add a logical AND operator the !! is no longer needed. The !! convention
is used to turn a value of not zero (ie not NULL) into a boolean. When you add the
additional operator the result is already boolean.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch iproute2] devlink: relax dpipe table show dependency on resources
  2019-02-21  2:01 ` Stephen Hemminger
@ 2019-02-21  7:02   ` Jiri Pirko
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2019-02-21  7:02 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, dsahern, mlxsw

Thu, Feb 21, 2019 at 03:01:17AM CET, stephen@networkplumber.org wrote:
>On Wed, 20 Feb 2019 10:21:09 +0100
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> -	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID];
>> +	resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] &&
>> +			 ctx->resources;
>
>When you add a logical AND operator the !! is no longer needed. The !! convention
>is used to turn a value of not zero (ie not NULL) into a boolean. When you add the
>additional operator the result is already boolean.

Okay. Will send v2.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-21  7:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20  9:21 [patch iproute2] devlink: relax dpipe table show dependency on resources Jiri Pirko
2019-02-21  2:01 ` Stephen Hemminger
2019-02-21  7:02   ` Jiri Pirko

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.