This makes ifnet protection consistent. Execute vmt_tclo_tick() timeout
handler in process context to allow context switch within
vmt_tclo_broadcastip().

Index: sys/dev/pv/vmt.c
===================================================================
RCS file: /cvs/src/sys/dev/pv/vmt.c,v
retrieving revision 1.30
diff -u -p -r1.30 vmt.c
--- sys/dev/pv/vmt.c    7 Jan 2023 06:40:21 -0000       1.30
+++ sys/dev/pv/vmt.c    23 Sep 2023 12:15:27 -0000
@@ -471,7 +471,7 @@ vmt_attach(struct device *parent, struct
 
        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 *s
 {
        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 *s
                                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",

Reply via email to