PPP, PPPoE: add support for disconnecting in link initiation state in disconnect callback

Disconnect callback does not currently support a disconnect event while
initiation is in progress. Retry timer is not stopped and PADT frame is
sent whatever the current state is. PADT frame can only be sent if we
received a PADS frame, otherwise sc_session is 0 and sending a PADT
frame is meaningless.

Fix both issues to allow calling the disconnect callback whatever the
PPPoE state is.
This commit is contained in:
Sylvain Rochet 2016-08-07 22:35:31 +02:00
parent d15ebc6a4c
commit 7c02a85424

View File

@ -952,7 +952,12 @@ pppoe_disconnect(ppp_pcb *ppp, void *ctx)
struct pppoe_softc *sc = (struct pppoe_softc *)ctx;
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
if (sc->sc_state == PPPOE_STATE_SESSION) {
pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
}
/* stop any timer, disconnect can be called while initiating is in progress */
sys_untimeout(pppoe_timeout, sc);
/* cleanup softc */
sc->sc_state = PPPOE_STATE_INITIAL;