git: 01e19f7b8620 - stable/13 - 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:04:18 UTC
The branch stable/13 has been updated by vmaffione:
URL: https://cgit.FreeBSD.org/src/commit/?id=01e19f7b86209cf8017e09392abed7cdde867354
commit 01e19f7b86209cf8017e09392abed7cdde867354
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:04:03 +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;