PPP, MPPE, issue CCP reset request if synchronization is lost

If MPPE synchronization is lost, it is advised to send a CCP reset
request in order to recover to a clean state.
This commit is contained in:
Sylvain Rochet 2015-04-26 22:04:21 +02:00
parent adaeff5540
commit 8fe2f747f4
3 changed files with 34 additions and 6 deletions

View File

@ -150,5 +150,7 @@ typedef struct ccp_options {
extern const struct protent ccp_protent; extern const struct protent ccp_protent;
void ccp_resetrequest(ppp_pcb *pcb); /* Issue a reset-request. */
#endif /* CCP_H */ #endif /* CCP_H */
#endif /* PPP_SUPPORT && CCP_SUPPORT */ #endif /* PPP_SUPPORT && CCP_SUPPORT */

View File

@ -411,7 +411,7 @@ static void ccp_init(ppp_pcb *pcb) {
(pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40)
| (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128);
} }
#endif #endif /* MPPE_SUPPORT */
} }
/* /*
@ -1701,6 +1701,29 @@ static void ccp_datainput(ppp_pcb *pcb, u_char *pkt, int len) {
} }
#endif /* PPP_DATAINPUT */ #endif /* PPP_DATAINPUT */
/*
* We have received a packet that the decompressor failed to
* decompress. Issue a reset-request.
*/
void ccp_resetrequest(ppp_pcb *pcb) {
fsm *f = &pcb->ccp_fsm;
if (f->state != PPP_FSM_OPENED)
return;
/*
* Send a reset-request to reset the peer's compressor.
* We don't do that if we are still waiting for an
* acknowledgement to a previous reset-request.
*/
if (!(pcb->ccp_localstate & RACK_PENDING)) {
fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0);
TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT);
pcb->ccp_localstate |= RACK_PENDING;
} else
pcb->ccp_localstate |= RREQ_REPEAT;
}
/* /*
* Timeout waiting for reset-ack. * Timeout waiting for reset-ack.
*/ */

View File

@ -273,7 +273,8 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
PPPDEBUG(LOG_DEBUG, PPPDEBUG(LOG_DEBUG,
("mppe_decompress[%d]: short pkt (%d)\n", ("mppe_decompress[%d]: short pkt (%d)\n",
pcb->netif->num, n0->len)); pcb->netif->num, n0->len));
return ERR_BUF; state->sanity_errors += 100;
goto sanity_error;
} }
pl = (u8_t*)n0->payload; pl = (u8_t*)n0->payload;
@ -381,16 +382,18 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb)
return ERR_OK; return ERR_OK;
sanity_error: sanity_error:
if (state->sanity_errors < SANITY_MAX) if (state->sanity_errors < SANITY_MAX) {
return ERR_BUF; /* Signal the peer to rekey (by sending a CCP Reset-Request). */
else ccp_resetrequest(pcb);
} else {
/* /*
* Take LCP down if the peer is sending too many bogons. * Take LCP down if the peer is sending too many bogons.
* We don't want to do this for a single or just a few * We don't want to do this for a single or just a few
* instances since it could just be due to packet corruption. * instances since it could just be due to packet corruption.
*/ */
lcp_close(pcb, "Too many MPPE errors"); lcp_close(pcb, "Too many MPPE errors");
return ERR_BUF; }
return ERR_BUF;
} }
#endif /* PPP_SUPPORT && MPPE_SUPPORT */ #endif /* PPP_SUPPORT && MPPE_SUPPORT */