From: dv Date: Sat, 10 Feb 2024 02:19:12 +0000 (+0000) Subject: Fix locked address interfaces in vmd(8). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b72f07428389f2276d16326d2c6ca814cfcee081;p=openbsd 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@ --- 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 @@ -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); }