From: Isaku Yamahata Date: Thu, 20 Dec 2012 15:12:52 +0000 (+0000) Subject: ip_gre: make ipgre_tunnel_xmit() not parse network header as IP unconditionally X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=412ed94744d16806fbec3bd250fd94e71cde5a1f;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ip_gre: make ipgre_tunnel_xmit() not parse network header as IP unconditionally ipgre_tunnel_xmit() parses network header as IP unconditionally. But transmitting packets are not always IP packet. For example such packet can be sent by packet socket with sockaddr_ll.sll_protocol set. So make the function check if skb->protocol is IP. Signed-off-by: Isaku Yamahata Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index a85ae2f7a21c..8fcf0ed76548 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -760,7 +760,10 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev if (dev->header_ops && dev->type == ARPHRD_IPGRE) { gre_hlen = 0; - tiph = (const struct iphdr *)skb->data; + if (skb->protocol == htons(ETH_P_IP)) + tiph = (const struct iphdr *)skb->data; + else + tiph = &tunnel->parms.iph; } else { gre_hlen = tunnel->hlen; tiph = &tunnel->parms.iph;