linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap
@ 2016-05-18 10:05 Haishuang Yan
  2016-05-18 10:05 ` [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
  2016-05-20 17:47 ` [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Haishuang Yan @ 2016-05-18 10:05 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.

This patch fix the issue in this situation.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 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] 5+ messages in thread

* [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path.
  2016-05-18 10:05 [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap Haishuang Yan
@ 2016-05-18 10:05 ` Haishuang Yan
  2016-05-20 17:48   ` David Miller
  2016-05-20 17:47 ` [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Haishuang Yan @ 2016-05-18 10:05 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris, Hideaki YOSHIFUJI
  Cc: netdev, linux-kernel, Haishuang Yan

In gre6 xmit path, we are sending a GRE packet, so set fl6 proto
to IPPROTO_GRE properly.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 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 8ea5a4d..cc84098 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -541,6 +541,7 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_GRE;
 
 	dsfield = ipv4_get_dsfield(iph);
 
@@ -595,6 +596,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
 		encap_limit = t->parms.encap_limit;
 
 	memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
+	fl6.flowi6_proto = IPPROTO_GRE;
 
 	dsfield = ipv6_get_dsfield(ipv6h);
 	if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
-- 
1.8.3.1

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

* Re: [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap
  2016-05-18 10:05 [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap Haishuang Yan
  2016-05-18 10:05 ` [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
@ 2016-05-20 17:47 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2016-05-20 17:47 UTC (permalink / raw)
  To: yanhaishuang; +Cc: kuznet, jmorris, yoshfuji, netdev, linux-kernel

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Wed, 18 May 2016 18:05:51 +0800

> 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.
> 
> This patch fix the issue in this situation.
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

It's great that you have provided precise examples of how to reproduce
the problem.

But you need to explain in your commit message how your fix works.
Why does simply checking the device type and subtracting the ethernet
header length work here?  What is the full context for your fix and
why does it work?

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

* Re: [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path.
  2016-05-18 10:05 ` [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
@ 2016-05-20 17:48   ` David Miller
  2016-05-21  3:46     ` 严海双
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2016-05-20 17:48 UTC (permalink / raw)
  To: yanhaishuang; +Cc: kuznet, jmorris, yoshfuji, netdev, linux-kernel

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Wed, 18 May 2016 18:05:52 +0800

> In gre6 xmit path, we are sending a GRE packet, so set fl6 proto
> to IPPROTO_GRE properly.
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

I think it would be a lot better to initialize the flow protocol field
properly in ip6gre_tnl_link_config() instead of fixing it up every
single transmit.

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

* Re: [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path.
  2016-05-20 17:48   ` David Miller
@ 2016-05-21  3:46     ` 严海双
  0 siblings, 0 replies; 5+ messages in thread
From: 严海双 @ 2016-05-21  3:46 UTC (permalink / raw)
  To: David Miller; +Cc: kuznet, jmorris, yoshfuji, netdev, linux-kernel


> On May 21, 2016, at 1:48 AM, David Miller <davem@davemloft.net> wrote:
> 
> From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> Date: Wed, 18 May 2016 18:05:52 +0800
> 
>> In gre6 xmit path, we are sending a GRE packet, so set fl6 proto
>> to IPPROTO_GRE properly.
>> 
>> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> 
> I think it would be a lot better to initialize the flow protocol field
> properly in ip6gre_tnl_link_config() instead of fixing it up every
> single transmit.
> 
> 

I agree, I will modify the changes in v2.

Thanks

Haishuang

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

end of thread, other threads:[~2016-05-21  3:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 10:05 [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap Haishuang Yan
2016-05-18 10:05 ` [PATCH 2/2] ip6_gre: Set flowi6_proto as IPPROTO_GRE in xmit path Haishuang Yan
2016-05-20 17:48   ` David Miller
2016-05-21  3:46     ` 严海双
2016-05-20 17:47 ` [PATCH 1/2] ip6_gre: Fix MTU setting for ip6gretap David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).