netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels
@ 2018-02-27 11:19 Xin Long
  2018-02-27 11:19 ` [PATCH net 1/3] ip_gre: fix IFLA_MTU ignored on NEWLINK Xin Long
  2018-02-27 19:36 ` [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Xin Long @ 2018-02-27 11:19 UTC (permalink / raw)
  To: network dev; +Cc: davem

The fix for ip_gre follows the way other ip tunnels do: not to
set mtu in ndo_init, as ip_tunnel_newlink will take care of it
properly.

The fix for ip6_tunnel and sit follows the way ipv6 tunenls do:
to set mtu again according to IFLA_MTU after, as all bind_dev
are called in ndo_init where it can't get the tb[IFLA_MTU].

Xin Long (3):
  ip_gre: fix IFLA_MTU ignored on NEWLINK
  ip6_tunnel: fix IFLA_MTU ignored on NEWLINK
  sit: fix IFLA_MTU ignored on NEWLINK

 net/ipv4/ip_gre.c     |  5 -----
 net/ipv6/ip6_tunnel.c | 12 ++++++++----
 net/ipv6/sit.c        |  7 +++++++
 3 files changed, 15 insertions(+), 9 deletions(-)

-- 
2.1.0

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

* [PATCH net 1/3] ip_gre: fix IFLA_MTU ignored on NEWLINK
  2018-02-27 11:19 [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels Xin Long
@ 2018-02-27 11:19 ` Xin Long
  2018-02-27 11:19   ` [PATCH net 2/3] ip6_tunnel: " Xin Long
  2018-02-27 19:36 ` [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Xin Long @ 2018-02-27 11:19 UTC (permalink / raw)
  To: network dev; +Cc: davem

It's safe to remove the setting of dev's needed_headroom and mtu in
__gre_tunnel_init, as discussed in [1], ip_tunnel_newlink can do it
properly.

Now Eric noticed that it could cover the mtu value set in do_setlink
when creating a ip_gre dev. It makes IFLA_MTU param not take effect.

So this patch is to remove them to make IFLA_MTU work, as in other
ipv4 tunnels.

  [1]: https://patchwork.ozlabs.org/patch/823504/

Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
Reported-by: Eric Garver <e@erig.me>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/ip_gre.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 45d97e9..0901de4 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -970,9 +970,6 @@ static void __gre_tunnel_init(struct net_device *dev)
 
 	t_hlen = tunnel->hlen + sizeof(struct iphdr);
 
-	dev->needed_headroom	= LL_MAX_HEADER + t_hlen + 4;
-	dev->mtu		= ETH_DATA_LEN - t_hlen - 4;
-
 	dev->features		|= GRE_FEATURES;
 	dev->hw_features	|= GRE_FEATURES;
 
@@ -1290,8 +1287,6 @@ static int erspan_tunnel_init(struct net_device *dev)
 		       erspan_hdr_len(tunnel->erspan_ver);
 	t_hlen = tunnel->hlen + sizeof(struct iphdr);
 
-	dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
-	dev->mtu = ETH_DATA_LEN - t_hlen - 4;
 	dev->features		|= GRE_FEATURES;
 	dev->hw_features	|= GRE_FEATURES;
 	dev->priv_flags		|= IFF_LIVE_ADDR_CHANGE;
-- 
2.1.0

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

* [PATCH net 2/3] ip6_tunnel: fix IFLA_MTU ignored on NEWLINK
  2018-02-27 11:19 ` [PATCH net 1/3] ip_gre: fix IFLA_MTU ignored on NEWLINK Xin Long
@ 2018-02-27 11:19   ` Xin Long
  2018-02-27 11:19     ` [PATCH net 3/3] sit: " Xin Long
  0 siblings, 1 reply; 5+ messages in thread
From: Xin Long @ 2018-02-27 11:19 UTC (permalink / raw)
  To: network dev; +Cc: davem

Commit 128bb975dc3c ("ip6_gre: init dev->mtu and dev->hard_header_len
correctly") fixed IFLA_MTU ignored on NEWLINK for ip6_gre. The same
mtu fix is also needed for ip6_tunnel.

Note that dev->hard_header_len setting for ip6_tunnel works fine,
no need to fix it.

Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv6/ip6_tunnel.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 4b15fe9..6e0f21e 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1982,14 +1982,14 @@ static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
 {
 	struct net *net = dev_net(dev);
 	struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
-	struct ip6_tnl *nt, *t;
 	struct ip_tunnel_encap ipencap;
+	struct ip6_tnl *nt, *t;
+	int err;
 
 	nt = netdev_priv(dev);
 
 	if (ip6_tnl_netlink_encap_parms(data, &ipencap)) {
-		int err = ip6_tnl_encap_setup(nt, &ipencap);
-
+		err = ip6_tnl_encap_setup(nt, &ipencap);
 		if (err < 0)
 			return err;
 	}
@@ -2005,7 +2005,11 @@ static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
 			return -EEXIST;
 	}
 
-	return ip6_tnl_create2(dev);
+	err = ip6_tnl_create2(dev);
+	if (!err && tb[IFLA_MTU])
+		ip6_tnl_change_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
+
+	return err;
 }
 
 static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[],
-- 
2.1.0

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

* [PATCH net 3/3] sit: fix IFLA_MTU ignored on NEWLINK
  2018-02-27 11:19   ` [PATCH net 2/3] ip6_tunnel: " Xin Long
@ 2018-02-27 11:19     ` Xin Long
  0 siblings, 0 replies; 5+ messages in thread
From: Xin Long @ 2018-02-27 11:19 UTC (permalink / raw)
  To: network dev; +Cc: davem

Commit 128bb975dc3c ("ip6_gre: init dev->mtu and dev->hard_header_len
correctly") fixed IFLA_MTU ignored on NEWLINK for ip6_gre. The same
mtu fix is also needed for sit.

Note that dev->hard_header_len setting for sit works fine, no need to
fix it. sit is actually ipv4 tunnel, it can't call ip6_tnl_change_mtu
to set mtu.

Reported-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv6/sit.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 3a1775a..0195598 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1578,6 +1578,13 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
 	if (err < 0)
 		return err;
 
+	if (tb[IFLA_MTU]) {
+		u32 mtu = nla_get_u32(tb[IFLA_MTU]);
+
+		if (mtu >= IPV6_MIN_MTU && mtu <= 0xFFF8 - dev->hard_header_len)
+			dev->mtu = mtu;
+	}
+
 #ifdef CONFIG_IPV6_SIT_6RD
 	if (ipip6_netlink_6rd_parms(data, &ip6rd))
 		err = ipip6_tunnel_update_6rd(nt, &ip6rd);
-- 
2.1.0

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

* Re: [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels
  2018-02-27 11:19 [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels Xin Long
  2018-02-27 11:19 ` [PATCH net 1/3] ip_gre: fix IFLA_MTU ignored on NEWLINK Xin Long
@ 2018-02-27 19:36 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2018-02-27 19:36 UTC (permalink / raw)
  To: lucien.xin; +Cc: netdev

From: Xin Long <lucien.xin@gmail.com>
Date: Tue, 27 Feb 2018 19:19:38 +0800

> The fix for ip_gre follows the way other ip tunnels do: not to
> set mtu in ndo_init, as ip_tunnel_newlink will take care of it
> properly.
> 
> The fix for ip6_tunnel and sit follows the way ipv6 tunenls do:
> to set mtu again according to IFLA_MTU after, as all bind_dev
> are called in ndo_init where it can't get the tb[IFLA_MTU].

Series applied, thanks.

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

end of thread, other threads:[~2018-02-27 19:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-27 11:19 [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels Xin Long
2018-02-27 11:19 ` [PATCH net 1/3] ip_gre: fix IFLA_MTU ignored on NEWLINK Xin Long
2018-02-27 11:19   ` [PATCH net 2/3] ip6_tunnel: " Xin Long
2018-02-27 11:19     ` [PATCH net 3/3] sit: " Xin Long
2018-02-27 19:36 ` [PATCH net 0/3] net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels 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).