PPP, PPPoS: wait for next packet when we drop a packet before it is complete

If we fail to receive a full packet, for exemple if a memory allocation
fail for some reason, we currently do not wait for next packet flag
character and we start filling a new packet at next received byte. Then
we expect the checksum check to discard the packet.

The behavior seem to have been broken one or two decades ago when adding
support for PFC (Protocol-Field-Compression) and ACFC
(Address-and-Control-Field-Compression).

Rework to drop any character until we receive a flag character at init
and when we drop a packet before it is complete.
This commit is contained in:
Sylvain Rochet 2020-10-17 19:51:45 +02:00
parent 88ac7460f0
commit 3779cf7856
2 changed files with 3 additions and 13 deletions

View File

@ -50,7 +50,6 @@ extern "C" {
* completed. */
enum {
PDIDLE = 0, /* Idle state - waiting. */
PDSTART, /* Process start flag. */
PDADDRESS, /* Process address field. */
PDCONTROL, /* Process control field. */
PDPROTOCOL1, /* Process protocol field 1. */

View File

@ -593,17 +593,8 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
/* Process character relative to current state. */
switch (pppos->in_state) {
case PDIDLE: /* Idle state - waiting. */
/* Drop the character if it's not 0xff
* we would have processed a flag character above. */
if (cur_char != PPP_ALLSTATIONS) {
break;
}
/* Fall through */
case PDSTART: /* Process start flag. */
/* Prepare for a new packet. */
pppos->in_fcs = PPP_INITFCS;
/* Fall through */
case PDIDLE: /* Idle state - wait for flag character. */
break;
case PDADDRESS: /* Process address field. */
if (cur_char == PPP_ALLSTATIONS) {
pppos->in_state = PDCONTROL;
@ -664,7 +655,7 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l)
PPPDEBUG(LOG_ERR, ("pppos_input[%d]: NO FREE PBUFS!\n", ppp->netif->num));
LINK_STATS_INC(link.memerr);
pppos_input_drop(pppos);
pppos->in_state = PDSTART; /* Wait for flag sequence. */
pppos->in_state = PDIDLE; /* Wait for flag character. */
break;
}
if (pppos->in_head == NULL) {