Skip to content

Commit 69ebaed

Browse files
committed
Merge branch 'mlxsw-GRE-mtu-changes'
Ido Schimmel says: ==================== mlxsw: Handle changes to MTU in GRE tunnels 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 ffc2b6e ("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. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f36b753 + 68c3cd9 commit 69ebaed

File tree

2 files changed

+72
-32
lines changed

2 files changed

+72
-32
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,55 @@ mlxsw_sp_ipip_entry_ol_up_event(struct mlxsw_sp *mlxsw_sp,
13801380
decap_fib_entry);
13811381
}
13821382

1383+
static int
1384+
mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,
1385+
struct mlxsw_sp_vr *ul_vr, bool enable)
1386+
{
1387+
struct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config;
1388+
struct mlxsw_sp_rif *rif = &lb_rif->common;
1389+
struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;
1390+
char ritr_pl[MLXSW_REG_RITR_LEN];
1391+
u32 saddr4;
1392+
1393+
switch (lb_cf.ul_protocol) {
1394+
case MLXSW_SP_L3_PROTO_IPV4:
1395+
saddr4 = be32_to_cpu(lb_cf.saddr.addr4);
1396+
mlxsw_reg_ritr_pack(ritr_pl, enable, MLXSW_REG_RITR_LOOPBACK_IF,
1397+
rif->rif_index, rif->vr_id, rif->dev->mtu);
1398+
mlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,
1399+
MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
1400+
ul_vr->id, saddr4, lb_cf.okey);
1401+
break;
1402+
1403+
case MLXSW_SP_L3_PROTO_IPV6:
1404+
return -EAFNOSUPPORT;
1405+
}
1406+
1407+
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);
1408+
}
1409+
1410+
static int mlxsw_sp_netdevice_ipip_ol_update_mtu(struct mlxsw_sp *mlxsw_sp,
1411+
struct net_device *ol_dev)
1412+
{
1413+
struct mlxsw_sp_ipip_entry *ipip_entry;
1414+
struct mlxsw_sp_rif_ipip_lb *lb_rif;
1415+
struct mlxsw_sp_vr *ul_vr;
1416+
int err = 0;
1417+
1418+
ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev);
1419+
if (ipip_entry) {
1420+
lb_rif = ipip_entry->ol_lb;
1421+
ul_vr = &mlxsw_sp->router->vrs[lb_rif->ul_vr_id];
1422+
err = mlxsw_sp_rif_ipip_lb_op(lb_rif, ul_vr, true);
1423+
if (err)
1424+
goto out;
1425+
lb_rif->common.mtu = ol_dev->mtu;
1426+
}
1427+
1428+
out:
1429+
return err;
1430+
}
1431+
13831432
static void mlxsw_sp_netdevice_ipip_ol_up_event(struct mlxsw_sp *mlxsw_sp,
13841433
struct net_device *ol_dev)
13851434
{
@@ -1660,6 +1709,8 @@ int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
16601709
extack = info->extack;
16611710
return mlxsw_sp_netdevice_ipip_ol_change_event(mlxsw_sp,
16621711
ol_dev, extack);
1712+
case NETDEV_CHANGEMTU:
1713+
return mlxsw_sp_netdevice_ipip_ol_update_mtu(mlxsw_sp, ol_dev);
16631714
}
16641715
return 0;
16651716
}
@@ -6843,33 +6894,6 @@ mlxsw_sp_rif_ipip_lb_setup(struct mlxsw_sp_rif *rif,
68436894
rif_lb->lb_config = params_lb->lb_config;
68446895
}
68456896

6846-
static int
6847-
mlxsw_sp_rif_ipip_lb_op(struct mlxsw_sp_rif_ipip_lb *lb_rif,
6848-
struct mlxsw_sp_vr *ul_vr, bool enable)
6849-
{
6850-
struct mlxsw_sp_rif_ipip_lb_config lb_cf = lb_rif->lb_config;
6851-
struct mlxsw_sp_rif *rif = &lb_rif->common;
6852-
struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp;
6853-
char ritr_pl[MLXSW_REG_RITR_LEN];
6854-
u32 saddr4;
6855-
6856-
switch (lb_cf.ul_protocol) {
6857-
case MLXSW_SP_L3_PROTO_IPV4:
6858-
saddr4 = be32_to_cpu(lb_cf.saddr.addr4);
6859-
mlxsw_reg_ritr_pack(ritr_pl, enable, MLXSW_REG_RITR_LOOPBACK_IF,
6860-
rif->rif_index, rif->vr_id, rif->dev->mtu);
6861-
mlxsw_reg_ritr_loopback_ipip4_pack(ritr_pl, lb_cf.lb_ipipt,
6862-
MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
6863-
ul_vr->id, saddr4, lb_cf.okey);
6864-
break;
6865-
6866-
case MLXSW_SP_L3_PROTO_IPV6:
6867-
return -EAFNOSUPPORT;
6868-
}
6869-
6870-
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl);
6871-
}
6872-
68736897
static int
68746898
mlxsw_sp_rif_ipip_lb_configure(struct mlxsw_sp_rif *rif)
68756899
{

net/ipv4/ip_tunnel.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,20 +362,29 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
362362
struct ip_tunnel *nt;
363363
struct net_device *dev;
364364
int t_hlen;
365+
int mtu;
366+
int err;
365367

366368
BUG_ON(!itn->fb_tunnel_dev);
367369
dev = __ip_tunnel_create(net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
368370
if (IS_ERR(dev))
369371
return ERR_CAST(dev);
370372

371-
dev->mtu = ip_tunnel_bind_dev(dev);
373+
mtu = ip_tunnel_bind_dev(dev);
374+
err = dev_set_mtu(dev, mtu);
375+
if (err)
376+
goto err_dev_set_mtu;
372377

373378
nt = netdev_priv(dev);
374379
t_hlen = nt->hlen + sizeof(struct iphdr);
375380
dev->min_mtu = ETH_MIN_MTU;
376381
dev->max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen;
377382
ip_tunnel_add(itn, nt);
378383
return nt;
384+
385+
err_dev_set_mtu:
386+
unregister_netdevice(dev);
387+
return ERR_PTR(err);
379388
}
380389

381390
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[],
11021111
nt->fwmark = fwmark;
11031112
err = register_netdevice(dev);
11041113
if (err)
1105-
goto out;
1114+
goto err_register_netdevice;
11061115

11071116
if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
11081117
eth_hw_addr_random(dev);
11091118

11101119
mtu = ip_tunnel_bind_dev(dev);
1111-
if (!tb[IFLA_MTU])
1112-
dev->mtu = mtu;
1120+
if (!tb[IFLA_MTU]) {
1121+
err = dev_set_mtu(dev, mtu);
1122+
if (err)
1123+
goto err_dev_set_mtu;
1124+
}
11131125

11141126
ip_tunnel_add(itn, nt);
1115-
out:
1127+
return 0;
1128+
1129+
err_dev_set_mtu:
1130+
unregister_netdevice(dev);
1131+
err_register_netdevice:
11161132
return err;
11171133
}
11181134
EXPORT_SYMBOL_GPL(ip_tunnel_newlink);

0 commit comments

Comments
 (0)