From 6584002826e39589d7972966a4e44e06472f44c9 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Tue, 20 Oct 2020 03:17:53 +0200 Subject: [PATCH] PPP, PPPoS: only reserve header space for IPv4 and IPv6 packets if IP forwarding is enabled We only have to reserve header space for forwarding for IPv4 and IPv6 packets, all other packets are PPP control packets. Doing so reduce the need of having to coalesce the PBUF chain before PPP processes control packets. --- src/netif/ppp/pppos.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 9d3fc2a4..f5fea002 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -561,7 +561,16 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) pppos->in_tail = NULL; #if IP_FORWARD || LWIP_IPV6_FORWARD /* hide the room for Ethernet forwarding header */ - pbuf_remove_header(inp, PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN); + if (0 +#if PPP_IPV4_SUPPORT + || pppos->in_protocol == PPP_IP +#endif /* PPP_IPV4_SUPPORT */ +#if PPP_IPV6_SUPPORT + || pppos->in_protocol == PPP_IPV6 +#endif /* PPP_IPV6_SUPPORT */ + ) { + pbuf_remove_header(inp, PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN); + } #endif /* IP_FORWARD || LWIP_IPV6_FORWARD */ #if PPP_INPROC_IRQ_SAFE if(tcpip_try_callback(pppos_input_callback, inp) != ERR_OK) { @@ -670,7 +679,14 @@ pppos_input(ppp_pcb *ppp, u8_t *s, int l) * + PBUF_LINK_HLEN bytes so the packet is being allocated with enough header * space to be forwarded (to Ethernet for example). */ - if (pppos->in_head == NULL) { + if (pppos->in_head == NULL && (0 +#if PPP_IPV4_SUPPORT + || pppos->in_protocol == PPP_IP +#endif /* PPP_IPV4_SUPPORT */ +#if PPP_IPV6_SUPPORT + || pppos->in_protocol == PPP_IPV6 +#endif /* PPP_IPV6_SUPPORT */ + )) { pbuf_alloc_len = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN; } #endif /* IP_FORWARD || LWIP_IPV6_FORWARD */