summaryrefslogtreecommitdiff
path: root/sys/dev/pv
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-09-26 08:30:14 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-09-26 08:30:14 +0000
commit56815de054768b125644b5553966b0bba4b071fa (patch)
tree5395aac805c3e63330b00891e0e2e0d0a55fab03 /sys/dev/pv
parent4735cca42b1617e29abffbf3b555d2ab88a5d793 (diff)
Use shared netlock to protect ifnet data within vmt_tclo_broadcastip().
Execute vmt_tclo_tick() timeout handler in process context to allow context switch within vmt_tclo_broadcastip(). ok yasuoka
Diffstat (limited to 'sys/dev/pv')
-rw-r--r--sys/dev/pv/vmt.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/pv/vmt.c b/sys/dev/pv/vmt.c
index 569b8600b03..824d8530dbd 100644
--- a/sys/dev/pv/vmt.c
+++ b/sys/dev/pv/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.30 2023/01/07 06:40:21 asou Exp $ */
+/* $OpenBSD: vmt.c,v 1.31 2023/09/26 08:30:13 mvs Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -471,7 +471,7 @@ vmt_attach(struct device *parent, struct device *self, void *aux)
config_mountroot(self, vmt_tick_hook);
- timeout_set(&sc->sc_tclo_tick, vmt_tclo_tick, sc);
+ timeout_set_proc(&sc->sc_tclo_tick, vmt_tclo_tick, sc);
timeout_add_sec(&sc->sc_tclo_tick, 1);
sc->sc_tclo_ping = 1;
@@ -899,9 +899,12 @@ vmt_tclo_broadcastip(struct vmt_softc *sc)
{
struct ifnet *iface;
struct sockaddr_in *guest_ip;
+ char ip[INET_ADDRSTRLEN];
/* find first available ipv4 address */
guest_ip = NULL;
+
+ NET_LOCK_SHARED();
TAILQ_FOREACH(iface, &ifnetlist, if_list) {
struct ifaddr *iface_addr;
@@ -918,14 +921,14 @@ vmt_tclo_broadcastip(struct vmt_softc *sc)
continue;
guest_ip = satosin(iface_addr->ifa_addr);
+ inet_ntop(AF_INET, &guest_ip->sin_addr, ip,
+ sizeof(ip));
break;
}
}
+ NET_UNLOCK_SHARED();
if (guest_ip != NULL) {
- char ip[INET_ADDRSTRLEN];
-
- inet_ntop(AF_INET, &guest_ip->sin_addr, ip, sizeof(ip));
if (vm_rpc_send_rpci_tx(sc, "info-set guestinfo.ip %s",
ip) != 0) {
DPRINTF("%s: unable to send guest IP address\n",