From 0baf796a9188a51c80f314f0bf5f04dc12259a9d Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Mon, 2 Jan 2017 08:42:53 +0000 Subject: pppoe_timeout() needs to take the NET_LOCK(). Assert reported and diff tested by semarie@ --- sys/net/if_pppoe.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sys/net/if_pppoe.c') diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c index 440b8555ccf..28b0c8a8400 100644 --- a/sys/net/if_pppoe.c +++ b/sys/net/if_pppoe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppoe.c,v 1.57 2016/06/14 20:44:43 sthen Exp $ */ +/* $OpenBSD: if_pppoe.c,v 1.58 2017/01/02 08:42:52 mpi Exp $ */ /* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */ /* @@ -223,7 +223,7 @@ pppoe_clone_create(struct if_clone *ifc, int unit) memcpy(&sc->sc_dest, etherbroadcastaddr, sizeof(sc->sc_dest)); /* init timer for interface watchdog */ - timeout_set(&sc->sc_timeout, pppoe_timeout, sc); + timeout_set_proc(&sc->sc_timeout, pppoe_timeout, sc); if_attach(&sc->sc_sppp.pp_if); if_alloc_sadl(&sc->sc_sppp.pp_if); @@ -1056,10 +1056,12 @@ static void pppoe_timeout(void *arg) { struct pppoe_softc *sc = (struct pppoe_softc *)arg; - int x, retry_wait, err; + int s, x, retry_wait, err; PPPOEDEBUG(("%s: timeout\n", sc->sc_sppp.pp_if.if_xname)); + NET_LOCK(s); + switch (sc->sc_state) { case PPPOE_STATE_PADI_SENT: /* @@ -1084,7 +1086,7 @@ pppoe_timeout(void *arg) } else { pppoe_abort_connect(sc); splx(x); - return; + break; } } if ((err = pppoe_send_padi(sc)) != 0) { @@ -1111,7 +1113,7 @@ pppoe_timeout(void *arg) timeout_add(&sc->sc_timeout, PPPOE_DISC_TIMEOUT * (1 + sc->sc_padi_retried)); splx(x); - return; + break; } if ((err = pppoe_send_padr(sc)) != 0) { sc->sc_padr_retried--; @@ -1127,8 +1129,10 @@ pppoe_timeout(void *arg) pppoe_disconnect(sc); break; default: - return; /* all done, work in peace */ + break; /* all done, work in peace */ } + + NET_UNLOCK(s); } /* Start a connection (i.e. initiate discovery phase). */ -- cgit v1.2.3