DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] ethdev: fix MAC address in telemetry device info
@ 2022-02-16 14:13 David Marchand
  2022-02-16 16:33 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: David Marchand @ 2022-02-16 14:13 UTC (permalink / raw)
  To: dev
  Cc: stable, Christophe Fontaine, Thomas Monjalon, Ferruh Yigit,
	Andrew Rybchenko, Gowrishankar Muthukrishnan

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 <cfontain@redhat.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ethdev: fix MAC address in telemetry device info
  2022-02-16 14:13 [PATCH] ethdev: fix MAC address in telemetry device info David Marchand
@ 2022-02-16 16:33 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2022-02-16 16:33 UTC (permalink / raw)
  To: David Marchand, dev
  Cc: stable, Christophe Fontaine, Thomas Monjalon, Andrew Rybchenko,
	Gowrishankar Muthukrishnan

On 2/16/2022 2:13 PM, David Marchand wrote:
> 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<cfontain@redhat.com>
> Signed-off-by: David Marchand<david.marchand@redhat.com>
> 

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-16 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 14:13 [PATCH] ethdev: fix MAC address in telemetry device info David Marchand
2022-02-16 16:33 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).