PPP: CCP: don't drop output packets if CCP negotiated that we don't compress on our side

CCP might negotiate to not compress if peers cannot agree on a
compressor, therefore if the null compressor is chosen we must pass
packets as is instead of dropping them.

Reported-by: Stephan Linz <linz@li-pro.net>
Fixes: 987f6237c4 "PPP, MPPE, drop input/output packets if we couldn't find the chosen decompressor/compressor"
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
This commit is contained in:
Sylvain Rochet 2016-01-19 23:51:47 +01:00
parent 2c31beb6e7
commit 6185bf6f61
2 changed files with 21 additions and 29 deletions

View File

@ -350,8 +350,6 @@ struct ppp_pcb_s {
#endif /* VJ_SUPPORT */ #endif /* VJ_SUPPORT */
#if CCP_SUPPORT #if CCP_SUPPORT
unsigned int ccp_all_rejected :1; /* we rejected all peer's options */ unsigned int ccp_all_rejected :1; /* we rejected all peer's options */
unsigned int ccp_is_open :1; /* true when CCP is open (currently negotiating) */
unsigned int ccp_is_up :1; /* true when CCP is up (ready to handle data packets) */
#endif /* CCP_SUPPORT */ #endif /* CCP_SUPPORT */
#if MPPE_SUPPORT #if MPPE_SUPPORT
unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */ unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */

View File

@ -456,6 +456,9 @@ static err_t ppp_netif_output_ip6(struct netif *netif, struct pbuf *pb, const ip
#endif /* PPP_IPV6_SUPPORT */ #endif /* PPP_IPV6_SUPPORT */
static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protocol) { static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protocol) {
#if MPPE_SUPPORT
err_t err;
#endif /* MPPE_SUPPORT */
ppp_pcb *pcb = (ppp_pcb*)netif->state; ppp_pcb *pcb = (ppp_pcb*)netif->state;
/* Check that the link is up. */ /* Check that the link is up. */
@ -473,8 +476,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
#if MPPE_SUPPORT #if MPPE_SUPPORT
/* If MPPE is required, refuse any IP packet until we are able to crypt them. */ /* If MPPE is required, refuse any IP packet until we are able to crypt them. */
if (pcb->settings.require_mppe && if (pcb->settings.require_mppe && pcb->ccp_transmit_method != CI_MPPE) {
(!pcb->ccp_is_up || pcb->ccp_transmit_method != CI_MPPE) ) {
PPPDEBUG(LOG_ERR, ("ppp_netif_output[%d]: MPPE required, not up\n", pcb->netif->num)); PPPDEBUG(LOG_ERR, ("ppp_netif_output[%d]: MPPE required, not up\n", pcb->netif->num));
goto err_rte_drop; goto err_rte_drop;
} }
@ -508,28 +510,24 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
#endif /* VJ_SUPPORT && LWIP_TCP */ #endif /* VJ_SUPPORT && LWIP_TCP */
#if CCP_SUPPORT #if CCP_SUPPORT
if (pcb->ccp_is_up) { switch (pcb->ccp_transmit_method) {
case 0:
break; /* Don't compress */
#if MPPE_SUPPORT #if MPPE_SUPPORT
err_t err; case CI_MPPE:
#endif /* MPPE_SUPPORT */ if ((err = mppe_compress(pcb, &pcb->mppe_comp, &pb, protocol)) != ERR_OK) {
LINK_STATS_INC(link.memerr);
switch (pcb->ccp_transmit_method) { LINK_STATS_INC(link.drop);
#if MPPE_SUPPORT MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
case CI_MPPE:
if ((err = mppe_compress(pcb, &pcb->mppe_comp, &pb, protocol)) != ERR_OK) {
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
MIB2_STATS_NETIF_INC(netif, ifoutdiscards);
return err;
}
err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, PPP_COMP);
pbuf_free(pb);
return err; return err;
#endif /* MPPE_SUPPORT */
default:
goto err_rte_drop; /* Cannot really happen, we only negotiate what we are able to do */
} }
err = pcb->link_cb->netif_output(pcb, pcb->link_ctx_cb, pb, PPP_COMP);
pbuf_free(pb);
return err;
#endif /* MPPE_SUPPORT */
default:
goto err_rte_drop; /* Cannot really happen, we only negotiate what we are able to do */
} }
#endif /* CCP_SUPPORT */ #endif /* CCP_SUPPORT */
@ -773,10 +771,6 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
if (protocol == PPP_COMP) { if (protocol == PPP_COMP) {
u8_t *pl; u8_t *pl;
if (!pcb->ccp_is_up) {
goto drop;
}
switch (pcb->ccp_receive_method) { switch (pcb->ccp_receive_method) {
#if MPPE_SUPPORT #if MPPE_SUPPORT
case CI_MPPE: case CI_MPPE:
@ -1307,8 +1301,8 @@ ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit)
void void
ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method) ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method)
{ {
pcb->ccp_is_open = isopen; LWIP_UNUSED_ARG(isopen);
pcb->ccp_is_up = isup; LWIP_UNUSED_ARG(isup);
pcb->ccp_receive_method = receive_method; pcb->ccp_receive_method = receive_method;
pcb->ccp_transmit_method = transmit_method; pcb->ccp_transmit_method = transmit_method;
PPPDEBUG(LOG_DEBUG, ("ccp_set[%d]: is_open=%d, is_up=%d, receive_method=%u, transmit_method=%u\n", PPPDEBUG(LOG_DEBUG, ("ccp_set[%d]: is_open=%d, is_up=%d, receive_method=%u, transmit_method=%u\n",