ip_tunnel: clear IPCB in ip_tunnel_xmit() in case dst_link_failure() is called
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / ip_gre.c
index 2a83591492dd6f3e8b7470c3e9b897dad7625a49..828b2e8631e70ff254e43e76707d44fdf3ff8cf8 100644 (file)
@@ -335,7 +335,8 @@ static int ipgre_rcv(struct sk_buff *skb)
                                  iph->saddr, iph->daddr, tpi.key);
 
        if (tunnel) {
-               ip_tunnel_rcv(tunnel, skb, &tpi, log_ecn_error);
+               skb_pop_mac_header(skb);
+               ip_tunnel_rcv(tunnel, skb, &tpi, hdr_len, log_ecn_error);
                return 0;
        }
        icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
@@ -503,10 +504,11 @@ static int ipgre_tunnel_ioctl(struct net_device *dev,
 
        if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
                return -EFAULT;
-       if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
-           p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
-           ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING))) {
-               return -EINVAL;
+       if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
+               if (p.iph.version != 4 || p.iph.protocol != IPPROTO_GRE ||
+                   p.iph.ihl != 5 || (p.iph.frag_off&htons(~IP_DF)) ||
+                   ((p.i_flags|p.o_flags)&(GRE_VERSION|GRE_ROUTING)))
+                       return -EINVAL;
        }
        p.i_flags = gre_flags_to_tnl_flags(p.i_flags);
        p.o_flags = gre_flags_to_tnl_flags(p.o_flags);
@@ -571,7 +573,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
        if (daddr)
                memcpy(&iph->daddr, daddr, 4);
        if (iph->daddr)
-               return t->hlen;
+               return t->hlen + sizeof(*iph);
 
        return -(t->hlen + sizeof(*iph));
 }