-/* $OpenBSD: if_sec.c,v 1.2 2023/08/08 10:14:29 dlg Exp $ */
+/* $OpenBSD: if_sec.c,v 1.3 2023/08/08 10:19:15 dlg Exp $ */
/*
* Copyright (c) 2022 The University of Queensland
struct sec_softc {
struct ifnet sc_if;
+ unsigned int sc_dead;
unsigned int sc_up;
struct task sc_send;
struct sec_softc *sc = ifp->if_softc;
NET_LOCK();
+ sc->sc_dead = 1;
if (ISSET(ifp->if_flags, IFF_RUNNING))
sec_down(sc);
NET_UNLOCK();
NET_ASSERT_LOCKED();
KASSERT(!ISSET(ifp->if_flags, IFF_RUNNING));
+ if (sc->sc_dead)
+ return (ENXIO);
+
/*
* coordinate with sec_down(). if sc_up is still up and
* we're here then something else is running sec_down.