From d28bb04a9cab629e18232f960c6fe5afd35d40bf Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Mon, 2 Mar 2015 00:16:25 +0100 Subject: [PATCH] PPP, PPPoE, improve reliability if we receive a PADT Don't disconnect when we receive a PADT, we let the LCP Echo/Reply find the fact that PPP session is down. Asking the PPP stack to end the session require strict checking about the PPP phase to prevent endless disconnection loops. Luckily it previously does nothing because PADT frames are rarely sent with a hunique tag and we only set the sc pointer if we receive a hunique tag. --- src/netif/ppp/pppoe.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index e3a6e442..fbcd1c6b 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -121,7 +121,9 @@ static err_t pppoe_destroy(ppp_pcb *ppp, void *ctx); /* management routines */ static void pppoe_abort_connect(struct pppoe_softc *); +#if 0 /* UNUSED */ static void pppoe_clear_softc(struct pppoe_softc *, const char *); +#endif /* UNUSED */ /* internal timeout handling */ static void pppoe_timeout(void *); @@ -634,10 +636,17 @@ breakbreak:; ppp_start(sc->pcb); /* notify upper layers */ break; case PPPOE_CODE_PADT: - if (sc == NULL) { + /* Don't disconnect here, we let the LCP Echo/Reply find the fact + * that PPP session is down. Asking the PPP stack to end the session + * require strict checking about the PPP phase to prevent endless + * disconnection loops. + */ +#if 0 /* UNUSED */ + if (sc == NULL) { /* PADT frames are rarely sent with a hunique tag, this is actually almost always true */ goto done; } pppoe_clear_softc(sc, "received PADT"); +#endif /* UNUSED */ break; default: if(sc) { @@ -1238,6 +1247,7 @@ pppoe_ifattach_hook(void *arg, struct pbuf **mp, struct netif *ifp, int dir) } #endif +#if 0 /* UNUSED */ static void pppoe_clear_softc(struct pppoe_softc *sc, const char *message) { @@ -1250,7 +1260,7 @@ pppoe_clear_softc(struct pppoe_softc *sc, const char *message) sc->sc_state = PPPOE_STATE_INITIAL; /* notify upper layers */ - ppp_link_end(sc->pcb); + ppp_link_end(sc->pcb); /* /!\ dangerous /!\ */ /* clean up softc */ MEMCPY(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest)); @@ -1259,4 +1269,5 @@ pppoe_clear_softc(struct pppoe_softc *sc, const char *message) sc->sc_padi_retried = 0; sc->sc_padr_retried = 0; } +#endif /* UNUSED */ #endif /* PPP_SUPPORT && PPPOE_SUPPORT */