]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jul 2021 12:13:41 +0000 (14:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jul 2021 12:13:41 +0000 (14:13 +0200)
added patches:
net-ip_tunnel-fix-mtu-calculation-for-ether-tunnel-devices.patch

queue-4.19/net-ip_tunnel-fix-mtu-calculation-for-ether-tunnel-devices.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/net-ip_tunnel-fix-mtu-calculation-for-ether-tunnel-devices.patch b/queue-4.19/net-ip_tunnel-fix-mtu-calculation-for-ether-tunnel-devices.patch
new file mode 100644 (file)
index 0000000..6169136
--- /dev/null
@@ -0,0 +1,91 @@
+From 9992a078b1771da354ac1f9737e1e639b687caa2 Mon Sep 17 00:00:00 2001
+From: Hangbin Liu <liuhangbin@gmail.com>
+Date: Fri, 9 Jul 2021 11:45:02 +0800
+Subject: net: ip_tunnel: fix mtu calculation for ETHER tunnel devices
+
+From: Hangbin Liu <liuhangbin@gmail.com>
+
+commit 9992a078b1771da354ac1f9737e1e639b687caa2 upstream.
+
+Commit 28e104d00281 ("net: ip_tunnel: fix mtu calculation") removed
+dev->hard_header_len subtraction when calculate MTU for tunnel devices
+as there is an overhead for device that has header_ops.
+
+But there are ETHER tunnel devices, like gre_tap or erspan, which don't
+have header_ops but set dev->hard_header_len during setup. This makes
+pkts greater than (MTU - ETH_HLEN) could not be xmited. Fix it by
+subtracting the ETHER tunnel devices' dev->hard_header_len for MTU
+calculation.
+
+Fixes: 28e104d00281 ("net: ip_tunnel: fix mtu calculation")
+Reported-by: Jianlin Shi <jishi@redhat.com>
+Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/ipv4/ip_tunnel.c |   22 ++++++++++++++++++----
+ 1 file changed, 18 insertions(+), 4 deletions(-)
+
+--- a/net/ipv4/ip_tunnel.c
++++ b/net/ipv4/ip_tunnel.c
+@@ -330,7 +330,7 @@ static int ip_tunnel_bind_dev(struct net
+       }
+       dev->needed_headroom = t_hlen + hlen;
+-      mtu -= t_hlen;
++      mtu -= t_hlen + (dev->type == ARPHRD_ETHER ? dev->hard_header_len : 0);
+       if (mtu < IPV4_MIN_MTU)
+               mtu = IPV4_MIN_MTU;
+@@ -361,6 +361,9 @@ static struct ip_tunnel *ip_tunnel_creat
+       t_hlen = nt->hlen + sizeof(struct iphdr);
+       dev->min_mtu = ETH_MIN_MTU;
+       dev->max_mtu = IP_MAX_MTU - t_hlen;
++      if (dev->type == ARPHRD_ETHER)
++              dev->max_mtu -= dev->hard_header_len;
++
+       ip_tunnel_add(itn, nt);
+       return nt;
+@@ -502,13 +505,18 @@ static int tnl_update_pmtu(struct net_de
+                           const struct iphdr *inner_iph)
+ {
+       struct ip_tunnel *tunnel = netdev_priv(dev);
+-      int pkt_size = skb->len - tunnel->hlen;
++      int pkt_size;
+       int mtu;
+-      if (df)
++      pkt_size = skb->len - tunnel->hlen;
++      pkt_size -= dev->type == ARPHRD_ETHER ? dev->hard_header_len : 0;
++
++      if (df) {
+               mtu = dst_mtu(&rt->dst) - (sizeof(struct iphdr) + tunnel->hlen);
+-      else
++              mtu -= dev->type == ARPHRD_ETHER ? dev->hard_header_len : 0;
++      } else {
+               mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
++      }
+       skb_dst_update_pmtu_no_confirm(skb, mtu);
+@@ -936,6 +944,9 @@ int __ip_tunnel_change_mtu(struct net_de
+       int t_hlen = tunnel->hlen + sizeof(struct iphdr);
+       int max_mtu = IP_MAX_MTU - t_hlen;
++      if (dev->type == ARPHRD_ETHER)
++              max_mtu -= dev->hard_header_len;
++
+       if (new_mtu < ETH_MIN_MTU)
+               return -EINVAL;
+@@ -1113,6 +1124,9 @@ int ip_tunnel_newlink(struct net_device
+       if (tb[IFLA_MTU]) {
+               unsigned int max = IP_MAX_MTU - (nt->hlen + sizeof(struct iphdr));
++              if (dev->type == ARPHRD_ETHER)
++                      max -= dev->hard_header_len;
++
+               mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, max);
+       }
index 93fd01321134017d6497923aeb2eb564c785d65f..2801b20f7c3fdc8df9433efcb4f39dbbd132446c 100644 (file)
@@ -49,3 +49,4 @@ tcp-annotate-data-races-around-tp-mtu_info.patch
 ipv6-tcp-drop-silly-icmpv6-packet-too-big-messages.patch
 bpftool-properly-close-va_list-ap-by-va_end-on-error.patch
 udp-annotate-data-races-around-unix_sk-sk-gso_size.patch
+net-ip_tunnel-fix-mtu-calculation-for-ether-tunnel-devices.patch