Before comparing the amount of bytes read to the size of a packet
struct, make sure the fd being read was actually the packet injection
pipe(2). Locked address interfaces force using the same copy-based
approach used for the internal dhcp service for "local" interfaces
but were accidentally being treated as reads from the pipe(2) and
not the tap.
This broke networking for any locked address interfaces in vmd(8).
Reported by and ok kn@
-/* $OpenBSD: vionet.c,v 1.11 2024/02/09 14:52:39 dv Exp $ */
+/* $OpenBSD: vionet.c,v 1.12 2024/02/10 02:19:12 dv Exp $ */
/*
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
/* If reading the tap(4), we should get valid ethernet. */
log_warnx("%s: invalid packet size", __func__);
return (0);
- } else if (sz != sizeof(struct packet)) {
- log_warnx("%s: invalid injected packet object", __func__);
+ } else if (fd == pipe_inject[READ] && sz != sizeof(struct packet)) {
+ log_warnx("%s: invalid injected packet object (sz=%ld)",
+ __func__, sz);
return (0);
}