All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] ip6_gre: Fix MTU setting for ip6gretap
@ 2016-05-21 10:17 Haishuang Yan
  2016-05-21 10:17 ` [PATCH v2 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
  2016-05-24 21:34 ` [PATCH v2 1/2] ip6_gre: Fix MTU setting for ip6gretap David Miller
  0 siblings, 2 replies; 147+ messages in thread
From: Haishuang Yan @ 2016-05-21 10:17 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan

When creat an ip6gretap interface with an unreachable route,
the MTU is about 14 bytes larger than what was needed.

If the remote address is reachable:
ping6 2001:0:130::1 -c 2
PING 2001:0:130::1(2001:0:130::1) 56 data bytes
64 bytes from 2001:0:130::1: icmp_seq=1 ttl=64 time=1.46 ms
64 bytes from 2001:0:130::1: icmp_seq=2 ttl=64 time=81.1 ms

--- 2001:0:130::1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.465/41.316/81.167/39.851 ms

ip link add ip6gretap1 type ip6gretap\
 local 2001:0:130::2 remote 2001:0:130::1
ip link show ip6gretap1
11: ip6gretap1@NONE: <BROADCAST,MULTICAST> mtu 1434 ...
    link/ether c2:f3:f8:c1:2c:bf brd ff:ff:ff:ff:ff:ff

The MTU value 1434 is right. But if we delete the direct route:
ip -6 route del 2001:0:130::/64
ping6 2001:0:130::1 -c 2
connect: Network is unreachable
ip link add ip6gretap1 type ip6gretap\
 local 2001:0:130::2 remote 2001:0:130::1
ip link show ip6gretap1
12: ip6gretap1@NONE: <BROADCAST,MULTICAST> mtu 1448 ...
    link/ether 7e:e1:d2:c4:06:5e brd ff:ff:ff:ff:ff:ff

Now, the MTU value 1448 is larger than what was needed.

The reason is that if there is a reachable route, when
run following code in ip6gre_tnl_link_config:

	if (p->flags & IP6_TNL_F_CAP_XMIT) {
		int strict = (ipv6_addr_type(&p->raddr) &
			      (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));

		struct rt6_info *rt = rt6_lookup(t->net,
						 &p->raddr, &p->laddr,
						 p->link, strict);

		if (!rt)
			return;

		if (rt->dst.dev) {
			dev->hard_header_len = rt->dst.dev->hard_header_len +
					       t_hlen;

			if (set_mtu) {
				dev->mtu = rt->dst.dev->mtu - t_hlen;
				if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
					dev->mtu -= 8;
				if (dev->type == ARPHRD_ETHER)
					dev->mtu -= ETH_HLEN;

				if (dev->mtu < IPV6_MIN_MTU)
					dev->mtu = IPV6_MIN_MTU;
			}
		}
		ip6_rt_put(rt);
	}

Because rt is not NULL here, so dev->mtu will subtract the ethernet
header length later. But when rt is NULL, it just simply return, so
dev->mtu doesn't update correctly in this situation.

This patch first verify the dev->type is ARPHRD_ETHER for ip6gretap
interface, and then decrease the mtu as early as possible.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
Changes in v2:
  - Make the commit message more clearer.
---
 net/ipv6/ip6_gre.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 4541fa5..8ea5a4d 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1029,6 +1029,8 @@ static int ip6gre_tunnel_init_common(struct net_device *dev)
 
 	dev->hard_header_len = LL_MAX_HEADER + t_hlen;
 	dev->mtu = ETH_DATA_LEN - t_hlen;
+	if (dev->type == ARPHRD_ETHER)
+		dev->mtu -= ETH_HLEN;
 	if (!(tunnel->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
 		dev->mtu -= 8;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 147+ messages in thread

end of thread, other threads:[~2016-06-23 10:49 UTC | newest]

Thread overview: 147+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-21 10:17 [PATCH v2 1/2] ip6_gre: Fix MTU setting for ip6gretap Haishuang Yan
2016-05-21 10:17 ` [PATCH v2 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
2016-05-17 15:15   ` [PATCH] ARM: shmobile: rcar-gen2: Use ICRAM1 for jump stub on all SoCs Geert Uytterhoeven
2016-05-17 15:15     ` Geert Uytterhoeven
2016-05-25  1:01     ` Simon Horman
2016-05-25  1:01       ` Simon Horman
2016-05-31 22:06     ` [PATCH 00/13] Add R8A7794/SILK board eMMC DT support Sergei Shtylyov
2016-05-31 22:06       ` Sergei Shtylyov
2016-05-31 22:09       ` [PATCH 01/13] ARM: shmobile: r8a7792: add clock index macros Sergei Shtylyov
2016-06-01  0:52         ` Simon Horman
2016-06-01 13:57           ` Sergei Shtylyov
2016-06-22 19:52           ` Sergei Shtylyov
2016-06-22 22:33             ` Simon Horman
2016-06-23  7:46               ` Geert Uytterhoeven
2016-06-23  7:46                 ` Geert Uytterhoeven
2016-06-23 10:49               ` Sergei Shtylyov
2016-06-23 10:49                 ` Sergei Shtylyov
2016-06-01  7:22         ` Geert Uytterhoeven
2016-06-01  7:22           ` Geert Uytterhoeven
2016-06-01 14:09           ` Sergei Shtylyov
2016-05-31 22:11       ` [PATCH 02/13] ARM: shmobile: r8a7792: add power domain " Sergei Shtylyov
2016-06-01  7:32         ` Geert Uytterhoeven
2016-05-31 22:15       ` [PATCH 03/13] soc: renesas: rcar-sysc: add R8A7792 support Sergei Shtylyov
2016-06-01  7:38         ` Geert Uytterhoeven
2016-05-31 22:18       ` [PATCH 04/13] ARM: shmobile: r8a7792: basic SoC support Sergei Shtylyov
2016-05-31 22:18         ` Sergei Shtylyov
2016-06-01  0:25         ` Simon Horman
2016-06-01  0:25           ` Simon Horman
2016-06-01  7:47         ` Geert Uytterhoeven
2016-06-01  7:47           ` Geert Uytterhoeven
2016-06-01 21:00           ` Sergei Shtylyov
2016-06-01 21:00             ` Sergei Shtylyov
2016-06-06 18:59         ` Sergei Shtylyov
2016-06-06 18:59           ` Sergei Shtylyov
2016-05-31 22:20       ` [PATCH 05/13] DT: clock: rcar-gen2-cpg-clocks: document R8A7792 support Sergei Shtylyov
2016-06-01  0:25         ` Simon Horman
2016-06-01  0:30           ` Simon Horman
2016-06-01  7:50           ` Geert Uytterhoeven
2016-06-01  7:48         ` Geert Uytterhoeven
2016-06-03  1:49         ` Rob Herring
2016-05-31 22:21       ` [PATCH 06/13] DT: clock: cpg-mstp-clocks: document-R8A7792-support Sergei Shtylyov
2016-06-01  0:28         ` Simon Horman
2016-06-01  7:51         ` Geert Uytterhoeven
2016-06-03  1:50         ` Rob Herring
2016-05-31 22:24       ` [PATCH 07/13] ARM: dts: r8a7792: initial SoC device tree Sergei Shtylyov
2016-05-31 22:24         ` Sergei Shtylyov
2016-06-01  0:57         ` Simon Horman
2016-06-01  0:57           ` Simon Horman
2016-06-01 14:00           ` Sergei Shtylyov
2016-06-01 14:00             ` Sergei Shtylyov
2016-06-06 22:26           ` Sergei Shtylyov
2016-06-06 22:26             ` Sergei Shtylyov
2016-06-07  7:13             ` Geert Uytterhoeven
2016-06-07  7:13               ` Geert Uytterhoeven
2016-06-07 20:58               ` Sergei Shtylyov
2016-06-07 20:58                 ` Sergei Shtylyov
2016-06-10  1:02                 ` Simon Horman
2016-06-10  1:02                   ` Simon Horman
2016-06-10 19:29                   ` Sergei Shtylyov
2016-06-10 19:29                     ` Sergei Shtylyov
2016-06-10 20:42                     ` Geert Uytterhoeven
2016-06-10 20:42                       ` Geert Uytterhoeven
2016-06-10 20:50                       ` Sergei Shtylyov
2016-06-10 20:50                         ` Sergei Shtylyov
2016-06-13  7:12                         ` Geert Uytterhoeven
2016-06-13  7:12                           ` Geert Uytterhoeven
2016-06-13 11:24                           ` Sergei Shtylyov
2016-06-13 11:24                             ` Sergei Shtylyov
2016-06-13 11:48                             ` Geert Uytterhoeven
2016-06-13 11:48                               ` Geert Uytterhoeven
2016-06-13 11:48                               ` Geert Uytterhoeven
2016-06-14  1:08                           ` Kuninori Morimoto
2016-06-14  1:08                             ` Kuninori Morimoto
2016-06-17  2:14                             ` Kuninori Morimoto
2016-06-17  2:14                               ` Kuninori Morimoto
2016-06-17  6:27                               ` Geert Uytterhoeven
2016-06-17  6:27                                 ` Geert Uytterhoeven
2016-06-14  0:43                     ` Simon Horman
2016-06-14  0:43                       ` Simon Horman
2016-06-14  0:43                       ` Simon Horman
2016-06-14 21:08                       ` Sergei Shtylyov
2016-06-14 21:08                         ` Sergei Shtylyov
2016-06-16  0:06                         ` Simon Horman
2016-06-16  0:06                           ` Simon Horman
2016-06-01  9:23         ` Geert Uytterhoeven
2016-06-01  9:23           ` Geert Uytterhoeven
2016-05-31 22:25       ` [PATCH 08/13] ARM: dts: r8a7792: add SYS-DMAC support Sergei Shtylyov
2016-05-31 22:25         ` Sergei Shtylyov
2016-06-01  1:03         ` Simon Horman
2016-06-01  1:03           ` Simon Horman
2016-06-01  8:15         ` Geert Uytterhoeven
2016-06-01  8:15           ` Geert Uytterhoeven
2016-06-01  8:15           ` Geert Uytterhoeven
2016-05-31 22:26       ` [PATCH 09/13] ARM: dts: r8a7792: add [H]SCIF support Sergei Shtylyov
2016-05-31 22:26         ` Sergei Shtylyov
2016-06-01  1:13         ` Simon Horman
2016-06-01  1:13           ` Simon Horman
2016-06-03 14:33           ` Sergei Shtylyov
2016-06-03 14:33             ` Sergei Shtylyov
2016-06-01  8:17         ` Geert Uytterhoeven
2016-06-01  8:17           ` Geert Uytterhoeven
2016-05-31 22:29       ` [PATCH 10/13] ARM: dts: r8a7792: add IRQC support Sergei Shtylyov
2016-05-31 22:29         ` Sergei Shtylyov
2016-06-01  1:18         ` Simon Horman
2016-06-01  1:18           ` Simon Horman
2016-06-01 14:02           ` Sergei Shtylyov
2016-06-01 14:02             ` Sergei Shtylyov
2016-06-01  8:17         ` Geert Uytterhoeven
2016-06-01  8:17           ` Geert Uytterhoeven
2016-06-01  8:17           ` Geert Uytterhoeven
2016-05-31 22:30       ` [PATCH 11/13] DT: arm: shmobile: document Blanche board Sergei Shtylyov
2016-05-31 23:51         ` Simon Horman
2016-06-01 13:34           ` Sergei Shtylyov
2016-06-01 13:34             ` Sergei Shtylyov
2016-06-01  8:19         ` Geert Uytterhoeven
2016-06-03  1:50         ` Rob Herring
2016-05-31 22:32       ` [PATCH 12/13] ARM: dts: blanche: initial device tree Sergei Shtylyov
2016-05-31 22:32         ` Sergei Shtylyov
2016-05-24 21:34         ` [PATCH v2 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path., Re: [PATCH] ARM: shmobile: rcar-gen2: Use ICRAM1 for jump stub on all SoCs, " David Miller, Simon Horman, Sergei Shtylyov
2016-05-24 21:34           ` [PATCH v2 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path David Miller
2016-06-01  1:21         ` [PATCH 12/13] ARM: dts: blanche: initial device tree Simon Horman
2016-06-01  1:21           ` Simon Horman
2016-06-02 21:34           ` Sergei Shtylyov
2016-06-02 21:34             ` Sergei Shtylyov
2016-06-01  8:36         ` Geert Uytterhoeven
2016-06-01  8:36           ` Geert Uytterhoeven
2016-06-01  8:36           ` Geert Uytterhoeven
2016-05-31 22:33       ` [PATCH 13/13] ARM: dts: blanche: add Ethernet support Sergei Shtylyov
2016-05-31 22:33         ` Sergei Shtylyov
2016-06-01  1:24         ` Simon Horman
2016-06-01  1:24           ` Simon Horman
2016-06-01  8:22         ` Geert Uytterhoeven
2016-06-01  8:22           ` Geert Uytterhoeven
2016-06-01  8:22           ` Geert Uytterhoeven
2016-06-01 12:16           ` Sergei Shtylyov
2016-06-01 12:16             ` Sergei Shtylyov
2016-06-01 12:27             ` Geert Uytterhoeven
2016-06-01 12:27               ` Geert Uytterhoeven
2016-06-01 12:27               ` Geert Uytterhoeven
2016-06-02 21:33               ` Sergei Shtylyov
2016-06-02 21:33                 ` Sergei Shtylyov
2016-06-01  7:04       ` [PATCH 00/13] Add R8A7794/SILK board eMMC DT support Geert Uytterhoeven
2016-06-01  7:04         ` Geert Uytterhoeven
2016-06-01  7:04         ` Geert Uytterhoeven
2016-06-01 10:30         ` Sergei Shtylyov
2016-06-01 10:30           ` Sergei Shtylyov
2016-05-24 21:34 ` [PATCH v2 1/2] ip6_gre: Fix MTU setting for ip6gretap David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.