From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 1/4] net/tap: replace rte_memcpy
Date: Mon, 28 Oct 2024 09:32:09 -0700 [thread overview]
Message-ID: <20241028163324.193338-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20241028163324.193338-1-stephen@networkplumber.org>
There is no point in using rte_memcpy to copy Ethernet addresses.
Use rte_ether_addr_copy() instead.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/tap/rte_eth_tap.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 36b06b3ac5..da45610665 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -15,7 +15,6 @@
#include <rte_net.h>
#include <rte_debug.h>
#include <rte_ip.h>
-#include <rte_string_fns.h>
#include <rte_ethdev.h>
#include <rte_errno.h>
#include <rte_cycles.h>
@@ -1395,11 +1394,13 @@ tap_mac_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
mac_addr))
mode = LOCAL_AND_REMOTE;
ifr.ifr_hwaddr.sa_family = AF_LOCAL;
- rte_memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, RTE_ETHER_ADDR_LEN);
+
+ rte_ether_addr_copy(mac_addr, (struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data);
ret = tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 1, mode);
if (ret < 0)
return ret;
- rte_memcpy(&pmd->eth_addr, mac_addr, RTE_ETHER_ADDR_LEN);
+
+ rte_ether_addr_copy(mac_addr, &pmd->eth_addr);
#ifdef HAVE_TCA_FLOWER
if (pmd->remote_if_index && !pmd->flow_isolate) {
@@ -1987,7 +1988,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
if (rte_is_zero_ether_addr(mac_addr))
rte_eth_random_addr((uint8_t *)&pmd->eth_addr);
else
- rte_memcpy(&pmd->eth_addr, mac_addr, sizeof(*mac_addr));
+ rte_ether_addr_copy(mac_addr, &pmd->eth_addr);
}
/*
@@ -2010,8 +2011,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
if (pmd->type == ETH_TUNTAP_TYPE_TAP) {
memset(&ifr, 0, sizeof(struct ifreq));
ifr.ifr_hwaddr.sa_family = AF_LOCAL;
- rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
- RTE_ETHER_ADDR_LEN);
+ rte_ether_addr_copy(&pmd->eth_addr, (struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data);
if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0)
goto error_exit;
}
@@ -2070,8 +2070,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
pmd->name, pmd->remote_iface);
goto error_remote;
}
- rte_memcpy(&pmd->eth_addr, ifr.ifr_hwaddr.sa_data,
- RTE_ETHER_ADDR_LEN);
+
+ rte_ether_addr_copy((struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data, &pmd->eth_addr);
/* The desired MAC is already in ifreq after SIOCGIFHWADDR. */
if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0) {
TAP_LOG(ERR, "%s: failed to get %s MAC address.",
--
2.45.2
next prev parent reply other threads:[~2024-10-28 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 16:32 [PATCH 0/4] net/tap: minor cleanups Stephen Hemminger
2024-10-28 16:32 ` Stephen Hemminger [this message]
2024-10-28 16:32 ` [PATCH 2/4] net/tap: rename struct nlmsg to tap_nlmsg Stephen Hemminger
2024-10-28 16:32 ` [PATCH 3/4] net/tap: do not use opaque parameter in convert Stephen Hemminger
2024-10-28 16:32 ` [PATCH 4/4] net/tap: do not use rte_malloc for process private data Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028163324.193338-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).