Skip to content

Commit

Permalink
gre: move iptunnel_pull_header down to ipgre_rcv
Browse files Browse the repository at this point in the history
This will allow to make the pull dependent on the tunnel type.

Signed-off-by: Jiri Benc <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Benc authored and davem330 committed May 4, 2016
1 parent 00b2034 commit 244a797
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ static __be32 tunnel_id_to_key(__be64 x)
#endif
}

static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
int hdr_len)
{
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL;
Expand All @@ -278,6 +279,9 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
iph->saddr, iph->daddr, tpi->key);

if (tunnel) {
if (iptunnel_pull_header(skb, hdr_len, tpi->proto, false) < 0)
goto drop;

skb_pop_mac_header(skb);
if (tunnel->collect_md) {
__be16 flags;
Expand All @@ -294,6 +298,10 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
return PACKET_RCVD;
}
return PACKET_REJECT;

drop:
kfree_skb(skb);
return PACKET_RCVD;
}

static int gre_rcv(struct sk_buff *skb)
Expand All @@ -314,10 +322,7 @@ static int gre_rcv(struct sk_buff *skb)
if (hdr_len < 0)
goto drop;

if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
goto drop;

if (ipgre_rcv(skb, &tpi) == PACKET_RCVD)
if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
return 0;

icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
Expand Down

0 comments on commit 244a797

Please sign in to comment.