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>
This commit is contained in:
Vincenzo Maffione 2022-12-24 16:06:05 +00:00
parent 95fc11577d
commit eda8251188

View file

@ -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;