PPP, PPPoS: drop in flight packets from the tcpip mailbox if PPP session is down

A previous call to ppp_input might have disconnected the session while
there were still packets in flight in the tcpip mailbox. Drop incoming
packets because ppp_input must never be called if the upper layer is
down.
This commit is contained in:
Sylvain Rochet 2020-10-22 22:52:10 +02:00
parent a9f19cd7f1
commit a494b990da
2 changed files with 14 additions and 1 deletions

View File

@ -781,6 +781,8 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
#if PPP_DEBUG && PPP_PROTOCOLNAME
const char *pname;
#endif /* PPP_DEBUG && PPP_PROTOCOLNAME */
LWIP_ASSERT("pcb->phase >= PPP_PHASE_ESTABLISH && pcb->phase <= PPP_PHASE_TERMINATE",
pcb->phase >= PPP_PHASE_ESTABLISH && pcb->phase <= PPP_PHASE_TERMINATE);
magic_randomize();

View File

@ -744,6 +744,7 @@ pppos_input(ppp_pcb *ppp, const void *s, int l)
static void pppos_input_callback(void *arg) {
struct pbuf *pb = (struct pbuf*)arg;
ppp_pcb *ppp;
pppos_pcb *pppos;
ppp = ((struct pppos_input_header*)pb->payload)->ppp;
if(pbuf_remove_header(pb, sizeof(struct pppos_input_header))) {
@ -751,6 +752,16 @@ static void pppos_input_callback(void *arg) {
goto drop;
}
/* A previous call to ppp_input might have disconnected the session
* while there were still packets in flight in the tcpip mailbox.
* Drop incoming packets because ppp_input must never be called if
* the upper layer is down.
*/
pppos = (pppos_pcb *)ppp->link_ctx_cb;
if (!pppos->open) {
goto drop;
}
/* Dispatch the packet thereby consuming it. */
ppp_input(ppp, pb);
return;