From 9d087ad2d25f0aae73c2ba77fb77d6865bab44e8 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sat, 3 Feb 2018 22:13:32 +0100 Subject: [PATCH] Add LWIP_ASSERT_CORE_LOCKED() to ppp (see task #14780) Signed-off-by: goldsimon --- src/netif/ppp/ppp.c | 7 +++++++ src/netif/ppp/pppoe.c | 1 + src/netif/ppp/pppos.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 66470bc4..5a1fb7b5 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -216,6 +216,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc /***********************************/ #if PPP_AUTH_SUPPORT void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) { + LWIP_ASSERT_CORE_LOCKED(); #if PAP_SUPPORT pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP); #endif /* PAP_SUPPORT */ @@ -268,6 +269,7 @@ void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_p * established before calling this. */ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) { + LWIP_ASSERT_CORE_LOCKED(); if (pcb->phase != PPP_PHASE_DEAD) { return ERR_ALREADY; } @@ -294,6 +296,7 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) { * established before calling this. */ err_t ppp_listen(ppp_pcb *pcb) { + LWIP_ASSERT_CORE_LOCKED(); if (pcb->phase != PPP_PHASE_DEAD) { return ERR_ALREADY; } @@ -323,6 +326,8 @@ err_t ppp_listen(ppp_pcb *pcb) { err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier) { + LWIP_ASSERT_CORE_LOCKED(); + pcb->err_code = PPPERR_USER; /* holdoff phase, cancel the reconnection */ @@ -383,6 +388,7 @@ ppp_close(ppp_pcb *pcb, u8_t nocarrier) */ err_t ppp_free(ppp_pcb *pcb) { err_t err; + LWIP_ASSERT_CORE_LOCKED(); if (pcb->phase != PPP_PHASE_DEAD) { return ERR_CONN; } @@ -402,6 +408,7 @@ err_t ppp_free(ppp_pcb *pcb) { err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg) { + LWIP_ASSERT_CORE_LOCKED(); if (pcb == NULL) { return ERR_VAL; } diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index 05d4b355..670b5780 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -177,6 +177,7 @@ ppp_pcb *pppoe_create(struct netif *pppif, struct pppoe_softc *sc; LWIP_UNUSED_ARG(service_name); LWIP_UNUSED_ARG(concentrator_name); + LWIP_ASSERT_CORE_LOCKED(); sc = (struct pppoe_softc *)LWIP_MEMPOOL_ALLOC(PPPOE_IF); if (sc == NULL) { diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index e4f73028..83ccb031 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -176,6 +176,7 @@ ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, { pppos_pcb *pppos; ppp_pcb *ppp; + LWIP_ASSERT_CORE_LOCKED(); pppos = (pppos_pcb *)LWIP_MEMPOOL_ALLOC(PPPOS_PCB); if (pppos == NULL) { @@ -407,6 +408,8 @@ pppos_destroy(ppp_pcb *ppp, void *ctx) #if !NO_SYS && !PPP_INPROC_IRQ_SAFE /** Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. + * + * This is one of the only functions that may be called outside of the TCPIP thread! * * @param ppp PPP descriptor index, returned by pppos_create() * @param s received data @@ -435,6 +438,7 @@ pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l) err_t pppos_input_sys(struct pbuf *p, struct netif *inp) { ppp_pcb *ppp = (ppp_pcb*)inp->state; struct pbuf *n; + LWIP_ASSERT_CORE_LOCKED(); for (n = p; n; n = n->next) { pppos_input(ppp, (u8_t*)n->payload, n->len); @@ -474,6 +478,9 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) u8_t cur_char; u8_t escaped; PPPOS_DECL_PROTECT(lev); +#if PPP_INPROC_IRQ_SAFE + LWIP_ASSERT_CORE_LOCKED(); +#endif PPPDEBUG(LOG_DEBUG, ("pppos_input[%d]: got %d bytes\n", ppp->netif->num, l)); while (l-- > 0) {