From 3779cf78560f8d4311438f8b38dad00baf8e35d9 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 17 Oct 2020 19:51:45 +0200 Subject: [PATCH] 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. --- src/include/netif/ppp/pppos.h | 1 - src/netif/ppp/pppos.c | 15 +++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index 380a965c..31abfa17 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -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. */ diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index afa65bae..c4a0bd09 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -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) {