Message ID | 1451923395-24533-2-git-send-email-jakub.kicinski@netronome.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Jakub Kicinski <jakub.kicinski@netronome.com> Date: Mon, 4 Jan 2016 16:03:13 +0000 > For freeing DMA buffers we depend on nfp_net.fl_bufsz having the same > value as during allocation therefore in .ndo_change_mtu we must first > free the buffers and then change the setting. > > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> > Reviewed-by: Rolf Neugebauer <rolf.neugebauer@netronome.com> The behavior implemented by this patch is not acceptable. If an error occurs reopenning the device after the MTU change, the user is left with an inoperable interface and zero feedback about what happened or why. You MUST, therefore, specifically try to allocate the new memory and resources that correspond to the new MTU value. And if you can successfully allocate everything and be guarateed to succeed, only then can you change the MTU and commit to the new resources. Otherwise you must leave the interface in exactly the state it was in prior to the MTU change call and return an error to the caller. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 43c618bafdb6..2826166547fd 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -1920,17 +1920,17 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) return -EINVAL; } + if (netif_running(netdev)) + nfp_net_netdev_close(netdev); + netdev->mtu = new_mtu; /* Freelist buffer size rounded up to the nearest 1K */ tmp = new_mtu + ETH_HLEN + VLAN_HLEN + NFP_NET_MAX_PREPEND; nn->fl_bufsz = roundup(tmp, 1024); - /* restart if running */ - if (netif_running(netdev)) { - nfp_net_netdev_close(netdev); + if (netif_running(netdev)) nfp_net_netdev_open(netdev); - } return 0; }