-/* $OpenBSD: if_pppx.c,v 1.111 2021/07/20 16:44:55 mvs Exp $ */
+/* $OpenBSD: if_pppx.c,v 1.112 2021/12/30 00:49:41 mvs Exp $ */
/*
* Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org>
struct pppac_softc {
struct ifnet sc_if;
dev_t sc_dev; /* [I] */
+ int sc_ready; /* [K] */
LIST_ENTRY(pppac_softc)
sc_entry; /* [K] */
struct pppac_softc *sc;
LIST_FOREACH(sc, &pppac_devs, sc_entry) {
- if (sc->sc_dev == dev)
+ if (sc->sc_dev == dev) {
+ if (sc->sc_ready == 0)
+ break;
+
return (sc);
+ }
}
return (NULL);
struct pipex_session *session;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
- if (pppac_lookup(dev) != NULL) {
- free(sc, M_DEVBUF, sizeof(*sc));
- return (EBUSY);
+ LIST_FOREACH(sc, &pppac_devs, sc_entry) {
+ if (sc->sc_dev == dev) {
+ free(sc, M_DEVBUF, sizeof(*sc));
+ return (EBUSY);
+ }
}
+ LIST_INSERT_HEAD(&pppac_devs, sc, sc_entry);
/* virtual pipex_session entry for multicast */
session = pool_get(&pipex_session_pool, PR_WAITOK | PR_ZERO);
mtx_init(&sc->sc_wsel_mtx, IPL_SOFTNET);
mq_init(&sc->sc_mq, IFQ_MAXLEN, IPL_SOFTNET);
- LIST_INSERT_HEAD(&pppac_devs, sc, sc_entry);
-
ifp = &sc->sc_if;
snprintf(ifp->if_xname, sizeof(ifp->if_xname), "pppac%u", minor(dev));
bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(uint32_t));
#endif
+ sc->sc_ready = 1;
+
return (0);
}
struct ifnet *ifp = &sc->sc_if;
int s;
+ sc->sc_ready = 0;
+
NET_LOCK();
CLR(ifp->if_flags, IFF_RUNNING);
NET_UNLOCK();