summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vionet.c
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2024-02-10 02:19:13 +0000
committerDave Voutila <dv@cvs.openbsd.org>2024-02-10 02:19:13 +0000
commit467bbb63187dc1c48a3c2526c6791003169776a4 (patch)
tree4c76bccc329f62a1e8c1bf6f91f06d3aa40d3aa1 /usr.sbin/vmd/vionet.c
parenta28741cca9672b7cf9512b8da0f15270e70dcc7a (diff)
Fix locked address interfaces in vmd(8).
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@
Diffstat (limited to 'usr.sbin/vmd/vionet.c')
-rw-r--r--usr.sbin/vmd/vionet.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/vmd/vionet.c b/usr.sbin/vmd/vionet.c
index 6f4b741bd1f..0de50784bb2 100644
--- a/usr.sbin/vmd/vionet.c
+++ b/usr.sbin/vmd/vionet.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -514,8 +514,9 @@ vionet_rx_copy(struct vionet_dev *dev, int fd, const struct iovec *iov,
/* 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);
}