veth: use ethtool_sprintf instead of snprintf

use ethtools api ethtool_sprintf to instead of snprintf.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Link: https://lore.kernel.org/r/20211125025444.13115-1-xiangxia.m.yue@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Tonghao Zhang 2021-11-25 10:54:44 +08:00 committed by Jakub Kicinski
parent cc0a75eb03
commit a0341b73d8
1 changed files with 10 additions and 17 deletions

View File

@ -134,29 +134,22 @@ static void veth_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *inf
static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{
char *p = (char *)buf;
u8 *p = buf;
int i, j;
switch(stringset) {
case ETH_SS_STATS:
memcpy(p, &ethtool_stats_keys, sizeof(ethtool_stats_keys));
p += sizeof(ethtool_stats_keys);
for (i = 0; i < dev->real_num_rx_queues; i++) {
for (j = 0; j < VETH_RQ_STATS_LEN; j++) {
snprintf(p, ETH_GSTRING_LEN,
"rx_queue_%u_%.18s",
i, veth_rq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
}
for (i = 0; i < dev->real_num_tx_queues; i++) {
for (j = 0; j < VETH_TQ_STATS_LEN; j++) {
snprintf(p, ETH_GSTRING_LEN,
"tx_queue_%u_%.18s",
i, veth_tq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
}
for (i = 0; i < dev->real_num_rx_queues; i++)
for (j = 0; j < VETH_RQ_STATS_LEN; j++)
ethtool_sprintf(&p, "rx_queue_%u_%.18s",
i, veth_rq_stats_desc[j].desc);
for (i = 0; i < dev->real_num_tx_queues; i++)
for (j = 0; j < VETH_TQ_STATS_LEN; j++)
ethtool_sprintf(&p, "tx_queue_%u_%.18s",
i, veth_tq_stats_desc[j].desc);
break;
}
}