diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2012-12-20 10:12:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-21 16:14:00 -0500 |
commit | 412ed94744d16806fbec3bd250fd94e71cde5a1f (patch) | |
tree | 092eb88bc8d798797354bdaa8db95c26faa35f6b /net | |
parent | 29042073e7af55334ac3c4f2a8340263200c5749 (diff) |
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 <yamahata@valinux.co.jp>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/ip_gre.c | 5 |
1 files changed, 4 insertions, 1 deletions
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 | |||
760 | 760 | ||
761 | if (dev->header_ops && dev->type == ARPHRD_IPGRE) { | 761 | if (dev->header_ops && dev->type == ARPHRD_IPGRE) { |
762 | gre_hlen = 0; | 762 | gre_hlen = 0; |
763 | tiph = (const struct iphdr *)skb->data; | 763 | if (skb->protocol == htons(ETH_P_IP)) |
764 | tiph = (const struct iphdr *)skb->data; | ||
765 | else | ||
766 | tiph = &tunnel->parms.iph; | ||
764 | } else { | 767 | } else { |
765 | gre_hlen = tunnel->hlen; | 768 | gre_hlen = tunnel->hlen; |
766 | tiph = &tunnel->parms.iph; | 769 | tiph = &tunnel->parms.iph; |