netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels
@ 2018-03-22 17:53 Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 1/3] ip_tunnel: Emit events for post-register MTU changes Ido Schimmel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-22 17:53 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, lucien.xin, mlxsw, Ido Schimmel

Petr says:

When offloading GRE tunnels, the MTU setting is kept fixed after the
initial offload even as the slow-path configuration changed. Worse: the
offloaded MTU setting is actually just a transient value set at the time
of NETDEV_REGISTER of the tunnel. As of commit ffc2b6ee4174 ("ip_gre:
fix IFLA_MTU ignored on NEWLINK"), that transient value is zero, and
unless there's e.g. a VRF migration that prompts re-offload, it stays at
zero, and all GRE packets end up trapping.

Thus, in patch #1, change the way the MTU is changed post-registration,
so that the full event protocol is observed. That way the drivers get to
see the change and have a chance to react.

In the remaining two patches, implement support for MTU change in mlxsw
driver.

Petr Machata (3):
  ip_tunnel: Emit events for post-register MTU changes
  mlxsw: spectrum_router: Move mlxsw_sp_rif_ipip_lb_op()
  mlxsw: spectrum_router: Handle MTU change of GRE netdevs

 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 78 ++++++++++++++--------
 net/ipv4/ip_tunnel.c                               | 26 ++++++--
 2 files changed, 72 insertions(+), 32 deletions(-)

-- 
2.14.3

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

* [PATCH net 1/3] ip_tunnel: Emit events for post-register MTU changes
  2018-03-22 17:53 [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels Ido Schimmel
@ 2018-03-22 17:53 ` Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 2/3] mlxsw: spectrum_router: Move mlxsw_sp_rif_ipip_lb_op() Ido Schimmel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-22 17:53 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, lucien.xin, mlxsw, Petr Machata, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

For tunnels created with IFLA_MTU, MTU of the netdevice is set by
rtnl_create_link() (called from rtnl_newlink()) before the device is
registered. However without IFLA_MTU that's not done.

rtnl_newlink() proceeds by calling struct rtnl_link_ops.newlink, which
via ip_tunnel_newlink() calls register_netdevice(), and that emits
NETDEV_REGISTER. Thus any listeners that inspect the netdevice get the
MTU of 0.

After ip_tunnel_newlink() corrects the MTU after registering the
netdevice, but since there's no event, the listeners don't get to know
about the MTU until something else happens--such as a NETDEV_UP event.
That's not ideal.

So instead of setting the MTU directly, go through dev_set_mtu(), which
takes care of distributing the necessary NETDEV_PRECHANGEMTU and
NETDEV_CHANGEMTU events.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 net/ipv4/ip_tunnel.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 6d21068f9b55..7b85ffad5d74 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -362,13 +362,18 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
 	struct ip_tunnel *nt;
 	struct net_device *dev;
 	int t_hlen;
+	int mtu;
+	int err;
 
 	BUG_ON(!itn->fb_tunnel_dev);
 	dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
 	if (IS_ERR(dev))
 		return ERR_CAST(dev);
 
-	dev->mtu = ip_tunnel_bind_dev(dev);
+	mtu = ip_tunnel_bind_dev(dev);
+	err = dev_set_mtu(dev, mtu);
+	if (err)
+		goto err_dev_set_mtu;
 
 	nt = netdev_priv(dev);
 	t_hlen = nt->hlen + sizeof(struct iphdr);
@@ -376,6 +381,10 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
 	dev->max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen;
 	ip_tunnel_add(itn, nt);
 	return nt;
+
+err_dev_set_mtu:
+	unregister_netdevice(dev);
+	return ERR_PTR(err);
 }
 
 int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
@@ -1102,17 +1111,24 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
 	nt->fwmark = fwmark;
 	err = register_netdevice(dev);
 	if (err)
-		goto out;
+		goto err_register_netdevice;
 
 	if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
 		eth_hw_addr_random(dev);
 
 	mtu = ip_tunnel_bind_dev(dev);
-	if (!tb[IFLA_MTU])
-		dev->mtu = mtu;
+	if (!tb[IFLA_MTU]) {
+		err = dev_set_mtu(dev, mtu);
+		if (err)
+			goto err_dev_set_mtu;
+	}
 
 	ip_tunnel_add(itn, nt);
-out:
+	return 0;
+
+err_dev_set_mtu:
+	unregister_netdevice(dev);
+err_register_netdevice:
 	return err;
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_newlink);
-- 
2.14.3

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

* [PATCH net 2/3] mlxsw: spectrum_router: Move mlxsw_sp_rif_ipip_lb_op()
  2018-03-22 17:53 [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 1/3] ip_tunnel: Emit events for post-register MTU changes Ido Schimmel
@ 2018-03-22 17:53 ` Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 3/3] mlxsw: spectrum_router: Handle MTU change of GRE netdevs Ido Schimmel
  2018-03-23 16:56 ` [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-22 17:53 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, lucien.xin, mlxsw, Petr Machata, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

Move the function so that it can be called without forward declaration
from a function that will be added in a follow-up patch.

Fixes: 0063587d3587 ("mlxsw: spectrum: Support decap-only IP-in-IP tunnels")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 54 +++++++++++-----------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index f7948e983637..a7d0adf068ec 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1380,6 +1380,33 @@ mlxsw_sp_ipip_entry_ol_up_event(struct mlxsw_sp *mlxsw_sp,
 						  decap_fib_entry);
 }
 
+static int
+mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,
+			struct mlxsw_sp_vr *ul_vr, bool enable)
+{
+	struct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config;
+	struct mlxsw_sp_rif *rif = &lb_rif->common;
+	struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;
+	char ritr_pl[MLXSW_REG_RITR_LEN];
+	u32 saddr4;
+
+	switch (lb_cf.ul_protocol) {
+	case MLXSW_SP_L3_PROTO_IPV4:
+		saddr4 = be32_to_cpu(lb_cf.saddr.addr4);
+		mlxsw_reg_ritr_pack(ritr_pl, enable, MLXSW_REG_RITR_LOOPBACK_IF,
+				    rif->rif_index, rif->vr_id, rif->dev->mtu);
+		mlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,
+			    MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
+			    ul_vr->id, saddr4, lb_cf.okey);
+		break;
+
+	case MLXSW_SP_L3_PROTO_IPV6:
+		return -EAFNOSUPPORT;
+	}
+
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);
+}
+
 static void mlxsw_sp_netdevice_ipip_ol_up_event(struct mlxsw_sp *mlxsw_sp,
 						struct net_device *ol_dev)
 {
@@ -6843,33 +6870,6 @@ mlxsw_sp_rif_ipip_lb_setup(struct mlxsw_sp_rif *rif,
 	rif_lb->lb_config = params_lb->lb_config;
 }
 
-static int
-mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,
-			struct mlxsw_sp_vr *ul_vr, bool enable)
-{
-	struct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config;
-	struct mlxsw_sp_rif *rif = &lb_rif->common;
-	struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;
-	char ritr_pl[MLXSW_REG_RITR_LEN];
-	u32 saddr4;
-
-	switch (lb_cf.ul_protocol) {
-	case MLXSW_SP_L3_PROTO_IPV4:
-		saddr4 = be32_to_cpu(lb_cf.saddr.addr4);
-		mlxsw_reg_ritr_pack(ritr_pl, enable, MLXSW_REG_RITR_LOOPBACK_IF,
-				    rif->rif_index, rif->vr_id, rif->dev->mtu);
-		mlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,
-			    MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
-			    ul_vr->id, saddr4, lb_cf.okey);
-		break;
-
-	case MLXSW_SP_L3_PROTO_IPV6:
-		return -EAFNOSUPPORT;
-	}
-
-	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);
-}
-
 static int
 mlxsw_sp_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif)
 {
-- 
2.14.3

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

* [PATCH net 3/3] mlxsw: spectrum_router: Handle MTU change of GRE netdevs
  2018-03-22 17:53 [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 1/3] ip_tunnel: Emit events for post-register MTU changes Ido Schimmel
  2018-03-22 17:53 ` [PATCH net 2/3] mlxsw: spectrum_router: Move mlxsw_sp_rif_ipip_lb_op() Ido Schimmel
@ 2018-03-22 17:53 ` Ido Schimmel
  2018-03-23 16:56 ` [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Ido Schimmel @ 2018-03-22 17:53 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, lucien.xin, mlxsw, Petr Machata, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

Update MTU of overlay loopback in accordance with the setting on the
tunnel netdevice.

Fixes: 0063587d3587 ("mlxsw: spectrum: Support decap-only IP-in-IP tunnels")
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index a7d0adf068ec..997e24dcb053 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1407,6 +1407,28 @@ mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,
 	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);
 }
 
+static int mlxsw_sp_netdevice_ipip_ol_update_mtu(struct mlxsw_sp *mlxsw_sp,
+						 struct net_device *ol_dev)
+{
+	struct mlxsw_sp_ipip_entry *ipip_entry;
+	struct mlxsw_sp_rif_ipip_lb *lb_rif;
+	struct mlxsw_sp_vr *ul_vr;
+	int err = 0;
+
+	ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev);
+	if (ipip_entry) {
+		lb_rif = ipip_entry->ol_lb;
+		ul_vr = &mlxsw_sp->router->vrs[lb_rif->ul_vr_id];
+		err = mlxsw_sp_rif_ipip_lb_op(lb_rif, ul_vr, true);
+		if (err)
+			goto out;
+		lb_rif->common.mtu = ol_dev->mtu;
+	}
+
+out:
+	return err;
+}
+
 static void mlxsw_sp_netdevice_ipip_ol_up_event(struct mlxsw_sp *mlxsw_sp,
 						struct net_device *ol_dev)
 {
@@ -1687,6 +1709,8 @@ int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
 		extack = info->extack;
 		return mlxsw_sp_netdevice_ipip_ol_change_event(mlxsw_sp,
 							       ol_dev, extack);
+	case NETDEV_CHANGEMTU:
+		return mlxsw_sp_netdevice_ipip_ol_update_mtu(mlxsw_sp, ol_dev);
 	}
 	return 0;
 }
-- 
2.14.3

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

* Re: [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels
  2018-03-22 17:53 [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels Ido Schimmel
                   ` (2 preceding siblings ...)
  2018-03-22 17:53 ` [PATCH net 3/3] mlxsw: spectrum_router: Handle MTU change of GRE netdevs Ido Schimmel
@ 2018-03-23 16:56 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-03-23 16:56 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, lucien.xin, mlxsw

From: Ido Schimmel <idosch@mellanox.com>
Date: Thu, 22 Mar 2018 19:53:32 +0200

> Petr says:
> 
> When offloading GRE tunnels, the MTU setting is kept fixed after the
> initial offload even as the slow-path configuration changed. Worse: the
> offloaded MTU setting is actually just a transient value set at the time
> of NETDEV_REGISTER of the tunnel. As of commit ffc2b6ee4174 ("ip_gre:
> fix IFLA_MTU ignored on NEWLINK"), that transient value is zero, and
> unless there's e.g. a VRF migration that prompts re-offload, it stays at
> zero, and all GRE packets end up trapping.
> 
> Thus, in patch #1, change the way the MTU is changed post-registration,
> so that the full event protocol is observed. That way the drivers get to
> see the change and have a chance to react.
> 
> In the remaining two patches, implement support for MTU change in mlxsw
> driver.

Series applied, thanks.

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

end of thread, other threads:[~2018-03-23 16:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 17:53 [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE tunnels Ido Schimmel
2018-03-22 17:53 ` [PATCH net 1/3] ip_tunnel: Emit events for post-register MTU changes Ido Schimmel
2018-03-22 17:53 ` [PATCH net 2/3] mlxsw: spectrum_router: Move mlxsw_sp_rif_ipip_lb_op() Ido Schimmel
2018-03-22 17:53 ` [PATCH net 3/3] mlxsw: spectrum_router: Handle MTU change of GRE netdevs Ido Schimmel
2018-03-23 16:56 ` [PATCH net 0/3] mlxsw: Handle changes to MTU in GRE 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).