git: 7a1e0af7d0df - stable/12 - netmap: pkt-gen: fix ifname before cmp in source_hwaddr
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 Dec 2022 12:29:20 UTC
The branch stable/12 has been updated by vmaffione:
URL: https://cgit.FreeBSD.org/src/commit/?id=7a1e0af7d0df51e7a45beb890e5053192d1dc33e
commit 7a1e0af7d0df51e7a45beb890e5053192d1dc33e
Author: Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2022-12-24 16:06:05 +0000
Commit: Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2022-12-31 12:14:49 +0000
netmap: pkt-gen: fix ifname before cmp in source_hwaddr
In source_hwaddr(), the configured ifname is compared against all
interfaces. However, in main(), the string 'netmap:' is prepended to the
interface string if no explicit type is given. Therefore the ifname will
not match any system interface and the source MAC address is always
empty.
Check for the leading 'netmap:' string and skip past it to match against
system interfaces. Note that 'tap:' and 'pcap:' devices strip the type
string from the ifname in main() so no further work is needed.
MFC after: 7 days
Submitted by: Brian Poole <brian90013@gmail.com>
(cherry picked from commit eda82511883f540cd18f8afd2268636c7db97685)
---
tools/tools/netmap/pkt-gen.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c
index 4518c2fd4219..3ecdbd2c3cc4 100644
--- a/tools/tools/netmap/pkt-gen.c
+++ b/tools/tools/netmap/pkt-gen.c
@@ -684,6 +684,10 @@ source_hwaddr(const char *ifname, char *buf)
return (-1);
}
+ /* remove 'netmap:' prefix before comparing interfaces */
+ if (!strncmp(ifname, "netmap:", 7))
+ ifname = &ifname[7];
+
for (ifap = ifaphead; ifap; ifap = ifap->ifa_next) {
struct sockaddr_dl *sdl =
(struct sockaddr_dl *)ifap->ifa_addr;