]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
devlink: relax dpipe table show dependency on resources
authorJiri Pirko <jiri@mellanox.com>
Thu, 21 Feb 2019 10:55:56 +0000 (11:55 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 21 Feb 2019 22:21:19 +0000 (14:21 -0800)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c

index 3651e90c115975d077c726c6611e2f0f9f9dc2cb..cced8d619f9f8af8d143e9b6cecf5d72e824b91e 100644 (file)
@@ -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);