From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F2C3245C76; Mon, 4 Nov 2024 12:14:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFA61410F2; Mon, 4 Nov 2024 12:11:25 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9B53A4021F for ; Mon, 4 Nov 2024 12:10:46 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XhpcC5Tpcz10PZ2; Mon, 4 Nov 2024 19:08:27 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id 6F72B180064; Mon, 4 Nov 2024 19:10:45 +0800 (CST) Received: from localhost.huawei.com (10.50.165.33) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 4 Nov 2024 19:10:45 +0800 From: Dengdui Huang To: CC: , , , , , , , , , , Subject: [PATCH v5 41/52] net/mlx5: replace strerror with reentrant version Date: Mon, 4 Nov 2024 19:10:26 +0800 Message-ID: <20241104111037.3632161-42-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241104111037.3632161-1-huangdengdui@huawei.com> References: <20231114082539.1858594-1-huangdengdui@huawei.com> <20241104111037.3632161-1-huangdengdui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500011.china.huawei.com (7.185.36.84) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The function strerror() is insecure in a multi-thread environment. This patch uses strerror_r() to replace it. Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng Acked-by: Morten Brørup Acked-by: Huisong Li --- drivers/net/mlx5/linux/mlx5_os.c | 5 ++- drivers/net/mlx5/linux/mlx5_socket.c | 40 ++++++++++++++++------- drivers/net/mlx5/linux/mlx5_verbs.c | 20 ++++++++---- drivers/net/mlx5/mlx5_devx.c | 9 ++++-- drivers/net/mlx5/mlx5_rxq.c | 12 ++++--- drivers/net/mlx5/mlx5_rxtx.c | 5 ++- drivers/net/mlx5/mlx5_stats.c | 5 ++- drivers/net/mlx5/mlx5_testpmd.c | 48 ++++++++++++++++++++-------- drivers/net/mlx5/windows/mlx5_os.c | 6 ++-- 9 files changed, 107 insertions(+), 43 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 0a8de88759..0ed5ba38a5 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1147,6 +1147,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, int nl_rdma; int i; struct mlx5_indexed_pool_config icfg[RTE_DIM(default_icfg)]; + char errmsg[RTE_STRERR_BUFSIZE]; memcpy(icfg, default_icfg, sizeof(icfg)); /* Determine if this port representor is supposed to be spawned. */ @@ -1256,7 +1257,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err = mlx5_glue->query_port(sh->cdev->ctx, spawn->phys_port, &port_attr); if (err) { - DRV_LOG(ERR, "port query failed: %s", strerror(err)); + if (strerror_r(err, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", err); + DRV_LOG(ERR, "port query failed: %s", errmsg); goto error; } if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c index 6ce0e59643..26c71670ca 100644 --- a/drivers/net/mlx5/linux/mlx5_socket.c +++ b/drivers/net/mlx5/linux/mlx5_socket.c @@ -54,6 +54,7 @@ mlx5_pmd_socket_handle(void *cb __rte_unused) FILE *file = NULL; struct rte_eth_dev *dev; struct rte_flow_error err; + char errmsg[RTE_STRERR_BUFSIZE]; struct mlx5_flow_dump_req *dump_req; struct mlx5_flow_dump_ack *dump_ack; @@ -61,13 +62,16 @@ mlx5_pmd_socket_handle(void *cb __rte_unused) /* Accept the connection from the client. */ conn_sock = accept(server_socket, NULL, NULL); if (conn_sock < 0) { - DRV_LOG(WARNING, "connection failed: %s", strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(WARNING, "connection failed: %s", errmsg); return; } ret = recvmsg(conn_sock, &msg, MSG_WAITALL); if (ret != sizeof(struct mlx5_flow_dump_req)) { - DRV_LOG(WARNING, "wrong message received: %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(WARNING, "wrong message received: %s", errmsg); goto error; } @@ -136,9 +140,11 @@ mlx5_pmd_socket_handle(void *cb __rte_unused) do { ret = sendmsg(conn_sock, &msg, 0); } while (ret < 0 && errno == EINTR); - if (ret < 0) - DRV_LOG(WARNING, "failed to send response %s", - strerror(errno)); + if (ret < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(WARNING, "failed to send response %s", errmsg); + } error: if (conn_sock >= 0) close(conn_sock); @@ -158,6 +164,7 @@ mlx5_pmd_socket_init(void) struct sockaddr_un sun = { .sun_family = AF_UNIX, }; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; int flags; @@ -166,8 +173,9 @@ mlx5_pmd_socket_init(void) return 0; ret = socket(AF_UNIX, SOCK_STREAM, 0); if (ret < 0) { - DRV_LOG(WARNING, "Failed to open mlx5 socket: %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(WARNING, "Failed to open mlx5 socket: %s", errmsg); goto error; } server_socket = ret; @@ -182,22 +190,28 @@ mlx5_pmd_socket_init(void) remove(sun.sun_path); ret = bind(server_socket, (const struct sockaddr *)&sun, sizeof(sun)); if (ret < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(WARNING, - "cannot bind mlx5 socket: %s", strerror(errno)); + "cannot bind mlx5 socket: %s", errmsg); goto remove; } ret = listen(server_socket, 0); if (ret < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(WARNING, "cannot listen on mlx5 socket: %s", - strerror(errno)); + errmsg); goto remove; } server_intr_handle = mlx5_os_interrupt_handler_create (RTE_INTR_INSTANCE_F_PRIVATE, false, server_socket, mlx5_pmd_socket_handle, NULL); if (server_intr_handle == NULL) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(WARNING, "cannot register interrupt handler for mlx5 socket: %s", - strerror(errno)); + errmsg); goto remove; } return 0; @@ -207,7 +221,9 @@ mlx5_pmd_socket_init(void) claim_zero(close(server_socket)); server_socket = -1; error: - DRV_LOG(ERR, "Cannot initialize socket: %s", strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot initialize socket: %s", errmsg); return -errno; } diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 454bd7c77e..1624c8bbeb 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -94,13 +94,16 @@ mlx5_ibv_modify_qp(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, .qp_state = IBV_QPS_RESET, .port_num = dev_port, }; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; if (type != MLX5_TXQ_MOD_RST2RDY) { ret = mlx5_glue->modify_qp(obj->qp, &mod, IBV_QP_STATE); if (ret) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(ERR, "Cannot change Tx QP state to RESET %s", - strerror(errno)); + errmsg); rte_errno = errno; return ret; } @@ -110,24 +113,27 @@ mlx5_ibv_modify_qp(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, mod.qp_state = IBV_QPS_INIT; ret = mlx5_glue->modify_qp(obj->qp, &mod, IBV_QP_STATE | IBV_QP_PORT); if (ret) { - DRV_LOG(ERR, "Cannot change Tx QP state to INIT %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot change Tx QP state to INIT %s", errmsg); rte_errno = errno; return ret; } mod.qp_state = IBV_QPS_RTR; ret = mlx5_glue->modify_qp(obj->qp, &mod, IBV_QP_STATE); if (ret) { - DRV_LOG(ERR, "Cannot change Tx QP state to RTR %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot change Tx QP state to RTR %s", errmsg); rte_errno = errno; return ret; } mod.qp_state = IBV_QPS_RTS; ret = mlx5_glue->modify_qp(obj->qp, &mod, IBV_QP_STATE); if (ret) { - DRV_LOG(ERR, "Cannot change Tx QP state to RTS %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot change Tx QP state to RTS %s", errmsg); rte_errno = errno; return ret; } diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 8ebe784000..1c6fbb597a 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -162,6 +162,7 @@ mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, uint8_t dev_port) { struct mlx5_devx_modify_sq_attr msq_attr = { 0 }; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; if (type != MLX5_TXQ_MOD_RST2RDY) { @@ -173,8 +174,10 @@ mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, msq_attr.state = MLX5_SQC_STATE_RST; ret = mlx5_devx_cmd_modify_sq(obj->sq_obj.sq, &msq_attr); if (ret) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(ERR, "Cannot change the Tx SQ state to RESET" - " %s", strerror(errno)); + " %s", errmsg); rte_errno = errno; return ret; } @@ -185,8 +188,10 @@ mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, msq_attr.state = MLX5_SQC_STATE_RDY; ret = mlx5_devx_cmd_modify_sq(obj->sq_obj.sq, &msq_attr); if (ret) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(ERR, "Cannot change the Tx SQ state to READY" - " %s", strerror(errno)); + " %s", errmsg); rte_errno = errno; return ret; } diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index c6655b7db4..8ad36546b4 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -481,14 +481,16 @@ mlx5_rx_queue_stop_primary(struct rte_eth_dev *dev, uint16_t idx) struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_rxq_priv *rxq = mlx5_rxq_get(dev, idx); struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; MLX5_ASSERT(rxq != NULL && rxq_ctrl != NULL); MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); ret = priv->obj_ops.rxq_obj_modify(rxq, MLX5_RXQ_MOD_RDY2RST); if (ret) { - DRV_LOG(ERR, "Cannot change Rx WQ state to RESET: %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot change Rx WQ state to RESET: %s", errmsg); rte_errno = errno; return ret; } @@ -567,6 +569,7 @@ mlx5_rx_queue_start_primary(struct rte_eth_dev *dev, uint16_t idx) struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_rxq_priv *rxq = mlx5_rxq_get(dev, idx); struct mlx5_rxq_data *rxq_data = &rxq->ctrl->rxq; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; MLX5_ASSERT(rxq != NULL && rxq->ctrl != NULL); @@ -586,8 +589,9 @@ mlx5_rx_queue_start_primary(struct rte_eth_dev *dev, uint16_t idx) rte_io_wmb(); ret = priv->obj_ops.rxq_obj_modify(rxq, MLX5_RXQ_MOD_RST2RDY); if (ret) { - DRV_LOG(ERR, "Cannot change Rx WQ state to READY: %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "Cannot change Rx WQ state to READY: %s", errmsg); rte_errno = errno; return ret; } diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index eadadcdffb..314d2d8c6b 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -394,6 +394,7 @@ mlx5_queue_state_modify_primary(struct rte_eth_dev *dev, const struct mlx5_mp_arg_queue_state_modify *sm) { int ret; + char errmsg[RTE_STRERR_BUFSIZE]; struct mlx5_priv *priv = dev->data->dev_private; if (sm->is_wq) { @@ -401,8 +402,10 @@ mlx5_queue_state_modify_primary(struct rte_eth_dev *dev, ret = priv->obj_ops.rxq_obj_modify(rxq, sm->state); if (ret) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); DRV_LOG(ERR, "Cannot change Rx WQ state to %u - %s", - sm->state, strerror(errno)); + sm->state, errmsg); rte_errno = errno; return ret; } diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index f4ac58e2f9..83338dc279 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -243,11 +243,14 @@ mlx5_xstats_reset(struct rte_eth_dev *dev) uint16_t stats_n = 0; uint16_t stats_n_2nd = 0; bool bond_master = (priv->master && priv->pf_bond >= 0); + char errmsg[RTE_STRERR_BUFSIZE]; ret = mlx5_os_get_stats_n(dev, bond_master, &stats_n, &stats_n_2nd); if (ret < 0) { + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); DRV_LOG(ERR, "port %u cannot get stats: %s", dev->data->port_id, - strerror(-ret)); + errmsg); return ret; } if (xstats_ctrl->stats_n != stats_n || diff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c index 1bb5a89559..02fbd59582 100644 --- a/drivers/net/mlx5/mlx5_testpmd.c +++ b/drivers/net/mlx5/mlx5_testpmd.c @@ -202,6 +202,7 @@ mlx5_test_extend_devargs(char *identifier, char *extend) }; struct cmsghdr *cmsg; const char *path = mlx5_test_get_socket_path(extend + 1); + char errmsg[RTE_STRERR_BUFSIZE]; size_t len = 1; int socket_fd; int ret; @@ -214,14 +215,17 @@ mlx5_test_extend_devargs(char *identifier, char *extend) /* Initialize IPC channel. */ socket_fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); if (socket_fd < 0) { - TESTPMD_LOG(ERR, "Failed to create unix socket: %s\n", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + TESTPMD_LOG(ERR, "Failed to create unix socket: %s\n", errmsg); return -1; } rte_strlcpy(un.sun_path, path, sizeof(un.sun_path)); if (connect(socket_fd, (struct sockaddr *)&un, sizeof(un)) < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); TESTPMD_LOG(ERR, "Failed to connect %s: %s\n", un.sun_path, - strerror(errno)); + errmsg); close(socket_fd); return -1; } @@ -231,8 +235,10 @@ mlx5_test_extend_devargs(char *identifier, char *extend) ret = sendmsg(socket_fd, &msgh, 0); } while (ret < 0 && errno == EINTR); if (ret < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); TESTPMD_LOG(ERR, "Failed to send request to (%s): %s\n", path, - strerror(errno)); + errmsg); close(socket_fd); return -1; } @@ -420,6 +426,7 @@ static void cmd_port_host_shaper_parsed(void *parsed_result, __rte_unused void *data) { struct cmd_port_host_shaper_result *res = parsed_result; + char errmsg[RTE_STRERR_BUFSIZE]; int ret = 0; if ((strcmp(res->mlx5, "mlx5") == 0) && @@ -430,8 +437,11 @@ static void cmd_port_host_shaper_parsed(void *parsed_result, (strcmp(res->rate, "rate") == 0)) ret = mlx5_test_set_port_host_shaper(res->port_num, res->fr, res->rate_num); - if (ret < 0) - printf("cmd_port_host_shaper error: (%s)\n", strerror(-ret)); + if (ret < 0) { + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); + printf("cmd_port_host_shaper error: (%s)\n", errmsg); + } } static cmdline_parse_token_string_t cmd_port_host_shaper_mlx5 = @@ -565,6 +575,7 @@ mlx5_cmd_map_ext_rxq_parsed(void *parsed_result, __rte_unused void *data) { struct mlx5_cmd_map_ext_rxq *res = parsed_result; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; if (port_id_is_invalid(res->port_id, ENABLED_WARN)) @@ -590,7 +601,9 @@ mlx5_cmd_map_ext_rxq_parsed(void *parsed_result, res->sw_queue_id); break; default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); + fprintf(stderr, "programming error: (%s)\n", errmsg); } } @@ -642,6 +655,7 @@ mlx5_cmd_unmap_ext_rxq_parsed(void *parsed_result, __rte_unused void *data) { struct mlx5_cmd_unmap_ext_rxq *res = parsed_result; + char errmsg[RTE_STRERR_BUFSIZE]; int ret; if (port_id_is_invalid(res->port_id, ENABLED_WARN)) @@ -663,7 +677,9 @@ mlx5_cmd_unmap_ext_rxq_parsed(void *parsed_result, fprintf(stderr, "function not implemented or supported\n"); break; default: - fprintf(stderr, "programming error: (%s)\n", strerror(-ret)); + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); + fprintf(stderr, "programming error: (%s)\n", errmsg); } } @@ -731,6 +747,7 @@ mlx5_cmd_set_flow_engine_mode_parsed(void *parsed_result, { struct mlx5_cmd_set_flow_engine_mode *res = parsed_result; enum rte_pmd_mlx5_flow_engine_mode mode; + char errmsg[RTE_STRERR_BUFSIZE]; uint32_t flag; int ret; @@ -743,13 +760,16 @@ mlx5_cmd_set_flow_engine_mode_parsed(void *parsed_result, ret = rte_pmd_mlx5_flow_engine_set_mode(mode, flag); - if (ret < 0) + if (ret < 0) { + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); fprintf(stderr, "Fail to set flow_engine to %s mode with flag 0x%x, error %s\n", mode == RTE_PMD_MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag, - strerror(-ret)); - else + errmsg); + } else { TESTPMD_LOG(DEBUG, "Set %d ports flow_engine to %s mode with flag 0x%x\n", ret, mode == RTE_PMD_MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag); + } } cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_mlx5 = @@ -1164,6 +1184,7 @@ mlx5_cmd_destroy_tlv_options_parsed(void *parsed_result, __rte_unused void *data) { struct mlx5_cmd_destroy_tlv_options *res = parsed_result; + char errmsg[RTE_STRERR_BUFSIZE]; struct mlx5_port *port; int ret; @@ -1176,8 +1197,9 @@ mlx5_cmd_destroy_tlv_options_parsed(void *parsed_result, ret = rte_pmd_mlx5_destroy_geneve_tlv_parser(port->geneve_tlv_parser_handle); if (ret < 0) { - fprintf(stderr, "Fail to destroy GENEVE TLV parser: %s\n", - strerror(-ret)); + if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret); + fprintf(stderr, "Fail to destroy GENEVE TLV parser: %s\n", errmsg); return; } diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 0ebd233595..8032616268 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -354,6 +354,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, uint16_t port_id; int i; struct mlx5_indexed_pool_config icfg[RTE_DIM(default_icfg)]; + char errmsg[RTE_STRERR_BUFSIZE]; memcpy(icfg, default_icfg, sizeof(icfg)); /* Build device name. */ @@ -381,8 +382,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, */ err = mlx5_glue->devx_init_showdown_event(sh->cdev->ctx); if (err) { - DRV_LOG(ERR, "failed to init showdown event: %s", - strerror(errno)); + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); + DRV_LOG(ERR, "failed to init showdown event: %s", errmsg); goto error; } /* Allocate private eth device data. */ -- 2.33.0