Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

l2tp: give proper headroom in pppol2tp_xmit()

pppol2tp_xmit() calls skb_cow_head(skb, 2) before calling
l2tp_xmit_skb()

Then l2tp_xmit_skb() calls again skb_cow_head(skb, large_headroom)

This patchs changes the first skb_cow_head() call to supply the needed
headroom to make sure at most one (expensive) pskb_expand_head() is
done.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
09df57ca bc416d97

+8 -1
+8 -1
net/l2tp/l2tp_ppp.c
··· 395 395 struct pppol2tp_session *ps; 396 396 int old_headroom; 397 397 int new_headroom; 398 + int uhlen, headroom; 398 399 399 400 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) 400 401 goto abort; ··· 414 413 goto abort_put_sess; 415 414 416 415 old_headroom = skb_headroom(skb); 417 - if (skb_cow_head(skb, sizeof(ppph))) 416 + uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; 417 + headroom = NET_SKB_PAD + 418 + sizeof(struct iphdr) + /* IP header */ 419 + uhlen + /* UDP header (if L2TP_ENCAPTYPE_UDP) */ 420 + session->hdr_len + /* L2TP header */ 421 + sizeof(ppph); /* PPP header */ 422 + if (skb_cow_head(skb, headroom)) 418 423 goto abort_put_sess_tun; 419 424 420 425 new_headroom = skb_headroom(skb);