PPP: close link protocol if LCP is not started in ppp_close

ppp_close might try to close LCP even if LCP is not started, it happens
because because the PPP session might be waiting for the link protocol
to come up and we do not check that.

We say in the PPP documentation that ppp_close() can be called anytime,
so, if link protocol is currently trying to connect, we must cancel
the link connection.

Fix it by calling the link protocol disconnect callback if LCP is not
started yet.
This commit is contained in:
Sylvain Rochet 2016-08-07 22:39:16 +02:00
parent 7c02a85424
commit 09c22e13fe

View File

@ -341,6 +341,12 @@ ppp_close(ppp_pcb *pcb, u8_t nocarrier)
return ERR_INPROGRESS; return ERR_INPROGRESS;
} }
/* LCP not open, close link protocol */
if (pcb->phase < PPP_PHASE_ESTABLISH) {
ppp_link_terminated(pcb);
return ERR_OK;
}
/* /*
* Only accept carrier lost signal on the stable running phase in order * Only accept carrier lost signal on the stable running phase in order
* to prevent changing the PPP phase FSM in transition phases. * to prevent changing the PPP phase FSM in transition phases.