PPP, PPPoL2TP: skip address & flags for PPP control packets

This is already what we inherently have always done for IPv4/IPv6
packets, so it works. Receivers must handle both cases anyway because
both behaviors are seen in the wild.
This commit is contained in:
Sylvain Rochet 2020-10-23 17:21:02 +02:00
parent a494b990da
commit 72d9132ecf

View File

@ -172,6 +172,9 @@ static err_t pppol2tp_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) {
LWIP_UNUSED_ARG(ppp);
#endif /* MIB2_STATS */
/* skip address & flags */
pbuf_remove_header(p, 2);
ph = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(PPPOL2TP_OUTPUT_DATA_HEADER_LEN), PBUF_RAM);
if(!ph) {
LINK_STATS_INC(link.memerr);
@ -463,8 +466,16 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, const
/*
* skip address & flags if necessary
*
* RFC 2661 does not specify whether the PPP frame in the L2TP payload should
* have a HDLC header or not. We handle both cases for compatibility.
* RFC 2661 (L2TPv2) does not specify whether the PPP frame in the L2TP payload
* should have a HDLC header or not, both behaviors are seen in the wild.
*
* On the other hand, L2TPv3 draft-ietf-l2tpext-l2tp-ppp versions 00 and 01 say
* it must be included, versions 02 to 05 say it must be omitted, and versions
* 06 and onwards say it should be omitted so it changed along the path when
* L2TPv3 was designed. Latest versions state that receivers must handle both
* cases.
*
* We handle both cases for compatibility.
*/
if (p->len >= 2) {
GETSHORT(hflags, inp);