[PATCH v2 1/9] net/pcap: avoid using rte_malloc and rte_memcpy

Stephen Hemminger
2026-01-09T01:18:08Z

No need to use rte_malloc or rte_memcpy in the short
code to get MAC address.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/pcap/pcap_osdep_freebsd.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/pcap/pcap_osdep_freebsd.c b/drivers/net/pcap/pcap_osdep_freebsd.c
index 20556b3e92..32e4a2bee7 100644
--- a/drivers/net/pcap/pcap_osdep_freebsd.c
+++ b/drivers/net/pcap/pcap_osdep_freebsd.c
@@ -8,9 +8,6 @@
#include <net/if_dl.h>
#include <sys/sysctl.h>

-#include <rte_malloc.h>
-#include <rte_memcpy.h>
-
#include "pcap_osdep.h"

int
@@ -41,19 +38,19 @@ osdep_iface_mac_get(const char *if_name, struct rte_ether_addr *mac)
if (len == 0)
return -1;

- buf = rte_malloc(NULL, len, 0);
+ buf = malloc(len);
if (!buf)
return -1;

if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
- rte_free(buf);
+ free(buf);
return -1;
}
ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);

- rte_memcpy(mac->addr_bytes, LLADDR(sdl), RTE_ETHER_ADDR_LEN);
+ memcpy(mac->addr_bytes, LLADDR(sdl), RTE_ETHER_ADDR_LEN);

- rte_free(buf);
+ free(buf);
return 0;
}
--
2.51.0