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 A42E945BAE; Wed, 23 Oct 2024 10:31:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E007742D27; Wed, 23 Oct 2024 10:29:36 +0200 (CEST) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mails.dpdk.org (Postfix) with ESMTP id 04BEA415D7 for ; Wed, 23 Oct 2024 10:29:00 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4XYMdt1Lhkz1ynX9; Wed, 23 Oct 2024 16:29:06 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id E89D71402CD; Wed, 23 Oct 2024 16:28:58 +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; Wed, 23 Oct 2024 16:28:58 +0800 From: Dengdui Huang To: CC: , , , , , , , , Subject: [PATCH v4 32/42] net/mlx4: use rte strerror Date: Wed, 23 Oct 2024 16:28:42 +0800 Message-ID: <20241023082852.2780488-33-huangdengdui@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241023082852.2780488-1-huangdengdui@huawei.com> References: <20231114082539.1858594-44-huangdengdui@huawei.com> <20241023082852.2780488-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: dggems705-chm.china.huawei.com (10.3.19.182) 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 rte_strerror() to replace it. Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Acked-by: Chengwen Feng Acked-by: Morten Brørup --- drivers/net/mlx4/mlx4.c | 14 +++++++------- drivers/net/mlx4/mlx4_ethdev.c | 18 +++++++++--------- drivers/net/mlx4/mlx4_rxq.c | 10 +++++----- drivers/net/mlx4/mlx4_txq.c | 10 +++++----- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 9c2872429f..54073057e8 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -255,7 +255,7 @@ mlx4_dev_configure(struct rte_eth_dev *dev) if (ret) { ERROR("cannot set up internal flow rules (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", - -ret, strerror(-ret), error.type, error.cause, + -ret, rte_strerror(-ret), error.type, error.cause, error.message ? error.message : "(unspecified)"); goto exit; } @@ -302,7 +302,7 @@ mlx4_dev_start(struct rte_eth_dev *dev) ret = mlx4_rss_init(priv); if (ret) { ERROR("%p: cannot initialize RSS resources: %s", - (void *)dev, strerror(-ret)); + (void *)dev, rte_strerror(-ret)); goto err; } #ifdef RTE_LIBRTE_MLX4_DEBUG @@ -319,7 +319,7 @@ mlx4_dev_start(struct rte_eth_dev *dev) ERROR("%p: cannot attach flow rules (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", (void *)dev, - -ret, strerror(-ret), error.type, error.cause, + -ret, rte_strerror(-ret), error.type, error.cause, error.message ? error.message : "(unspecified)"); goto err; } @@ -793,7 +793,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) err = mlx4_init_once(); if (err) { ERROR("unable to init PMD global data: %s", - strerror(rte_errno)); + rte_strerror(rte_errno)); return -rte_errno; } MLX4_ASSERT(pci_drv == &mlx4_driver); @@ -946,7 +946,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) err = mlx4_glue->query_port(ctx, port, &port_attr); if (err) { err = ENODEV; - ERROR("port query failed: %s", strerror(err)); + ERROR("port query failed: %s", rte_strerror(err)); goto port_error; } if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) { @@ -963,7 +963,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) err = mlx4_fd_set_non_blocking(ctx->async_fd); if (err) { ERROR("cannot make asynchronous FD non-blocking: %s", - strerror(err)); + rte_strerror(err)); goto port_error; } /* Allocate protection domain. */ @@ -1024,7 +1024,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) err = mlx4_get_mac(priv, &mac.addr_bytes); if (err) { ERROR("cannot get MAC address, is mlx4_en loaded?" - " (error: %s)", strerror(err)); + " (error: %s)", rte_strerror(err)); goto port_error; } INFO("port %u MAC address is " RTE_ETHER_ADDR_PRT_FMT, diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index f11c6b4373..d52d2f5511 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -373,7 +373,7 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle toggle) ERROR("cannot toggle %s mode (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", - mode, rte_errno, strerror(rte_errno), error.type, error.cause, + mode, rte_errno, rte_strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); return ret; } @@ -462,7 +462,7 @@ mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) ERROR("failed to synchronize flow rules after removing MAC address" " at index %d (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", - index, rte_errno, strerror(rte_errno), error.type, error.cause, + index, rte_errno, rte_strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); } @@ -501,7 +501,7 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, ERROR("failed to synchronize flow rules after adding MAC address" " at index %d (code %d, \"%s\")," " flow error type %d, cause %p, message: %s", - index, rte_errno, strerror(rte_errno), error.type, error.cause, + index, rte_errno, rte_strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); return ret; } @@ -558,7 +558,7 @@ mlx4_set_mc_addr_list(struct rte_eth_dev *dev, struct rte_ether_addr *list, return 0; ERROR("failed to synchronize flow rules after modifying MC list," " (code %d, \"%s\"), flow error type %d, cause %p, message: %s", - rte_errno, strerror(rte_errno), error.type, error.cause, + rte_errno, rte_strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); return ret; } @@ -600,7 +600,7 @@ mlx4_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) " (code %d, \"%s\"), " " flow error type %d, cause %p, message: %s", on ? "enabling" : "disabling", vlan_id, - rte_errno, strerror(rte_errno), error.type, error.cause, + rte_errno, rte_strerror(rte_errno), error.type, error.cause, error.message ? error.message : "(unspecified)"); return ret; } @@ -807,7 +807,7 @@ mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) } (void)wait_to_complete; if (mlx4_ifreq(priv, SIOCGIFFLAGS, &ifr)) { - WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(rte_errno)); + WARN("ioctl(SIOCGIFFLAGS) failed: %s", rte_strerror(rte_errno)); return -rte_errno; } memset(&dev_link, 0, sizeof(dev_link)); @@ -816,7 +816,7 @@ mlx4_link_update(struct rte_eth_dev *dev, int wait_to_complete) ifr.ifr_data = (void *)&edata; if (mlx4_ifreq(priv, SIOCETHTOOL, &ifr)) { WARN("ioctl(SIOCETHTOOL, ETHTOOL_GSET) failed: %s", - strerror(rte_errno)); + rte_strerror(rte_errno)); return -rte_errno; } link_speed = ethtool_cmd_speed(&edata); @@ -858,7 +858,7 @@ mlx4_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) ret = rte_errno; WARN("ioctl(SIOCETHTOOL, ETHTOOL_GPAUSEPARAM)" " failed: %s", - strerror(rte_errno)); + rte_strerror(rte_errno)); goto out; } fc_conf->autoneg = ethpause.autoneg; @@ -913,7 +913,7 @@ mlx4_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) ret = rte_errno; WARN("ioctl(SIOCETHTOOL, ETHTOOL_SPAUSEPARAM)" " failed: %s", - strerror(rte_errno)); + rte_strerror(rte_errno)); goto out; } ret = 0; diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c index 781ee256df..d0ec84201e 100644 --- a/drivers/net/mlx4/mlx4_rxq.c +++ b/drivers/net/mlx4/mlx4_rxq.c @@ -353,7 +353,7 @@ mlx4_rss_init(struct mlx4_priv *priv) if (ret) { ERROR("cannot set up range size for RSS context to %u" " (for %u Rx queues), error: %s", - 1 << log2_range, dev->data->nb_rx_queues, strerror(ret)); + 1 << log2_range, dev->data->nb_rx_queues, rte_strerror(ret)); rte_errno = ret; return -ret; } @@ -431,7 +431,7 @@ mlx4_rss_init(struct mlx4_priv *priv) return 0; error: ERROR("cannot initialize common RSS resources (queue %u): %s: %s", - i, msg, strerror(ret)); + i, msg, rte_strerror(ret)); while (i--) { struct rxq *rxq = ETH_DEV(priv)->data->rx_queues[i]; @@ -631,7 +631,7 @@ mlx4_rxq_attach(struct rxq *rxq) --rxq->usecnt; rte_errno = ret; ERROR("error while attaching Rx queue %p: %s: %s", - (void *)rxq, msg, strerror(ret)); + (void *)rxq, msg, rte_strerror(ret)); priv->verbs_alloc_ctx.type = MLX4_VERBS_ALLOC_TYPE_NONE; return -ret; } @@ -882,13 +882,13 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, rte_errno = ENOMEM; ERROR("%p: Rx interrupt completion channel creation" " failure: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } if (mlx4_fd_set_non_blocking(rxq->channel->fd) < 0) { ERROR("%p: unable to make Rx interrupt completion" " channel non-blocking: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } } diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index 0db2e55bef..f08c152d5e 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -411,7 +411,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (!txq->cq) { rte_errno = ENOMEM; ERROR("%p: CQ creation failure: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } qp_init_attr = (struct ibv_qp_init_attr){ @@ -431,7 +431,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (!txq->qp) { rte_errno = errno ? errno : EINVAL; ERROR("%p: QP creation failure: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } txq->max_inline = qp_init_attr.cap.max_inline_data; @@ -445,7 +445,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (ret) { rte_errno = ret; ERROR("%p: QP state to IBV_QPS_INIT failed: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } ret = mlx4_glue->modify_qp @@ -457,7 +457,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (ret) { rte_errno = ret; ERROR("%p: QP state to IBV_QPS_RTR failed: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } ret = mlx4_glue->modify_qp @@ -469,7 +469,7 @@ mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (ret) { rte_errno = ret; ERROR("%p: QP state to IBV_QPS_RTS failed: %s", - (void *)dev, strerror(rte_errno)); + (void *)dev, rte_strerror(rte_errno)); goto error; } /* Retrieve device queue information. */ -- 2.33.0