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 476CDA00BE; Wed, 16 Feb 2022 15:14:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E9CD4115E; Wed, 16 Feb 2022 15:13:59 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id D5142410FB for ; Wed, 16 Feb 2022 15:13:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645020838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ATrUZvVqFuELSlKDLvxYrfcx4ozf95YNAi66nA95GHc=; b=ZzNlk2QZmfER86pSksT9DLNzEm6KRASjq/xLWtPZ9nuV9LYv8mUY4fIGmHB3/f+akzO47V /6dlwAZOQIgzY+FB8xMMzVxoXdoufehibH1exEaWDxkOLnx8Kt0cXDwudf/hzn/lxOWdjz MSciwrZR+vT260pzx+s+0aaNzDCl6gk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-kg5rP1IwPRGnR3lDQM29tA-1; Wed, 16 Feb 2022 09:13:55 -0500 X-MC-Unique: kg5rP1IwPRGnR3lDQM29tA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8F022F45; Wed, 16 Feb 2022 14:13:53 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.194.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id DADC2703A2; Wed, 16 Feb 2022 14:13:45 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Christophe Fontaine , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Gowrishankar Muthukrishnan Subject: [PATCH] ethdev: fix MAC address in telemetry device info Date: Wed, 16 Feb 2022 15:13:16 +0100 Message-Id: <20220216141316.19127-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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 right size for a human readable mac is RTE_ETHER_ADDR_FMT_SIZE. While at it, the net library provides a helper for mac address formatting. Prefer it. Fixes: 58b43c1ddfd1 ("ethdev: add telemetry endpoint for device info") Cc: stable@dpdk.org Reported-by: Christophe Fontaine Signed-off-by: David Marchand --- lib/ethdev/rte_ethdev.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 70c850a2f1..29a3d80466 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -5631,7 +5631,7 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, struct rte_tel_data *d) { struct rte_tel_data *rxq_state, *txq_state; - char mac_addr[RTE_ETHER_ADDR_LEN]; + char mac_addr[RTE_ETHER_ADDR_FMT_SIZE]; struct rte_eth_dev *eth_dev; char *end_param; int port_id, i; @@ -5672,13 +5672,8 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, eth_dev->data->min_rx_buf_size); rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail", eth_dev->data->rx_mbuf_alloc_failed); - snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", - eth_dev->data->mac_addrs->addr_bytes[0], - eth_dev->data->mac_addrs->addr_bytes[1], - eth_dev->data->mac_addrs->addr_bytes[2], - eth_dev->data->mac_addrs->addr_bytes[3], - eth_dev->data->mac_addrs->addr_bytes[4], - eth_dev->data->mac_addrs->addr_bytes[5]); + rte_ether_format_addr(mac_addr, sizeof(mac_addr), + eth_dev->data->mac_addrs); rte_tel_data_add_dict_string(d, "mac_addr", mac_addr); rte_tel_data_add_dict_int(d, "promiscuous", eth_dev->data->promiscuous); -- 2.23.0