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 581F145BAE; Wed, 23 Oct 2024 10:31:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A6A7427E0; Wed, 23 Oct 2024 10:29:32 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id C41C340E3B for ; Wed, 23 Oct 2024 10:28:59 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XYMXj6Y1fz1HLJ5; Wed, 23 Oct 2024 16:24:37 +0800 (CST) Received: from dggpeml500011.china.huawei.com (unknown [7.185.36.84]) by mail.maildlp.com (Postfix) with ESMTPS id BDED71A016C; 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 31/42] net/memif: use rte strerror Date: Wed, 23 Oct 2024 16:28:41 +0800 Message-ID: <20241023082852.2780488-32-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/memif/memif_socket.c | 4 ++-- drivers/net/memif/rte_eth_memif.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c index 649f8d0e61..592b71979a 100644 --- a/drivers/net/memif/memif_socket.c +++ b/drivers/net/memif/memif_socket.c @@ -71,7 +71,7 @@ memif_msg_send_from_queue(struct memif_control_channel *cc) size = memif_msg_send(rte_intr_fd_get(cc->intr_handle), &e->msg, e->fd); if (size != sizeof(memif_msg_t)) { - MIF_LOG(ERR, "sendmsg fail: %s.", strerror(errno)); + MIF_LOG(ERR, "sendmsg fail: %s.", rte_strerror(errno)); ret = -1; } else { MIF_LOG(DEBUG, "Sent msg type %u.", e->msg.type); @@ -975,7 +975,7 @@ memif_socket_create(char *key, uint8_t listener, bool is_abstract, uid_t owner_u return sock; error: - MIF_LOG(ERR, "Failed to setup socket %s: %s", key, strerror(errno)); + MIF_LOG(ERR, "Failed to setup socket %s: %s", key, rte_strerror(errno)); if (sock != NULL) { rte_intr_instance_free(sock->intr_handle); rte_free(sock); diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c index cd722f254f..4b1d2010a2 100644 --- a/drivers/net/memif/rte_eth_memif.c +++ b/drivers/net/memif/rte_eth_memif.c @@ -807,7 +807,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) sizeof(a)); if (unlikely(size < 0)) { MIF_LOG(WARNING, - "Failed to send interrupt. %s", strerror(errno)); + "Failed to send interrupt. %s", rte_strerror(errno)); } } @@ -958,7 +958,7 @@ eth_memif_tx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) &a, sizeof(a)); if (unlikely(size < 0)) { MIF_LOG(WARNING, - "Failed to send interrupt. %s", strerror(errno)); + "Failed to send interrupt. %s", rte_strerror(errno)); } } @@ -1080,27 +1080,27 @@ memif_region_init_shm(struct rte_eth_dev *dev, uint8_t has_buffers) r->fd = memfd_create(shm_name, MFD_ALLOW_SEALING); if (r->fd < 0) { - MIF_LOG(ERR, "Failed to create shm file: %s.", strerror(errno)); + MIF_LOG(ERR, "Failed to create shm file: %s.", rte_strerror(errno)); ret = -1; goto error; } ret = fcntl(r->fd, F_ADD_SEALS, F_SEAL_SHRINK); if (ret < 0) { - MIF_LOG(ERR, "Failed to add seals to shm file: %s.", strerror(errno)); + MIF_LOG(ERR, "Failed to add seals to shm file: %s.", rte_strerror(errno)); goto error; } ret = ftruncate(r->fd, r->region_size); if (ret < 0) { - MIF_LOG(ERR, "Failed to truncate shm file: %s.", strerror(errno)); + MIF_LOG(ERR, "Failed to truncate shm file: %s.", rte_strerror(errno)); goto error; } r->addr = mmap(NULL, r->region_size, PROT_READ | PROT_WRITE, MAP_SHARED, r->fd, 0); if (r->addr == MAP_FAILED) { - MIF_LOG(ERR, "Failed to mmap shm region: %s.", strerror(ret)); + MIF_LOG(ERR, "Failed to mmap shm region: %s.", rte_strerror(ret)); ret = -1; goto error; } @@ -1221,7 +1221,7 @@ memif_init_queues(struct rte_eth_dev *dev) if (rte_intr_fd_get(mq->intr_handle) < 0) { MIF_LOG(WARNING, "Failed to create eventfd for tx queue %d: %s.", i, - strerror(errno)); + rte_strerror(errno)); } mq->buffers = NULL; if (pmd->flags & ETH_MEMIF_FLAG_ZERO_COPY) { @@ -1245,7 +1245,7 @@ memif_init_queues(struct rte_eth_dev *dev) if (rte_intr_fd_get(mq->intr_handle) < 0) { MIF_LOG(WARNING, "Failed to create eventfd for rx queue %d: %s.", i, - strerror(errno)); + rte_strerror(errno)); } mq->buffers = NULL; if (pmd->flags & ETH_MEMIF_FLAG_ZERO_COPY) { @@ -1301,7 +1301,7 @@ memif_connect(struct rte_eth_dev *dev) MAP_SHARED, mr->fd, 0); if (mr->addr == MAP_FAILED) { MIF_LOG(ERR, "mmap failed: %s", - strerror(errno)); + rte_strerror(errno)); return -1; } } @@ -1985,7 +1985,7 @@ rte_pmd_memif_probe(struct rte_vdev_device *vdev) */ if (ret < 0 && rte_errno != EEXIST) MIF_LOG(WARNING, "Failed to register mp action callback: %s", - strerror(rte_errno)); + rte_strerror(rte_errno)); /* use abstract address by default */ flags |= ETH_MEMIF_FLAG_SOCKET_ABSTRACT; -- 2.33.0