Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1503528 > unrolled thread

[PATCH net-next 0/6] net: use core MTU range checking everywhere

Started byJarod Wilson <jarod@redhat.com>
First post2016-10-19 04:40 +0200
Last post2016-10-20 21:00 +0200
Articles 20 on this page of 44 — 14 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next 0/6] net: use core MTU range checking everywhere Jarod Wilson <jarod@redhat.com> - 2016-10-19 04:40 +0200
    [PATCH net-next 6/6] net: use core MTU range checking in misc drivers Jarod Wilson <jarod@redhat.com> - 2016-10-19 04:40 +0200
      Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers Robin Holt <robinmholt@gmail.com> - 2016-10-19 16:40 +0200
      Re: [PATCH net-next 6/6] net: use core MTU range checking in misc  drivers Sabrina Dubroca <sd@queasysnail.net> - 2016-10-19 18:10 +0200
        Re: [PATCH net-next 6/6] net: use core MTU range checking in misc  drivers Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-20 00:50 +0200
          Re: [PATCH net-next 6/6] net: use core MTU range checking in misc  drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 05:20 +0200
            Re: [PATCH net-next 6/6] net: use core MTU range checking in misc  drivers Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-22 11:40 +0200
              Re: [PATCH net-next 6/6] net: use core MTU range checking in misc  drivers Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-22 21:00 +0200
    Re: [PATCH net-next 0/6] net: use core MTU range checking  everywhere David Miller <davem@davemloft.net> - 2016-10-19 21:20 +0200
      Re: [PATCH net-next 0/6] net: use core MTU range checking everywhere Jarod Wilson <jarod@redhat.com> - 2016-10-19 21:30 +0200
    [PATCH net-next v2 9/9] ipv4/6: use core net MTU range checking Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
    [PATCH net-next v2 3/9] net: use core MTU range checking in wireless drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
      Re: [PATCH net-next v2 3/9] net: use core MTU range checking in  wireless drivers Johannes Berg <johannes@sipsolutions.net> - 2016-10-20 20:30 +0200
        Re: [PATCH net-next v2 3/9] net: use core MTU range checking in  wireless drivers David Miller <davem@davemloft.net> - 2016-10-20 20:50 +0200
    [PATCH net-next v2 1/9] ethernet: use net core MTU range checking in more drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
    [PATCH net-next v2 4/9] net: use core MTU range checking in WAN drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
    [PATCH net-next v2 2/9] net: use core MTU range checking in USB NIC drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
    [PATCH net-next v2 0/9] net: use core MTU range checking everywhere Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
      [PATCH net-next v2 5/9] net: use core MTU range checking in core net infra Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
      [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
        RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers Haiyang Zhang <haiyangz@microsoft.com> - 2016-10-20 20:10 +0200
          RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers "Kershner, David A" <David.Kershner@unisys.com> - 2016-10-20 22:50 +0200
        Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers "Michael S. Tsirkin" <mst@redhat.com> - 2016-10-20 22:30 +0200
          Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers Jarod Wilson <jarod@redhat.com> - 2016-10-21 04:40 +0200
            Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers "Michael S. Tsirkin" <mst@redhat.com> - 2016-10-21 05:40 +0200
              Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers Aaron Conole <aconole@bytheb.org> - 2016-10-21 15:30 +0200
        Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt  drivers Wei Liu <wei.liu2@citrix.com> - 2016-10-21 12:10 +0200
      [PATCH net-next v2 8/9] s390/net: use net core MTU range checking Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
      [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers Jarod Wilson <jarod@redhat.com> - 2016-10-20 20:00 +0200
        Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers Rémi Denis-Courmont <remi@remlab.net> - 2016-10-21 09:00 +0200
        Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc  drivers Sebastian Reichel <sre@kernel.org> - 2016-10-21 18:30 +0200
        Re: [net-next,v2,7/9] net: use core MTU range checking in misc drivers Sven Eckelmann <sven@narfation.org> - 2016-10-22 09:30 +0200
        Re: [PATCH net-next v2 7/9] net: use core MTU range checking in  misc drivers Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-22 21:20 +0200
          Re: [PATCH net-next v2 7/9] net: use core MTU range checking in  misc drivers Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-22 21:30 +0200
            Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc  drivers Jarod Wilson <jarod@redhat.com> - 2016-10-23 03:20 +0200
              [PATCH net-next 1/2] firewire: net: fix maximum possible MTU Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-23 16:30 +0200
                [PATCH net-next 2/2] firewire: net: set initial MTU = 1500  unconditionally, fix IPv6 on some CardBus cards Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-23 16:40 +0200
                  Re: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500  unconditionally, fix IPv6 on some CardBus cards Jarod Wilson <jarod@redhat.com> - 2016-10-24 04:00 +0200
                    [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500  unconditionally, fix IPv6 on some CardBus cards Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-24 14:30 +0200
                      Re: [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500  unconditionally, fix IPv6 on some CardBus cards Jarod Wilson <jarod@redhat.com> - 2016-10-25 05:10 +0200
                  Re: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500  unconditionally, fix IPv6 on some CardBus cards David Miller <davem@davemloft.net> - 2016-10-26 23:40 +0200
                Re: [PATCH net-next 1/2] firewire: net: fix maximum possible MTU Jarod Wilson <jarod@redhat.com> - 2016-10-24 04:00 +0200
                Re: [PATCH net-next 1/2] firewire: net: fix maximum possible MTU David Miller <davem@davemloft.net> - 2016-10-26 23:40 +0200
      Re: [PATCH net-next v2 0/9] net: use core MTU range checking  everywhere David Miller <davem@davemloft.net> - 2016-10-20 21:00 +0200

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#1505166 — RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

FromHaiyang Zhang <haiyangz@microsoft.com>
Date2016-10-20 20:10 +0200
SubjectRE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<supWX-2CC-57@gated-at.bofh.it>
In reply to#1505154

> -----Original Message-----
> From: Jarod Wilson [mailto:jarod@redhat.com]
> Sent: Thursday, October 20, 2016 1:55 PM
> To: linux-kernel@vger.kernel.org
> Cc: Jarod Wilson <jarod@redhat.com>; netdev@vger.kernel.org;
> virtualization@lists.linux-foundation.org; KY Srinivasan
> <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>; Michael S.
> Tsirkin <mst@redhat.com>; Shrikrishna Khare <skhare@vmware.com>; VMware,
> Inc. <pv-drivers@vmware.com>; Wei Liu <wei.liu2@citrix.com>; Paul
> Durrant <paul.durrant@citrix.com>; David Kershner
> <david.kershner@unisys.com>
> Subject: [PATCH net-next v2 6/9] net: use core MTU range checking in
> virt drivers
> 
> hyperv_net:
> - set min/max_mtu, per Haiyang, after rndis_filter_device_add
> 
> virtio_net:
> - set min/max_mtu
> - remove virtnet_change_mtu
> 
> vmxnet3:
> - set min/max_mtu
> 
> xen-netback:
> - min_mtu = 0, max_mtu = 65517
> 
> xen-netfront:
> - min_mtu = 0, max_mtu = 65535
> 
> unisys/visor:
> - clean up defines a little to not clash with network core or add
>   redundat definitions
> 
> CC: netdev@vger.kernel.org
> CC: virtualization@lists.linux-foundation.org
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Shrikrishna Khare <skhare@vmware.com>
> CC: "VMware, Inc." <pv-drivers@vmware.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Paul Durrant <paul.durrant@citrix.com>
> CC: David Kershner <david.kershner@unisys.com>
> Signed-off-by: Jarod Wilson <jarod@redhat.com>
> ---

The hv_netvsc changes look fine. Thanks.

Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>

[toc] | [prev] | [next] | [standalone]


#1505249 — RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

From"Kershner, David A" <David.Kershner@unisys.com>
Date2016-10-20 22:50 +0200
SubjectRE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<susrM-45X-17@gated-at.bofh.it>
In reply to#1505166

> -----Original Message-----
> From: Haiyang Zhang [mailto:haiyangz@microsoft.com]
> Sent: Thursday, October 20, 2016 2:05 PM
> To: Jarod Wilson <jarod@redhat.com>; linux-kernel@vger.kernel.org
> Cc: netdev@vger.kernel.org; virtualization@lists.linux-foundation.org; KY
> Srinivasan <kys@microsoft.com>; Michael S. Tsirkin <mst@redhat.com>;
> Shrikrishna Khare <skhare@vmware.com>; VMware, Inc. <pv-
> drivers@vmware.com>; Wei Liu <wei.liu2@citrix.com>; Paul Durrant
> <paul.durrant@citrix.com>; Kershner, David A
> <David.Kershner@unisys.com>
> Subject: RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt
> drivers
> 
> 
> 
> > -----Original Message-----
> > From: Jarod Wilson [mailto:jarod@redhat.com]
> > Sent: Thursday, October 20, 2016 1:55 PM
> > To: linux-kernel@vger.kernel.org
> > Cc: Jarod Wilson <jarod@redhat.com>; netdev@vger.kernel.org;
> > virtualization@lists.linux-foundation.org; KY Srinivasan
> > <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>;
> Michael S.
> > Tsirkin <mst@redhat.com>; Shrikrishna Khare <skhare@vmware.com>;
> VMware,
> > Inc. <pv-drivers@vmware.com>; Wei Liu <wei.liu2@citrix.com>; Paul
> > Durrant <paul.durrant@citrix.com>; David Kershner
> > <david.kershner@unisys.com>
> > Subject: [PATCH net-next v2 6/9] net: use core MTU range checking in
> > virt drivers
> >
> > hyperv_net:
> > - set min/max_mtu, per Haiyang, after rndis_filter_device_add
> >
> > virtio_net:
> > - set min/max_mtu
> > - remove virtnet_change_mtu
> >
> > vmxnet3:
> > - set min/max_mtu
> >
> > xen-netback:
> > - min_mtu = 0, max_mtu = 65517
> >
> > xen-netfront:
> > - min_mtu = 0, max_mtu = 65535
> >
> > unisys/visor:
> > - clean up defines a little to not clash with network core or add
> >   redundat definitions
> >
> > CC: netdev@vger.kernel.org
> > CC: virtualization@lists.linux-foundation.org
> > CC: "K. Y. Srinivasan" <kys@microsoft.com>
> > CC: Haiyang Zhang <haiyangz@microsoft.com>
> > CC: "Michael S. Tsirkin" <mst@redhat.com>
> > CC: Shrikrishna Khare <skhare@vmware.com>
> > CC: "VMware, Inc." <pv-drivers@vmware.com>
> > CC: Wei Liu <wei.liu2@citrix.com>
> > CC: Paul Durrant <paul.durrant@citrix.com>
> > CC: David Kershner <david.kershner@unisys.com>
> > Signed-off-by: Jarod Wilson <jarod@redhat.com>
> > ---
> 
> The hv_netvsc changes look fine. Thanks.
> 
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
> 

The visornic changes look good.

Reviewed-by: David Kershner <david.kershner@unisys.com>


 

[toc] | [prev] | [next] | [standalone]


#1505236 — Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

From"Michael S. Tsirkin" <mst@redhat.com>
Date2016-10-20 22:30 +0200
SubjectRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<sus8p-3Z6-7@gated-at.bofh.it>
In reply to#1505154
On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
> hyperv_net:
> - set min/max_mtu, per Haiyang, after rndis_filter_device_add
> 
> virtio_net:
> - set min/max_mtu
> - remove virtnet_change_mtu
> vmxnet3:
> - set min/max_mtu
> 
> xen-netback:
> - min_mtu = 0, max_mtu = 65517
> 
> xen-netfront:
> - min_mtu = 0, max_mtu = 65535
> 
> unisys/visor:
> - clean up defines a little to not clash with network core or add
>   redundat definitions
> 
> CC: netdev@vger.kernel.org
> CC: virtualization@lists.linux-foundation.org
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Shrikrishna Khare <skhare@vmware.com>
> CC: "VMware, Inc." <pv-drivers@vmware.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Paul Durrant <paul.durrant@citrix.com>
> CC: David Kershner <david.kershner@unisys.com>
> Signed-off-by: Jarod Wilson <jarod@redhat.com>
> ---
>  drivers/net/hyperv/hyperv_net.h                 |  4 ++--
>  drivers/net/hyperv/netvsc_drv.c                 | 14 +++++++-------
>  drivers/net/virtio_net.c                        | 23 ++++++++++-------------
>  drivers/net/vmxnet3/vmxnet3_drv.c               |  7 ++++---
>  drivers/net/xen-netback/interface.c             |  5 ++++-
>  drivers/net/xen-netfront.c                      |  2 ++
>  drivers/staging/unisys/include/iochannel.h      | 10 ++++------
>  drivers/staging/unisys/visornic/visornic_main.c |  4 ++--
>  8 files changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
> index f4fbcb5..3958ada 100644
> --- a/drivers/net/hyperv/hyperv_net.h
> +++ b/drivers/net/hyperv/hyperv_net.h
> @@ -606,8 +606,8 @@ struct nvsp_message {
>  } __packed;
>  
>  
> -#define NETVSC_MTU 65536
> -#define NETVSC_MTU_MIN 68
> +#define NETVSC_MTU 65535
> +#define NETVSC_MTU_MIN ETH_MIN_MTU
>  
>  #define NETVSC_RECEIVE_BUFFER_SIZE		(1024*1024*16)	/* 16MB */
>  #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY	(1024*1024*15)  /* 15MB */
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index f0919bd..3b28cf1 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
>  	struct netvsc_device *nvdev = ndevctx->nvdev;
>  	struct hv_device *hdev = ndevctx->device_ctx;
>  	struct netvsc_device_info device_info;
> -	int limit = ETH_DATA_LEN;
>  	u32 num_chn;
>  	int ret = 0;
>  
>  	if (ndevctx->start_remove || !nvdev || nvdev->destroy)
>  		return -ENODEV;
>  
> -	if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
> -		limit = NETVSC_MTU - ETH_HLEN;
> -
> -	if (mtu < NETVSC_MTU_MIN || mtu > limit)
> -		return -EINVAL;
> -
>  	ret = netvsc_close(ndev);
>  	if (ret)
>  		goto out;
> @@ -1402,6 +1395,13 @@ static int netvsc_probe(struct hv_device *dev,
>  	netif_set_real_num_tx_queues(net, nvdev->num_chn);
>  	netif_set_real_num_rx_queues(net, nvdev->num_chn);
>  
> +	/* MTU range: 68 - 1500 or 65521 */
> +	net->min_mtu = NETVSC_MTU_MIN;
> +	if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
> +		net->max_mtu = NETVSC_MTU - ETH_HLEN;
> +	else
> +		net->max_mtu = ETH_DATA_LEN;
> +
>  	ret = register_netdev(net);
>  	if (ret != 0) {
>  		pr_err("Unable to register netdev.\n");
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fad84f3..720809f 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
>  	.set_settings = virtnet_set_settings,
>  };
>  
> -#define MIN_MTU 68
> -#define MAX_MTU 65535
> -
> -static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
> -{
> -	if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
> -		return -EINVAL;
> -	dev->mtu = new_mtu;
> -	return 0;
> -}
> -
>  static const struct net_device_ops virtnet_netdev = {
>  	.ndo_open            = virtnet_open,
>  	.ndo_stop   	     = virtnet_close,
> @@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = {
>  	.ndo_validate_addr   = eth_validate_addr,
>  	.ndo_set_mac_address = virtnet_set_mac_address,
>  	.ndo_set_rx_mode     = virtnet_set_rx_mode,
> -	.ndo_change_mtu	     = virtnet_change_mtu,
>  	.ndo_get_stats64     = virtnet_stats,
>  	.ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
>  	.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
> @@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
>  	return true;
>  }
>  
> +#define MIN_MTU ETH_MIN_MTU
> +#define MAX_MTU ETH_MAX_MTU
> +

Can we drop these btw?

>  static int virtnet_probe(struct virtio_device *vdev)
>  {
>  	int i, err;
> @@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>  
>  	dev->vlan_features = dev->features;
>  
> +	/* MTU range: 68 - 65535 */
> +	dev->min_mtu = MIN_MTU;
> +	dev->max_mtu = MAX_MTU;
> +
>  	/* Configuration may specify what MAC to use.  Otherwise random. */
>  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
>  		virtio_cread_bytes(vdev,
> @@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>  		mtu = virtio_cread16(vdev,
>  				     offsetof(struct virtio_net_config,
>  					      mtu));
> -		if (virtnet_change_mtu(dev, mtu))
> +		if (mtu < dev->min_mtu || mtu > dev->max_mtu)

In fact the > max_mtu branch does not make sense since a 16 bit
value can't exceed MAX_MTU.

>  			__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
> +		else
> +			dev->mtu = mtu;
>  	}
>  
>  	if (vi->any_header_sg)
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index b5554f2..0c36de1 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)
>  	struct vmxnet3_adapter *adapter = netdev_priv(netdev);
>  	int err = 0;
>  
> -	if (new_mtu < VMXNET3_MIN_MTU || new_mtu > VMXNET3_MAX_MTU)
> -		return -EINVAL;
> -
>  	netdev->mtu = new_mtu;
>  
>  	/*
> @@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,
>  	vmxnet3_set_ethtool_ops(netdev);
>  	netdev->watchdog_timeo = 5 * HZ;
>  
> +	/* MTU range: 60 - 9000 */
> +	netdev->min_mtu = VMXNET3_MIN_MTU;
> +	netdev->max_mtu = VMXNET3_MAX_MTU;
> +
>  	INIT_WORK(&adapter->work, vmxnet3_reset_work);
>  	set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state);
>  
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index 74dc2bf..e30ffd2 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -302,7 +302,7 @@ static int xenvif_close(struct net_device *dev)
>  static int xenvif_change_mtu(struct net_device *dev, int mtu)
>  {
>  	struct xenvif *vif = netdev_priv(dev);
> -	int max = vif->can_sg ? 65535 - VLAN_ETH_HLEN : ETH_DATA_LEN;
> +	int max = vif->can_sg ? ETH_MAX_MTU - VLAN_ETH_HLEN : ETH_DATA_LEN;
>  
>  	if (mtu > max)
>  		return -EINVAL;
> @@ -471,6 +471,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
>  
>  	dev->tx_queue_len = XENVIF_QUEUE_LENGTH;
>  
> +	dev->min_mtu = 0;
> +	dev->max_mtu = ETH_MAX_MTU - VLAN_ETH_HLEN;
> +
>  	/*
>  	 * Initialise a dummy MAC address. We choose the numerically
>  	 * largest non-broadcast address to prevent the address getting
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index e17879d..7d616b0 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1329,6 +1329,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
>  	netdev->features |= netdev->hw_features;
>  
>  	netdev->ethtool_ops = &xennet_ethtool_ops;
> +	netdev->min_mtu = 0;
> +	netdev->max_mtu = XEN_NETIF_MAX_TX_SIZE;
>  	SET_NETDEV_DEV(netdev, &dev->dev);
>  
>  	np->netdev = netdev;
> diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h
> index cba4433..9081b3f 100644
> --- a/drivers/staging/unisys/include/iochannel.h
> +++ b/drivers/staging/unisys/include/iochannel.h
> @@ -113,12 +113,10 @@ enum net_types {
>  
>  };
>  
> -#define		ETH_HEADER_SIZE 14	/* size of ethernet header */
> -
>  #define		ETH_MIN_DATA_SIZE 46	/* minimum eth data size */
> -#define		ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE)
> +#define		ETH_MIN_PACKET_SIZE (ETH_HLEN + ETH_MIN_DATA_SIZE)
>  
> -#define		ETH_MAX_MTU 16384	/* maximum data size */
> +#define		VISOR_ETH_MAX_MTU 16384	/* maximum data size */
>  
>  #ifndef MAX_MACADDR_LEN
>  #define MAX_MACADDR_LEN 6	/* number of bytes in MAC address */
> @@ -288,7 +286,7 @@ struct net_pkt_xmt {
>  	int len;	/* full length of data in the packet */
>  	int num_frags;	/* number of fragments in frags containing data */
>  	struct phys_info frags[MAX_PHYS_INFO];	/* physical page information */
> -	char ethhdr[ETH_HEADER_SIZE];	/* the ethernet header  */
> +	char ethhdr[ETH_HLEN];	/* the ethernet header  */
>  	struct {
>  		/* these are needed for csum at uisnic end */
>  		u8 valid;	/* 1 = struct is valid - else ignore */
> @@ -323,7 +321,7 @@ struct net_pkt_xmtdone {
>   */
>  #define RCVPOST_BUF_SIZE 4032
>  #define MAX_NET_RCV_CHAIN \
> -	((ETH_MAX_MTU + ETH_HEADER_SIZE + RCVPOST_BUF_SIZE - 1) \
> +	((VISOR_ETH_MAX_MTU + ETH_HLEN + RCVPOST_BUF_SIZE - 1) \
>  	/ RCVPOST_BUF_SIZE)
>  
>  struct net_pkt_rcvpost {
> diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
> index 1367007..f8a584b 100644
> --- a/drivers/staging/unisys/visornic/visornic_main.c
> +++ b/drivers/staging/unisys/visornic/visornic_main.c
> @@ -791,7 +791,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
>  	 * pointing to
>  	 */
>  	firstfraglen = skb->len - skb->data_len;
> -	if (firstfraglen < ETH_HEADER_SIZE) {
> +	if (firstfraglen < ETH_HLEN) {
>  		spin_unlock_irqrestore(&devdata->priv_lock, flags);
>  		devdata->busy_cnt++;
>  		dev_err(&netdev->dev,
> @@ -864,7 +864,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)
>  	/* copy ethernet header from first frag into ocmdrsp
>  	 * - everything else will be pass in frags & DMA'ed
>  	 */
> -	memcpy(cmdrsp->net.xmt.ethhdr, skb->data, ETH_HEADER_SIZE);
> +	memcpy(cmdrsp->net.xmt.ethhdr, skb->data, ETH_HLEN);
>  	/* copy frags info - from skb->data we need to only provide access
>  	 * beyond eth header
>  	 */
> -- 
> 2.10.0

[toc] | [prev] | [next] | [standalone]


#1505393 — Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

FromJarod Wilson <jarod@redhat.com>
Date2016-10-21 04:40 +0200
SubjectRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<suxUu-7SK-11@gated-at.bofh.it>
In reply to#1505236
On Thu, Oct 20, 2016 at 11:23:54PM +0300, Michael S. Tsirkin wrote:
> On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
...
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index fad84f3..720809f 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
> >  	.set_settings = virtnet_set_settings,
> >  };
> >  
> > -#define MIN_MTU 68
> > -#define MAX_MTU 65535
> > -
> > -static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
> > -{
> > -	if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
> > -		return -EINVAL;
> > -	dev->mtu = new_mtu;
> > -	return 0;
> > -}
> > -
> >  static const struct net_device_ops virtnet_netdev = {
> >  	.ndo_open            = virtnet_open,
> >  	.ndo_stop   	     = virtnet_close,
> > @@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = {
> >  	.ndo_validate_addr   = eth_validate_addr,
> >  	.ndo_set_mac_address = virtnet_set_mac_address,
> >  	.ndo_set_rx_mode     = virtnet_set_rx_mode,
> > -	.ndo_change_mtu	     = virtnet_change_mtu,
> >  	.ndo_get_stats64     = virtnet_stats,
> >  	.ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
> >  	.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
> > @@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
> >  	return true;
> >  }
> >  
> > +#define MIN_MTU ETH_MIN_MTU
> > +#define MAX_MTU ETH_MAX_MTU
> > +
> 
> Can we drop these btw?

Bah. Yeah. Should have just used them directly. I didn't add ETH_MAX_MTU
until after doing the virtio_net changes, so I missed that.

> >  static int virtnet_probe(struct virtio_device *vdev)
> >  {
> >  	int i, err;
> > @@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> >  
> >  	dev->vlan_features = dev->features;
> >  
> > +	/* MTU range: 68 - 65535 */
> > +	dev->min_mtu = MIN_MTU;
> > +	dev->max_mtu = MAX_MTU;
> > +
> >  	/* Configuration may specify what MAC to use.  Otherwise random. */
> >  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
> >  		virtio_cread_bytes(vdev,
> > @@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> >  		mtu = virtio_cread16(vdev,
> >  				     offsetof(struct virtio_net_config,
> >  					      mtu));
> > -		if (virtnet_change_mtu(dev, mtu))
> > +		if (mtu < dev->min_mtu || mtu > dev->max_mtu)
> 
> In fact the > max_mtu branch does not make sense since a 16 bit
> value can't exceed MAX_MTU.

Hm. mtu is declared as an int, not sure if there's any sort of type
promotion to be worried about (not an area I know much/anything about).
Certainly something that could be looked into as a minor optimization,
though it's only in a probe path and shouldn't hurt anything, so ... meh?

-- 
Jarod Wilson
jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


#1505453 — Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

From"Michael S. Tsirkin" <mst@redhat.com>
Date2016-10-21 05:40 +0200
SubjectRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<suyQx-8rm-13@gated-at.bofh.it>
In reply to#1505393
On Thu, Oct 20, 2016 at 10:37:20PM -0400, Jarod Wilson wrote:
> On Thu, Oct 20, 2016 at 11:23:54PM +0300, Michael S. Tsirkin wrote:
> > On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
> ...
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index fad84f3..720809f 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
> > >  	.set_settings = virtnet_set_settings,
> > >  };
> > >  
> > > -#define MIN_MTU 68
> > > -#define MAX_MTU 65535
> > > -
> > > -static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
> > > -{
> > > -	if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
> > > -		return -EINVAL;
> > > -	dev->mtu = new_mtu;
> > > -	return 0;
> > > -}
> > > -
> > >  static const struct net_device_ops virtnet_netdev = {
> > >  	.ndo_open            = virtnet_open,
> > >  	.ndo_stop   	     = virtnet_close,
> > > @@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = {
> > >  	.ndo_validate_addr   = eth_validate_addr,
> > >  	.ndo_set_mac_address = virtnet_set_mac_address,
> > >  	.ndo_set_rx_mode     = virtnet_set_rx_mode,
> > > -	.ndo_change_mtu	     = virtnet_change_mtu,
> > >  	.ndo_get_stats64     = virtnet_stats,
> > >  	.ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
> > >  	.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
> > > @@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
> > >  	return true;
> > >  }
> > >  
> > > +#define MIN_MTU ETH_MIN_MTU
> > > +#define MAX_MTU ETH_MAX_MTU
> > > +
> > 
> > Can we drop these btw?
> 
> Bah. Yeah. Should have just used them directly. I didn't add ETH_MAX_MTU
> until after doing the virtio_net changes, so I missed that.
> 
> > >  static int virtnet_probe(struct virtio_device *vdev)
> > >  {
> > >  	int i, err;
> > > @@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> > >  
> > >  	dev->vlan_features = dev->features;
> > >  
> > > +	/* MTU range: 68 - 65535 */
> > > +	dev->min_mtu = MIN_MTU;
> > > +	dev->max_mtu = MAX_MTU;
> > > +
> > >  	/* Configuration may specify what MAC to use.  Otherwise random. */
> > >  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
> > >  		virtio_cread_bytes(vdev,
> > > @@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev)
> > >  		mtu = virtio_cread16(vdev,
> > >  				     offsetof(struct virtio_net_config,
> > >  					      mtu));
> > > -		if (virtnet_change_mtu(dev, mtu))
> > > +		if (mtu < dev->min_mtu || mtu > dev->max_mtu)
> > 
> > In fact the > max_mtu branch does not make sense since a 16 bit
> > value can't exceed MAX_MTU.
> 
> Hm. mtu is declared as an int, not sure if there's any sort of type
> promotion to be worried about (not an area I know much/anything about).

Not by design, that's for sure.

> Certainly something that could be looked into as a minor optimization,
> though it's only in a probe path and shouldn't hurt anything, so ... meh?

Right. Aaron said he's working on a patch that essentially does
dev->max_mtu = mtu after validation, so this part will look
a bit silly there.

> -- 
> Jarod Wilson
> jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


#1505932 — Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

FromAaron Conole <aconole@bytheb.org>
Date2016-10-21 15:30 +0200
SubjectRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<suI3v-63W-7@gated-at.bofh.it>
In reply to#1505453
"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Thu, Oct 20, 2016 at 10:37:20PM -0400, Jarod Wilson wrote:
>> On Thu, Oct 20, 2016 at 11:23:54PM +0300, Michael S. Tsirkin wrote:
>> > On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
>> ...
>> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> > > index fad84f3..720809f 100644
>> > > --- a/drivers/net/virtio_net.c
>> > > +++ b/drivers/net/virtio_net.c
>> > > @@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
>> > >  	.set_settings = virtnet_set_settings,
>> > >  };
>> > >  
>> > > -#define MIN_MTU 68
>> > > -#define MAX_MTU 65535
>> > > -
>> > > -static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
>> > > -{
>> > > -	if (new_mtu < MIN_MTU || new_mtu > MAX_MTU)
>> > > -		return -EINVAL;
>> > > -	dev->mtu = new_mtu;
>> > > -	return 0;
>> > > -}
>> > > -
>> > >  static const struct net_device_ops virtnet_netdev = {
>> > >  	.ndo_open            = virtnet_open,
>> > >  	.ndo_stop   	     = virtnet_close,
>> > > @@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = {
>> > >  	.ndo_validate_addr   = eth_validate_addr,
>> > >  	.ndo_set_mac_address = virtnet_set_mac_address,
>> > >  	.ndo_set_rx_mode     = virtnet_set_rx_mode,
>> > > -	.ndo_change_mtu	     = virtnet_change_mtu,
>> > >  	.ndo_get_stats64     = virtnet_stats,
>> > >  	.ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
>> > >  	.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
>> > > @@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
>> > >  	return true;
>> > >  }
>> > >  
>> > > +#define MIN_MTU ETH_MIN_MTU
>> > > +#define MAX_MTU ETH_MAX_MTU
>> > > +
>> > 
>> > Can we drop these btw?
>> 
>> Bah. Yeah. Should have just used them directly. I didn't add ETH_MAX_MTU
>> until after doing the virtio_net changes, so I missed that.
>> 
>> > >  static int virtnet_probe(struct virtio_device *vdev)
>> > >  {
>> > >  	int i, err;
>> > > @@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>> > >  
>> > >  	dev->vlan_features = dev->features;
>> > >  
>> > > +	/* MTU range: 68 - 65535 */
>> > > +	dev->min_mtu = MIN_MTU;
>> > > +	dev->max_mtu = MAX_MTU;
>> > > +
>> > >  	/* Configuration may specify what MAC to use.  Otherwise random. */
>> > >  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
>> > >  		virtio_cread_bytes(vdev,
>> > > @@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>> > >  		mtu = virtio_cread16(vdev,
>> > >  				     offsetof(struct virtio_net_config,
>> > >  					      mtu));
>> > > -		if (virtnet_change_mtu(dev, mtu))
>> > > +		if (mtu < dev->min_mtu || mtu > dev->max_mtu)
>> > 
>> > In fact the > max_mtu branch does not make sense since a 16 bit
>> > value can't exceed MAX_MTU.
>> 
>> Hm. mtu is declared as an int, not sure if there's any sort of type
>> promotion to be worried about (not an area I know much/anything about).
>
> Not by design, that's for sure.

If you're really worried, we could declare it as a u16. The value
returned from virtio_cread16 is type u16, and there are no type
promotion rules I'm aware of that would do the wrong thing there.

>> Certainly something that could be looked into as a minor optimization,
>> though it's only in a probe path and shouldn't hurt anything, so ... meh?
>
> Right. Aaron said he's working on a patch that essentially does
> dev->max_mtu = mtu after validation, so this part will look
> a bit silly there.

Agreed, but I can do that in my patch if you don't want the extra churn.

-Aaron

[toc] | [prev] | [next] | [standalone]


#1505751 — Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers

FromWei Liu <wei.liu2@citrix.com>
Date2016-10-21 12:10 +0200
SubjectRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Message-ID<suEVX-45D-1@gated-at.bofh.it>
In reply to#1505154
On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
> hyperv_net:
> - set min/max_mtu, per Haiyang, after rndis_filter_device_add
> 
> virtio_net:
> - set min/max_mtu
> - remove virtnet_change_mtu
> 
> vmxnet3:
> - set min/max_mtu
> 
> xen-netback:
> - min_mtu = 0, max_mtu = 65517
> 
> xen-netfront:
> - min_mtu = 0, max_mtu = 65535
> 
> unisys/visor:
> - clean up defines a little to not clash with network core or add
>   redundat definitions
> 
> CC: netdev@vger.kernel.org
> CC: virtualization@lists.linux-foundation.org
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Shrikrishna Khare <skhare@vmware.com>
> CC: "VMware, Inc." <pv-drivers@vmware.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Paul Durrant <paul.durrant@citrix.com>
> CC: David Kershner <david.kershner@unisys.com>
> Signed-off-by: Jarod Wilson <jarod@redhat.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

[toc] | [prev] | [next] | [standalone]


#1505155 — [PATCH net-next v2 8/9] s390/net: use net core MTU range checking

FromJarod Wilson <jarod@redhat.com>
Date2016-10-20 20:00 +0200
Subject[PATCH net-next v2 8/9] s390/net: use net core MTU range checking
Message-ID<supNh-2j8-55@gated-at.bofh.it>
In reply to#1505152
ctcm:
- min_mtu = 576, max_mtu = 65527

netiucv:
- min_mtu = 576, max_mtu = 65535

qeth:
- min_mtu = 64, max_mtu = 65535

CC: netdev@vger.kernel.org
CC: linux-s390@vger.kernel.org
CC: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/s390/net/ctcm_main.c      |  5 ++---
 drivers/s390/net/netiucv.c        | 24 ++----------------------
 drivers/s390/net/qeth_core_main.c |  4 ----
 drivers/s390/net/qeth_l2_main.c   |  2 ++
 drivers/s390/net/qeth_l3_main.c   |  2 ++
 5 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
index ad17fc5..ac65f12 100644
--- a/drivers/s390/net/ctcm_main.c
+++ b/drivers/s390/net/ctcm_main.c
@@ -1032,9 +1032,6 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu)
 	struct ctcm_priv *priv;
 	int max_bufsize;
 
-	if (new_mtu < 576 || new_mtu > 65527)
-		return -EINVAL;
-
 	priv = dev->ml_priv;
 	max_bufsize = priv->channel[CTCM_READ]->max_bufsize;
 
@@ -1123,6 +1120,8 @@ void static ctcm_dev_setup(struct net_device *dev)
 	dev->type = ARPHRD_SLIP;
 	dev->tx_queue_len = 100;
 	dev->flags = IFF_POINTOPOINT | IFF_NOARP;
+	dev->min_mtu = 576;
+	dev->max_mtu = 65527;
 }
 
 /*
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 2f0f391..2981024 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1428,27 +1428,6 @@ static struct net_device_stats *netiucv_stats (struct net_device * dev)
 	return &priv->stats;
 }
 
-/**
- * netiucv_change_mtu
- * @dev: Pointer to interface struct.
- * @new_mtu: The new MTU to use for this interface.
- *
- * Sets MTU of an interface.
- *
- * Returns 0 on success, -EINVAL if MTU is out of valid range.
- *         (valid range is 576 .. NETIUCV_MTU_MAX).
- */
-static int netiucv_change_mtu(struct net_device * dev, int new_mtu)
-{
-	IUCV_DBF_TEXT(trace, 3, __func__);
-	if (new_mtu < 576 || new_mtu > NETIUCV_MTU_MAX) {
-		IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n");
-		return -EINVAL;
-	}
-	dev->mtu = new_mtu;
-	return 0;
-}
-
 /*
  * attributes in sysfs
  */
@@ -1986,12 +1965,13 @@ static const struct net_device_ops netiucv_netdev_ops = {
 	.ndo_stop		= netiucv_close,
 	.ndo_get_stats		= netiucv_stats,
 	.ndo_start_xmit		= netiucv_tx,
-	.ndo_change_mtu	   	= netiucv_change_mtu,
 };
 
 static void netiucv_setup_netdevice(struct net_device *dev)
 {
 	dev->mtu	         = NETIUCV_MTU_DEFAULT;
+	dev->min_mtu		 = 576;
+	dev->max_mtu		 = NETIUCV_MTU_MAX;
 	dev->destructor          = netiucv_free_netdevice;
 	dev->hard_header_len     = NETIUCV_HDRLEN;
 	dev->addr_len            = 0;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 20cf296..e335583 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -4202,10 +4202,6 @@ int qeth_change_mtu(struct net_device *dev, int new_mtu)
 	sprintf(dbf_text, "%8x", new_mtu);
 	QETH_CARD_TEXT(card, 4, dbf_text);
 
-	if (new_mtu < 64)
-		return -EINVAL;
-	if (new_mtu > 65535)
-		return -EINVAL;
 	if ((!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) &&
 	    (!qeth_mtu_is_valid(card, new_mtu)))
 		return -EINVAL;
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index bb27058..9c921c28 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1107,6 +1107,8 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
 	card->dev->ml_priv = card;
 	card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
 	card->dev->mtu = card->info.initial_mtu;
+	card->dev->min_mtu = 64;
+	card->dev->max_mtu = ETH_MAX_MTU;
 	card->dev->netdev_ops = &qeth_l2_netdev_ops;
 	card->dev->ethtool_ops =
 		(card->info.type != QETH_CARD_TYPE_OSN) ?
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 272d9e7..ac37d05 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3140,6 +3140,8 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
 	card->dev->ml_priv = card;
 	card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
 	card->dev->mtu = card->info.initial_mtu;
+	card->dev->min_mtu = 64;
+	card->dev->max_mtu = ETH_MAX_MTU;
 	card->dev->ethtool_ops = &qeth_l3_ethtool_ops;
 	card->dev->features |=	NETIF_F_HW_VLAN_CTAG_TX |
 				NETIF_F_HW_VLAN_CTAG_RX |
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1505156 — [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromJarod Wilson <jarod@redhat.com>
Date2016-10-20 20:00 +0200
Subject[PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<supNg-2j8-41@gated-at.bofh.it>
In reply to#1505152
firewire-net:
- set min/max_mtu
- remove fwnet_change_mtu

nes:
- set max_mtu
- clean up nes_netdev_change_mtu

xpnet:
- set min/max_mtu
- remove xpnet_dev_change_mtu

hippi:
- set min/max_mtu
- remove hippi_change_mtu

batman-adv:
- set max_mtu
- remove batadv_interface_change_mtu
- initialization is a little async, not 100% certain that max_mtu is set
  in the optimal place, don't have hardware to test with

rionet:
- set min/max_mtu
- remove rionet_change_mtu

slip:
- set min/max_mtu
- streamline sl_change_mtu

um/net_kern:
- remove pointless ndo_change_mtu

hsi/clients/ssi_protocol:
- use core MTU range checking
- remove now redundant ssip_pn_set_mtu

ipoib:
- set a default max MTU value
- Note: ipoib's actual max MTU can vary, depending on if the device is in
  connected mode or not, so we'll just set the max_mtu value to the max
  possible, and let the ndo_change_mtu function continue to validate any new
  MTU change requests with checks for CM or not. Note that ipoib has no
  min_mtu set, and thus, the network core's mtu > 0 check is the only lower
  bounds here.

mptlan:
- use net core MTU range checking
- remove now redundant mpt_lan_change_mtu

fddi:
- min_mtu = 21, max_mtu = 4470
- remove now redundant fddi_change_mtu (including export)

fjes:
- min_mtu = 8192, max_mtu = 65536
- The max_mtu value is actually one over IP_MAX_MTU here, but the idea is to
  get past the core net MTU range checks so fjes_change_mtu can validate a
  new MTU against what it supports (see fjes_support_mtu in fjes_hw.c)

hsr:
- min_mtu = 0 (calls ether_setup, max_mtu is 1500)

f_phonet:
- min_mtu = 6, max_mtu = 65541

u_ether:
- min_mtu = 14, max_mtu = 15412

phonet/pep-gprs:
- min_mtu = 576, max_mtu = 65530
- remove redundant gprs_set_mtu

CC: netdev@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: Stefan Richter <stefanr@s5r6.in-berlin.de>
CC: Faisal Latif <faisal.latif@intel.com>
CC: linux-rdma@vger.kernel.org
CC: Cliff Whickman <cpw@sgi.com>
CC: Robin Holt <robinmholt@gmail.com>
CC: Jes Sorensen <jes@trained-monkey.org>
CC: Marek Lindner <mareklindner@neomailbox.ch>
CC: Simon Wunderlich <sw@simonwunderlich.de>
CC: Antonio Quartulli <a@unstable.cc>
CC: Sathya Prakash <sathya.prakash@broadcom.com>
CC: Chaitra P B <chaitra.basappa@broadcom.com>
CC: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
CC: MPT-FusionLinux.pdl@broadcom.com
CC: Sebastian Reichel <sre@kernel.org>
CC: Felipe Balbi <balbi@kernel.org>
CC: Arvid Brodin <arvid.brodin@alten.se>
CC: Remi Denis-Courmont <courmisch@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 arch/um/drivers/net_kern.c                |  8 --------
 drivers/firewire/net.c                    | 18 ++++--------------
 drivers/hsi/clients/ssi_protocol.c        | 14 ++++----------
 drivers/infiniband/hw/nes/nes.c           |  1 -
 drivers/infiniband/hw/nes/nes.h           |  4 ++--
 drivers/infiniband/hw/nes/nes_nic.c       | 10 +++-------
 drivers/infiniband/ulp/ipoib/ipoib_main.c |  1 +
 drivers/message/fusion/mptlan.c           | 15 ++++-----------
 drivers/misc/sgi-xp/xpnet.c               | 21 ++++-----------------
 drivers/net/fddi/skfp/skfddi.c            |  1 -
 drivers/net/fjes/fjes_main.c              |  2 ++
 drivers/net/hippi/rrunner.c               |  1 -
 drivers/net/rionet.c                      | 15 +++------------
 drivers/net/slip/slip.c                   | 11 +++++------
 drivers/usb/gadget/function/f_phonet.c    | 11 ++---------
 drivers/usb/gadget/function/u_ether.c     | 14 ++++----------
 include/linux/fddidevice.h                |  1 -
 include/linux/hippidevice.h               |  1 -
 net/802/fddi.c                            | 11 ++---------
 net/802/hippi.c                           | 14 ++------------
 net/batman-adv/soft-interface.c           | 13 +------------
 net/hsr/hsr_device.c                      |  1 +
 net/phonet/pep-gprs.c                     | 12 ++----------
 23 files changed, 46 insertions(+), 154 deletions(-)

diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 2cd5b68..1669240 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -256,13 +256,6 @@ static void uml_net_tx_timeout(struct net_device *dev)
 	netif_wake_queue(dev);
 }
 
-static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
-{
-	dev->mtu = new_mtu;
-
-	return 0;
-}
-
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void uml_net_poll_controller(struct net_device *dev)
 {
@@ -374,7 +367,6 @@ static const struct net_device_ops uml_netdev_ops = {
 	.ndo_set_rx_mode	= uml_net_set_multicast_list,
 	.ndo_tx_timeout 	= uml_net_tx_timeout,
 	.ndo_set_mac_address	= eth_mac_addr,
-	.ndo_change_mtu 	= uml_net_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller = uml_net_poll_controller,
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 309311b..8430222 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 	return NETDEV_TX_OK;
 }
 
-static int fwnet_change_mtu(struct net_device *net, int new_mtu)
-{
-	if (new_mtu < 68)
-		return -EINVAL;
-
-	net->mtu = new_mtu;
-	return 0;
-}
-
 static const struct ethtool_ops fwnet_ethtool_ops = {
 	.get_link	= ethtool_op_get_link,
 };
@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = {
 	.ndo_open       = fwnet_open,
 	.ndo_stop	= fwnet_stop,
 	.ndo_start_xmit = fwnet_tx,
-	.ndo_change_mtu = fwnet_change_mtu,
 };
 
 static void fwnet_init_dev(struct net_device *net)
@@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,
 	struct net_device *net;
 	bool allocated_netdev = false;
 	struct fwnet_device *dev;
-	unsigned max_mtu;
 	int ret;
 	union fwnet_hwaddr *ha;
 
@@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,
 	 * Use the RFC 2734 default 1500 octets or the maximum payload
 	 * as initial MTU
 	 */
-	max_mtu = (1 << (card->max_receive + 1))
-		  - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
-	net->mtu = min(1500U, max_mtu);
+	net->max_mtu = (1 << (card->max_receive + 1))
+		       - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
+	net->mtu = min(1500U, net->max_mtu);
+	net->min_mtu = ETH_MIN_MTU;
 
 	/* Set our hardware address while we're at it */
 	ha = (union fwnet_hwaddr *)net->dev_addr;
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
index 6031cd1..7ef8196 100644
--- a/drivers/hsi/clients/ssi_protocol.c
+++ b/drivers/hsi/clients/ssi_protocol.c
@@ -960,15 +960,6 @@ static int ssip_pn_stop(struct net_device *dev)
 	return 0;
 }
 
-static int ssip_pn_set_mtu(struct net_device *dev, int new_mtu)
-{
-	if (new_mtu > SSIP_MAX_MTU || new_mtu < PHONET_MIN_MTU)
-		return -EINVAL;
-	dev->mtu = new_mtu;
-
-	return 0;
-}
-
 static void ssip_xmit_work(struct work_struct *work)
 {
 	struct ssi_protocol *ssi =
@@ -1060,7 +1051,6 @@ static const struct net_device_ops ssip_pn_ops = {
 	.ndo_open	= ssip_pn_open,
 	.ndo_stop	= ssip_pn_stop,
 	.ndo_start_xmit	= ssip_pn_xmit,
-	.ndo_change_mtu	= ssip_pn_set_mtu,
 };
 
 static void ssip_pn_setup(struct net_device *dev)
@@ -1136,6 +1126,10 @@ static int ssi_protocol_probe(struct device *dev)
 		goto out1;
 	}
 
+	/* MTU range: 6 - 65535 */
+	ssi->netdev->min_mtu = PHONET_MIN_MTU;
+	ssi->netdev->max_mtu = SSIP_MAX_MTU;
+
 	SET_NETDEV_DEV(ssi->netdev, dev);
 	netif_carrier_off(ssi->netdev);
 	err = register_netdev(ssi->netdev);
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 35cbb17..2baa45a 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -65,7 +65,6 @@ MODULE_DESCRIPTION("NetEffect RNIC Low-level iWARP Driver");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(DRV_VERSION);
 
-int max_mtu = 9000;
 int interrupt_mod_interval = 0;
 
 /* Interoperability */
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index e7430c9..85acd08 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -83,6 +83,8 @@
 #define NES_FIRST_QPN           64
 #define NES_SW_CONTEXT_ALIGN    1024
 
+#define NES_MAX_MTU		9000
+
 #define NES_NIC_MAX_NICS        16
 #define NES_MAX_ARP_TABLE_SIZE  4096
 
@@ -169,8 +171,6 @@ do { \
 #include "nes_cm.h"
 #include "nes_mgt.h"
 
-extern int max_mtu;
-#define max_frame_len (max_mtu+ETH_HLEN)
 extern int interrupt_mod_interval;
 extern int nes_if_count;
 extern int mpa_version;
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 2b27d13..7f8597d 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -981,20 +981,16 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	struct nes_vnic	*nesvnic = netdev_priv(netdev);
 	struct nes_device *nesdev = nesvnic->nesdev;
-	int ret = 0;
 	u8 jumbomode = 0;
 	u32 nic_active;
 	u32 nic_active_bit;
 	u32 uc_all_active;
 	u32 mc_all_active;
 
-	if ((new_mtu < ETH_ZLEN) || (new_mtu > max_mtu))
-		return -EINVAL;
-
 	netdev->mtu = new_mtu;
 	nesvnic->max_frame_size	= new_mtu + VLAN_ETH_HLEN;
 
-	if (netdev->mtu	> 1500)	{
+	if (netdev->mtu	> ETH_DATA_LEN)	{
 		jumbomode=1;
 	}
 	nes_nic_init_timer_defaults(nesdev, jumbomode);
@@ -1020,7 +1016,7 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu)
 		nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL, nic_active);
 	}
 
-	return ret;
+	return 0;
 }
 
 
@@ -1658,7 +1654,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
 
 	netdev->watchdog_timeo = NES_TX_TIMEOUT;
 	netdev->irq = nesdev->pcidev->irq;
-	netdev->mtu = ETH_DATA_LEN;
+	netdev->max_mtu = NES_MAX_MTU;
 	netdev->hard_header_len = ETH_HLEN;
 	netdev->addr_len = ETH_ALEN;
 	netdev->type = ARPHRD_ETHER;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index cc05921..ae5d7cd 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -2017,6 +2017,7 @@ static struct net_device *ipoib_add_port(const char *format,
 	/* MTU will be reset when mcast join happens */
 	priv->dev->mtu  = IPOIB_UD_MTU(priv->max_ib_mtu);
 	priv->mcast_mtu  = priv->admin_mtu = priv->dev->mtu;
+	priv->dev->max_mtu = IPOIB_CM_MTU;
 
 	priv->dev->neigh_priv_len = sizeof(struct ipoib_neigh);
 
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 6955c9e..55dd71b 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -549,16 +549,6 @@ mpt_lan_close(struct net_device *dev)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-static int
-mpt_lan_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < MPT_LAN_MIN_MTU) || (new_mtu > MPT_LAN_MAX_MTU))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /* Tx timeout handler. */
 static void
 mpt_lan_tx_timeout(struct net_device *dev)
@@ -1304,7 +1294,6 @@ static const struct net_device_ops mpt_netdev_ops = {
 	.ndo_open       = mpt_lan_open,
 	.ndo_stop       = mpt_lan_close,
 	.ndo_start_xmit = mpt_lan_sdu_send,
-	.ndo_change_mtu = mpt_lan_change_mtu,
 	.ndo_tx_timeout = mpt_lan_tx_timeout,
 };
 
@@ -1375,6 +1364,10 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
 	dev->netdev_ops = &mpt_netdev_ops;
 	dev->watchdog_timeo = MPT_LAN_TX_TIMEOUT;
 
+	/* MTU range: 96 - 65280 */
+	dev->min_mtu = MPT_LAN_MIN_MTU;
+	dev->max_mtu = MPT_LAN_MAX_MTU;
+
 	dlprintk((KERN_INFO MYNAM ": Finished registering dev "
 		"and setting initial values\n"));
 
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 557f978..0c26eaf 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -118,6 +118,8 @@ static DEFINE_SPINLOCK(xpnet_broadcast_lock);
  * now, the default is 64KB.
  */
 #define XPNET_MAX_MTU (0x800000UL - L1_CACHE_BYTES)
+/* 68 comes from min TCP+IP+MAC header */
+#define XPNET_MIN_MTU 68
 /* 32KB has been determined to be the ideal */
 #define XPNET_DEF_MTU (0x8000UL)
 
@@ -330,22 +332,6 @@ xpnet_dev_stop(struct net_device *dev)
 	return 0;
 }
 
-static int
-xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
-{
-	/* 68 comes from min TCP+IP+MAC header */
-	if ((new_mtu < 68) || (new_mtu > XPNET_MAX_MTU)) {
-		dev_err(xpnet, "ifconfig %s mtu %d failed; value must be "
-			"between 68 and %ld\n", dev->name, new_mtu,
-			XPNET_MAX_MTU);
-		return -EINVAL;
-	}
-
-	dev->mtu = new_mtu;
-	dev_dbg(xpnet, "ifconfig %s mtu set to %d\n", dev->name, new_mtu);
-	return 0;
-}
-
 /*
  * Notification that the other end has received the message and
  * DMA'd the skb information.  At this point, they are done with
@@ -519,7 +505,6 @@ static const struct net_device_ops xpnet_netdev_ops = {
 	.ndo_open		= xpnet_dev_open,
 	.ndo_stop		= xpnet_dev_stop,
 	.ndo_start_xmit		= xpnet_dev_hard_start_xmit,
-	.ndo_change_mtu		= xpnet_dev_change_mtu,
 	.ndo_tx_timeout		= xpnet_dev_tx_timeout,
 	.ndo_set_mac_address 	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
@@ -555,6 +540,8 @@ xpnet_init(void)
 
 	xpnet_device->netdev_ops = &xpnet_netdev_ops;
 	xpnet_device->mtu = XPNET_DEF_MTU;
+	xpnet_device->min_mtu = XPNET_MIN_MTU;
+	xpnet_device->max_mtu = XPNET_MAX_MTU;
 
 	/*
 	 * Multicast assumes the LSB of the first octet is set for multicast
diff --git a/drivers/net/fddi/skfp/skfddi.c b/drivers/net/fddi/skfp/skfddi.c
index 51acc6d..3a63918 100644
--- a/drivers/net/fddi/skfp/skfddi.c
+++ b/drivers/net/fddi/skfp/skfddi.c
@@ -166,7 +166,6 @@ static const struct net_device_ops skfp_netdev_ops = {
 	.ndo_stop		= skfp_close,
 	.ndo_start_xmit		= skfp_send_pkt,
 	.ndo_get_stats		= skfp_ctl_get_stats,
-	.ndo_change_mtu		= fddi_change_mtu,
 	.ndo_set_rx_mode	= skfp_ctl_set_multicast_list,
 	.ndo_set_mac_address	= skfp_ctl_set_mac_address,
 	.ndo_do_ioctl		= skfp_ioctl,
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index f36eb4a..b77e4ecf 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1316,6 +1316,8 @@ static void fjes_netdev_setup(struct net_device *netdev)
 	netdev->netdev_ops = &fjes_netdev_ops;
 	fjes_set_ethtool_ops(netdev);
 	netdev->mtu = fjes_support_mtu[3];
+	netdev->min_mtu = fjes_support_mtu[0];
+	netdev->max_mtu = fjes_support_mtu[3];
 	netdev->flags |= IFF_BROADCAST;
 	netdev->features |= NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_FILTER;
 }
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 95c0b45..f5a9728 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -68,7 +68,6 @@ static const struct net_device_ops rr_netdev_ops = {
 	.ndo_stop		= rr_close,
 	.ndo_do_ioctl		= rr_ioctl,
 	.ndo_start_xmit		= rr_start_xmit,
-	.ndo_change_mtu		= hippi_change_mtu,
 	.ndo_set_mac_address	= hippi_mac_addr,
 };
 
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index a31f461..300bb14 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -466,17 +466,6 @@ static void rionet_set_msglevel(struct net_device *ndev, u32 value)
 	rnet->msg_enable = value;
 }
 
-static int rionet_change_mtu(struct net_device *ndev, int new_mtu)
-{
-	if ((new_mtu < 68) || (new_mtu > RIONET_MAX_MTU)) {
-		printk(KERN_ERR "%s: Invalid MTU size %d\n",
-		       ndev->name, new_mtu);
-		return -EINVAL;
-	}
-	ndev->mtu = new_mtu;
-	return 0;
-}
-
 static const struct ethtool_ops rionet_ethtool_ops = {
 	.get_drvinfo = rionet_get_drvinfo,
 	.get_msglevel = rionet_get_msglevel,
@@ -488,7 +477,6 @@ static const struct net_device_ops rionet_netdev_ops = {
 	.ndo_open		= rionet_open,
 	.ndo_stop		= rionet_close,
 	.ndo_start_xmit		= rionet_start_xmit,
-	.ndo_change_mtu		= rionet_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_set_mac_address	= eth_mac_addr,
 };
@@ -525,6 +513,9 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
 
 	ndev->netdev_ops = &rionet_netdev_ops;
 	ndev->mtu = RIONET_MAX_MTU;
+	/* MTU range: 68 - 4082 */
+	ndev->min_mtu = ETH_MIN_MTU;
+	ndev->max_mtu = RIONET_MAX_MTU;
 	ndev->features = NETIF_F_LLTX;
 	SET_NETDEV_DEV(ndev, &mport->dev);
 	ndev->ethtool_ops = &rionet_ethtool_ops;
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 9ed6d1c..7e933d8 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -561,12 +561,7 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct slip *sl = netdev_priv(dev);
 
-	if (new_mtu < 68 || new_mtu > 65534)
-		return -EINVAL;
-
-	if (new_mtu != dev->mtu)
-		return sl_realloc_bufs(sl, new_mtu);
-	return 0;
+	return sl_realloc_bufs(sl, new_mtu);
 }
 
 /* Netdevice get statistics request */
@@ -663,6 +658,10 @@ static void sl_setup(struct net_device *dev)
 	dev->addr_len		= 0;
 	dev->tx_queue_len	= 10;
 
+	/* MTU range: 68 - 65534 */
+	dev->min_mtu = 68;
+	dev->max_mtu = 65534;
+
 	/* New-style flags. */
 	dev->flags		= IFF_NOARP|IFF_POINTOPOINT|IFF_MULTICAST;
 }
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
index 0473d61..b4058f0 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -261,19 +261,10 @@ static int pn_net_xmit(struct sk_buff *skb, struct net_device *dev)
 	return NETDEV_TX_OK;
 }
 
-static int pn_net_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < PHONET_MIN_MTU) || (new_mtu > PHONET_MAX_MTU))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-
 static const struct net_device_ops pn_netdev_ops = {
 	.ndo_open	= pn_net_open,
 	.ndo_stop	= pn_net_close,
 	.ndo_start_xmit	= pn_net_xmit,
-	.ndo_change_mtu	= pn_net_mtu,
 };
 
 static void pn_net_setup(struct net_device *dev)
@@ -282,6 +273,8 @@ static void pn_net_setup(struct net_device *dev)
 	dev->type		= ARPHRD_PHONET;
 	dev->flags		= IFF_POINTOPOINT | IFF_NOARP;
 	dev->mtu		= PHONET_DEV_MTU;
+	dev->min_mtu		= PHONET_MIN_MTU;
+	dev->max_mtu		= PHONET_MAX_MTU;
 	dev->hard_header_len	= 1;
 	dev->dev_addr[0]	= PN_MEDIA_USB;
 	dev->addr_len		= 1;
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 9c8c9ed..39a6df1 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -142,15 +142,6 @@ static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
 
 /* NETWORK DRIVER HOOKUP (to the layer above this driver) */
 
-static int ueth_change_mtu(struct net_device *net, int new_mtu)
-{
-	if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
-		return -ERANGE;
-	net->mtu = new_mtu;
-
-	return 0;
-}
-
 static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)
 {
 	struct eth_dev *dev = netdev_priv(net);
@@ -736,7 +727,6 @@ static const struct net_device_ops eth_netdev_ops = {
 	.ndo_open		= eth_open,
 	.ndo_stop		= eth_stop,
 	.ndo_start_xmit		= eth_start_xmit,
-	.ndo_change_mtu		= ueth_change_mtu,
 	.ndo_set_mac_address 	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
 };
@@ -799,6 +789,10 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 
 	net->ethtool_ops = &ops;
 
+	/* MTU range: 14 - 15412 */
+	net->min_mtu = ETH_HLEN;
+	net->max_mtu = GETHER_MAX_ETH_FRAME_LEN;
+
 	dev->gadget = g;
 	SET_NETDEV_DEV(net, &g->dev);
 	SET_NETDEV_DEVTYPE(net, &gadget_type);
diff --git a/include/linux/fddidevice.h b/include/linux/fddidevice.h
index 9a79f01..32c22cf 100644
--- a/include/linux/fddidevice.h
+++ b/include/linux/fddidevice.h
@@ -26,7 +26,6 @@
 
 #ifdef __KERNEL__
 __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev);
-int fddi_change_mtu(struct net_device *dev, int new_mtu);
 struct net_device *alloc_fddidev(int sizeof_priv);
 #endif
 
diff --git a/include/linux/hippidevice.h b/include/linux/hippidevice.h
index 8ec23fb..402f99e 100644
--- a/include/linux/hippidevice.h
+++ b/include/linux/hippidevice.h
@@ -32,7 +32,6 @@ struct hippi_cb {
 };
 
 __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev);
-int hippi_change_mtu(struct net_device *dev, int new_mtu);
 int hippi_mac_addr(struct net_device *dev, void *p);
 int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p);
 struct net_device *alloc_hippi_dev(int sizeof_priv);
diff --git a/net/802/fddi.c b/net/802/fddi.c
index 7d3a0af..6356623 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -141,15 +141,6 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 EXPORT_SYMBOL(fddi_type_trans);
 
-int fddi_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < FDDI_K_SNAP_HLEN) || (new_mtu > FDDI_K_SNAP_DLEN))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-EXPORT_SYMBOL(fddi_change_mtu);
-
 static const struct header_ops fddi_header_ops = {
 	.create		= fddi_header,
 };
@@ -161,6 +152,8 @@ static void fddi_setup(struct net_device *dev)
 	dev->type		= ARPHRD_FDDI;
 	dev->hard_header_len	= FDDI_K_SNAP_HLEN+3;	/* Assume 802.2 SNAP hdr len + 3 pad bytes */
 	dev->mtu		= FDDI_K_SNAP_DLEN;	/* Assume max payload of 802.2 SNAP frame */
+	dev->min_mtu		= FDDI_K_SNAP_HLEN;
+	dev->max_mtu		= FDDI_K_SNAP_DLEN;
 	dev->addr_len		= FDDI_K_ALEN;
 	dev->tx_queue_len	= 100;			/* Long queues on FDDI */
 	dev->flags		= IFF_BROADCAST | IFF_MULTICAST;
diff --git a/net/802/hippi.c b/net/802/hippi.c
index ade1a52..5e4427b 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -116,18 +116,6 @@ __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
 
 EXPORT_SYMBOL(hippi_type_trans);
 
-int hippi_change_mtu(struct net_device *dev, int new_mtu)
-{
-	/*
-	 * HIPPI's got these nice large MTUs.
-	 */
-	if ((new_mtu < 68) || (new_mtu > 65280))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-EXPORT_SYMBOL(hippi_change_mtu);
-
 /*
  * For HIPPI we will actually use the lower 4 bytes of the hardware
  * address as the I-FIELD rather than the actual hardware address.
@@ -174,6 +162,8 @@ static void hippi_setup(struct net_device *dev)
 	dev->type		= ARPHRD_HIPPI;
 	dev->hard_header_len 	= HIPPI_HLEN;
 	dev->mtu		= 65280;
+	dev->min_mtu		= 68;
+	dev->max_mtu		= 65280;
 	dev->addr_len		= HIPPI_ALEN;
 	dev->tx_queue_len	= 25 /* 5 */;
 	memset(dev->broadcast, 0xFF, HIPPI_ALEN);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 49e16b6..112679d 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -158,17 +158,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
 	return 0;
 }
 
-static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
-{
-	/* check ranges */
-	if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
-		return -EINVAL;
-
-	dev->mtu = new_mtu;
-
-	return 0;
-}
-
 /**
  * batadv_interface_set_rx_mode - set the rx mode of a device
  * @dev: registered network device to modify
@@ -920,7 +909,6 @@ static const struct net_device_ops batadv_netdev_ops = {
 	.ndo_vlan_rx_add_vid = batadv_interface_add_vid,
 	.ndo_vlan_rx_kill_vid = batadv_interface_kill_vid,
 	.ndo_set_mac_address = batadv_interface_set_mac_addr,
-	.ndo_change_mtu = batadv_interface_change_mtu,
 	.ndo_set_rx_mode = batadv_interface_set_rx_mode,
 	.ndo_start_xmit = batadv_interface_tx,
 	.ndo_validate_addr = eth_validate_addr,
@@ -987,6 +975,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)
 	dev_net_set(soft_iface, net);
 
 	soft_iface->rtnl_link_ops = &batadv_link_ops;
+	soft_iface->max_mtu = batadv_hardif_min_mtu(soft_iface);
 
 	ret = register_netdevice(soft_iface);
 	if (ret < 0) {
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 16737cd..fc65b14 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -398,6 +398,7 @@ void hsr_dev_setup(struct net_device *dev)
 	random_ether_addr(dev->dev_addr);
 
 	ether_setup(dev);
+	dev->min_mtu = 0;
 	dev->header_ops = &hsr_header_ops;
 	dev->netdev_ops = &hsr_device_ops;
 	SET_NETDEV_DEVTYPE(dev, &hsr_type);
diff --git a/net/phonet/pep-gprs.c b/net/phonet/pep-gprs.c
index fa8237f..21c28b5 100644
--- a/net/phonet/pep-gprs.c
+++ b/net/phonet/pep-gprs.c
@@ -217,20 +217,10 @@ static netdev_tx_t gprs_xmit(struct sk_buff *skb, struct net_device *dev)
 	return NETDEV_TX_OK;
 }
 
-static int gprs_set_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < 576) || (new_mtu > (PHONET_MAX_MTU - 11)))
-		return -EINVAL;
-
-	dev->mtu = new_mtu;
-	return 0;
-}
-
 static const struct net_device_ops gprs_netdev_ops = {
 	.ndo_open	= gprs_open,
 	.ndo_stop	= gprs_close,
 	.ndo_start_xmit	= gprs_xmit,
-	.ndo_change_mtu	= gprs_set_mtu,
 };
 
 static void gprs_setup(struct net_device *dev)
@@ -239,6 +229,8 @@ static void gprs_setup(struct net_device *dev)
 	dev->type		= ARPHRD_PHONET_PIPE;
 	dev->flags		= IFF_POINTOPOINT | IFF_NOARP;
 	dev->mtu		= GPRS_DEFAULT_MTU;
+	dev->min_mtu		= 576;
+	dev->max_mtu		= (PHONET_MAX_MTU - 11);
 	dev->hard_header_len	= 0;
 	dev->addr_len		= 0;
 	dev->tx_queue_len	= 10;
-- 
2.10.0

[toc] | [prev] | [next] | [standalone]


#1505512 — Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromRémi Denis-Courmont <remi@remlab.net>
Date2016-10-21 09:00 +0200
SubjectRe: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<suBY5-1YC-7@gated-at.bofh.it>
In reply to#1505156
Acked-by: Rémi Denis-Courmont <courmisch@gmail.com>

-- 
Rémi Denis-Courmont
http://www.remlab.net/CV.pdf

[toc] | [prev] | [next] | [standalone]


#1506129 — Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromSebastian Reichel <sre@kernel.org>
Date2016-10-21 18:30 +0200
SubjectRe: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<suKRH-87U-17@gated-at.bofh.it>
In reply to#1505156

[Multipart message — attachments visible in raw view] — view raw

Hi,

On Thu, Oct 20, 2016 at 01:55:22PM -0400, Jarod Wilson wrote:
> hsi/clients/ssi_protocol:
> - use core MTU range checking
> - remove now redundant ssip_pn_set_mtu

Acked-By: Sebastian Reichel <sre@kernel.org>

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#1506391 — Re: [net-next,v2,7/9] net: use core MTU range checking in misc drivers

FromSven Eckelmann <sven@narfation.org>
Date2016-10-22 09:30 +0200
SubjectRe: [net-next,v2,7/9] net: use core MTU range checking in misc drivers
Message-ID<suYUG-lu-5@gated-at.bofh.it>
In reply to#1505156

[Multipart message — attachments visible in raw view] — view raw

On Donnerstag, 20. Oktober 2016 13:55:22 CEST Jarod Wilson wrote:
[...]
> batman-adv:
> - set max_mtu
> - remove batadv_interface_change_mtu
> - initialization is a little async, not 100% certain that max_mtu is set
>   in the optimal place, don't have hardware to test with

batman-adv is creating a virtual interface - so there are no
hardware requirements (ok, ethernet compatible hardware - even
when only virtual/emulated).

[...]
> diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
> index 49e16b6..112679d 100644
> --- a/net/batman-adv/soft-interface.c
> +++ b/net/batman-adv/soft-interface.c
> @@ -158,17 +158,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
>  	return 0;
>  }
>  
> -static int batadv_interface_change_mtu(struct net_device *dev, int new_mtu)
> -{
> -	/* check ranges */
> -	if ((new_mtu < 68) || (new_mtu > batadv_hardif_min_mtu(dev)))
> -		return -EINVAL;
> -
> -	dev->mtu = new_mtu;
> -
> -	return 0;
> -}
> -
>  /**
>   * batadv_interface_set_rx_mode - set the rx mode of a device
>   * @dev: registered network device to modify
> @@ -920,7 +909,6 @@ static const struct net_device_ops batadv_netdev_ops = {
>  	.ndo_vlan_rx_add_vid = batadv_interface_add_vid,
>  	.ndo_vlan_rx_kill_vid = batadv_interface_kill_vid,
>  	.ndo_set_mac_address = batadv_interface_set_mac_addr,
> -	.ndo_change_mtu = batadv_interface_change_mtu,
>  	.ndo_set_rx_mode = batadv_interface_set_rx_mode,
>  	.ndo_start_xmit = batadv_interface_tx,
>  	.ndo_validate_addr = eth_validate_addr,
> @@ -987,6 +975,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)
>  	dev_net_set(soft_iface, net);
>  
>  	soft_iface->rtnl_link_ops = &batadv_link_ops;
> +	soft_iface->max_mtu = batadv_hardif_min_mtu(soft_iface);
>  
>  	ret = register_netdevice(soft_iface);
>  	if (ret < 0) {

This looks bogus to me. You are now setting max_mtu during initialization of
the virtual interface. But at this time no slave interfaces were added to the
master batman-adv interface. So the batadv_hardif_min_mtu will not return the
correct value here. Especially if you don't have fragmentation enabled.

So this change looks like a bug to me

Kind regards,
	Sven

[toc] | [prev] | [next] | [standalone]


#1506586 — Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-22 21:20 +0200
SubjectRe: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<sv9ZL-7vE-3@gated-at.bofh.it>
In reply to#1505156
On Oct 20 Jarod Wilson wrote:
> firewire-net:
> - set min/max_mtu
> - remove fwnet_change_mtu
[...]
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
[...]
> @@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,
>  	 * Use the RFC 2734 default 1500 octets or the maximum payload
>  	 * as initial MTU
>  	 */
> -	max_mtu = (1 << (card->max_receive + 1))
> -		  - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> -	net->mtu = min(1500U, max_mtu);
> +	net->max_mtu = (1 << (card->max_receive + 1))
> +		       - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> +	net->mtu = min(1500U, net->max_mtu);
> +	net->min_mtu = ETH_MIN_MTU;
>  
>  	/* Set our hardware address while we're at it */
>  	ha = (union fwnet_hwaddr *)net->dev_addr;

Please preserve the current behavior, i.e. do not enforce any particular
upper bound.  (Especially none based on the local link layer controller's
max_receive parameter.)

BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced
that net->mtu should be initialized to 1500, not less.  But such a change
should be done in a separate patch.
-- 
Stefan Richter
-======----- =-=- =-==-
http://arcgraph.de/sr/

[toc] | [prev] | [next] | [standalone]


#1506588 — Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-22 21:30 +0200
SubjectRe: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<sva9r-7yQ-11@gated-at.bofh.it>
In reply to#1506586
Adding Cc: linux1394-devel, dropping several Ccs, no additional comment.

On Oct 22 Stefan Richter wrote:
> On Oct 20 Jarod Wilson wrote:
> > firewire-net:
> > - set min/max_mtu
> > - remove fwnet_change_mtu  
> [...]
> > --- a/drivers/firewire/net.c
> > +++ b/drivers/firewire/net.c
> > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff
> > *skb, struct net_device *net) return NETDEV_TX_OK;
> >  }
> >  
> > -static int fwnet_change_mtu(struct net_device *net, int new_mtu)
> > -{
> > -	if (new_mtu < 68)
> > -		return -EINVAL;
> > -
> > -	net->mtu = new_mtu;
> > -	return 0;
> > -}
> > -
> >  static const struct ethtool_ops fwnet_ethtool_ops = {
> >  	.get_link	= ethtool_op_get_link,
> >  };
> > @@ -1366,7 +1357,6 @@ static const struct net_device_ops
> > fwnet_netdev_ops = { .ndo_open       = fwnet_open,
> >  	.ndo_stop	= fwnet_stop,
> >  	.ndo_start_xmit = fwnet_tx,
> > -	.ndo_change_mtu = fwnet_change_mtu,
> >  };
> >  
> >  static void fwnet_init_dev(struct net_device *net)
> > @@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,
> >  	struct net_device *net;
> >  	bool allocated_netdev = false;
> >  	struct fwnet_device *dev;
> > -	unsigned max_mtu;
> >  	int ret;
> >  	union fwnet_hwaddr *ha;
> >  
> > @@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,
> >  	 * Use the RFC 2734 default 1500 octets or the maximum payload
> >  	 * as initial MTU
> >  	 */
> > -	max_mtu = (1 << (card->max_receive + 1))
> > -		  - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> > -	net->mtu = min(1500U, max_mtu);
> > +	net->max_mtu = (1 << (card->max_receive + 1))
> > +		       - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> > +	net->mtu = min(1500U, net->max_mtu);
> > +	net->min_mtu = ETH_MIN_MTU;
> >  
> >  	/* Set our hardware address while we're at it */
> >  	ha = (union fwnet_hwaddr *)net->dev_addr;
> 
> Please preserve the current behavior, i.e. do not enforce any particular
> upper bound.  (Especially none based on the local link layer controller's
> max_receive parameter.)
> 
> BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced
> that net->mtu should be initialized to 1500, not less.  But such a change
> should be done in a separate patch.
-- 
Stefan Richter
-======----- =-=- =-==-
http://arcgraph.de/sr/

[toc] | [prev] | [next] | [standalone]


#1506623 — Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers

FromJarod Wilson <jarod@redhat.com>
Date2016-10-23 03:20 +0200
SubjectRe: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Message-ID<svfC9-2Bw-5@gated-at.bofh.it>
In reply to#1506588
On Sat, Oct 22, 2016 at 09:27:59PM +0200, Stefan Richter wrote:
> Adding Cc: linux1394-devel, dropping several Ccs, no additional comment.
> 
> On Oct 22 Stefan Richter wrote:
> > On Oct 20 Jarod Wilson wrote:
> > > firewire-net:
> > > - set min/max_mtu
> > > - remove fwnet_change_mtu  
> > [...]
> > > --- a/drivers/firewire/net.c
> > > +++ b/drivers/firewire/net.c
> > > @@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff
> > > *skb, struct net_device *net) return NETDEV_TX_OK;
> > >  }
> > >  
> > > -static int fwnet_change_mtu(struct net_device *net, int new_mtu)
> > > -{
> > > -	if (new_mtu < 68)
> > > -		return -EINVAL;
> > > -
> > > -	net->mtu = new_mtu;
> > > -	return 0;
> > > -}
> > > -
> > >  static const struct ethtool_ops fwnet_ethtool_ops = {
> > >  	.get_link	= ethtool_op_get_link,
> > >  };
> > > @@ -1366,7 +1357,6 @@ static const struct net_device_ops
> > > fwnet_netdev_ops = { .ndo_open       = fwnet_open,
> > >  	.ndo_stop	= fwnet_stop,
> > >  	.ndo_start_xmit = fwnet_tx,
> > > -	.ndo_change_mtu = fwnet_change_mtu,
> > >  };
> > >  
> > >  static void fwnet_init_dev(struct net_device *net)
> > > @@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,
> > >  	struct net_device *net;
> > >  	bool allocated_netdev = false;
> > >  	struct fwnet_device *dev;
> > > -	unsigned max_mtu;
> > >  	int ret;
> > >  	union fwnet_hwaddr *ha;
> > >  
> > > @@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,
> > >  	 * Use the RFC 2734 default 1500 octets or the maximum payload
> > >  	 * as initial MTU
> > >  	 */
> > > -	max_mtu = (1 << (card->max_receive + 1))
> > > -		  - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> > > -	net->mtu = min(1500U, max_mtu);
> > > +	net->max_mtu = (1 << (card->max_receive + 1))
> > > +		       - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
> > > +	net->mtu = min(1500U, net->max_mtu);
> > > +	net->min_mtu = ETH_MIN_MTU;
> > >  
> > >  	/* Set our hardware address while we're at it */
> > >  	ha = (union fwnet_hwaddr *)net->dev_addr;
> > 
> > Please preserve the current behavior, i.e. do not enforce any particular
> > upper bound.  (Especially none based on the local link layer controller's
> > max_receive parameter.)
> > 
> > BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced
> > that net->mtu should be initialized to 1500, not less.  But such a change
> > should be done in a separate patch.

Okay, since it's already merged in net-next, I can do a follow-up patch
here to set max_mtu to ETH_MAX_MTU (65535), which is the largest possible
size the kernel can handle, so far as I can tell. But as long as I'm going
to be in here, if we just want to use an initial mtu of 1500, I could
clean that up at the same time, and entirely remove the max_mtu
calculation stuff, if that's what you think is more correct here.

-- 
Jarod Wilson
jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


#1506710 — [PATCH net-next 1/2] firewire: net: fix maximum possible MTU

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-23 16:30 +0200
Subject[PATCH net-next 1/2] firewire: net: fix maximum possible MTU
Message-ID<svrWF-273-3@gated-at.bofh.it>
In reply to#1506623
Commit b3e3893e1253 ("net: use core MTU range checking in misc drivers")
mistakenly introduced an upper limit for firewire-net's MTU based on the
local link layer controller's reception capability.  Revert this.  Neither
RFC 2734 nor our implementation impose any particular upper limit.

Actually, to be on the safe side and to make the code explicit, set
ETH_MAX_MTU = 65535 as upper limit now.

(I replaced sizeof(struct rfc2734_header) by the equivalent
RFC2374_FRAG_HDR_SIZE in order to avoid distracting long/int conversions.)

Fixes: b3e3893e1253('net: use core MTU range checking in misc drivers')
CC: netdev@vger.kernel.org
CC: linux1394-devel@lists.sourceforge.net
CC: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
 drivers/firewire/net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 8430222151fc..99379542b263 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1467,10 +1467,11 @@ static int fwnet_probe(struct fw_unit *unit,
 	 * Use the RFC 2734 default 1500 octets or the maximum payload
 	 * as initial MTU
 	 */
-	net->max_mtu = (1 << (card->max_receive + 1))
-		       - sizeof(struct rfc2734_header) - IEEE1394_GASP_HDR_SIZE;
-	net->mtu = min(1500U, net->max_mtu);
+	net->mtu = min(1500U,
+		       (1U << (card->max_receive + 1))
+		       - RFC2374_FRAG_HDR_SIZE - IEEE1394_GASP_HDR_SIZE);
 	net->min_mtu = ETH_MIN_MTU;
+	net->max_mtu = ETH_MAX_MTU;
 
 	/* Set our hardware address while we're at it */
 	ha = (union fwnet_hwaddr *)net->dev_addr;
-- 
Stefan Richter
-======----- =-=- =-===
http://arcgraph.de/sr/

[toc] | [prev] | [next] | [standalone]


#1506711 — [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-23 16:40 +0200
Subject[PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Message-ID<svs6m-2am-11@gated-at.bofh.it>
In reply to#1506710
firewire-net, like the older eth1394 driver, reduced the initial MTU to
less than 1500 octets if the local link layer controller's asynchronous
packet reception limit was lower.

This is bogus, since this reception limit does not have anything to do
with the transmission limit.  Neither did this reduction affect the TX
path positively, nor could it prevent link fragmentation at the RX path.

Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU
of 1024 - 16 = 1008.  RFC 2734 and RFC 3146 allow a minimum max_rec = 8,
which would result in an initial MTU of 512 - 16 = 496.  On such cards,
IPv6 could only be employed if the MTU was manually increased to 1280 or
more, i.e. IPv6 would not work without intervention from userland.

We now always initialize the MTU to 1500, which is the default according
to RFC 2734 and RFC 3146.

On a VIA VT6316 based CardBus card which was affected by this, changing
the MTU from 1008 to 1500 also increases TX bandwidth by 6 %.
RX remains unaffected.

CC: netdev@vger.kernel.org
CC: linux1394-devel@lists.sourceforge.net
CC: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
 drivers/firewire/net.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 99379542b263..03715e7d9d92 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1463,13 +1463,7 @@ static int fwnet_probe(struct fw_unit *unit,
 		goto out;
 	dev->local_fifo = dev->handler.offset;
 
-	/*
-	 * Use the RFC 2734 default 1500 octets or the maximum payload
-	 * as initial MTU
-	 */
-	net->mtu = min(1500U,
-		       (1U << (card->max_receive + 1))
-		       - RFC2374_FRAG_HDR_SIZE - IEEE1394_GASP_HDR_SIZE);
+	net->mtu = 1500U;
 	net->min_mtu = ETH_MIN_MTU;
 	net->max_mtu = ETH_MAX_MTU;
 
-- 
Stefan Richter
-======----- =-=- =-===
http://arcgraph.de/sr/

[toc] | [prev] | [next] | [standalone]


#1506823 — Re: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards

FromJarod Wilson <jarod@redhat.com>
Date2016-10-24 04:00 +0200
SubjectRe: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Message-ID<svCIp-Pc-9@gated-at.bofh.it>
In reply to#1506711
On Sun, Oct 23, 2016 at 04:30:56PM +0200, Stefan Richter wrote:
> firewire-net, like the older eth1394 driver, reduced the initial MTU to
> less than 1500 octets if the local link layer controller's asynchronous
> packet reception limit was lower.
> 
> This is bogus, since this reception limit does not have anything to do
> with the transmission limit.  Neither did this reduction affect the TX
> path positively, nor could it prevent link fragmentation at the RX path.
> 
> Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU
> of 1024 - 16 = 1008.  RFC 2734 and RFC 3146 allow a minimum max_rec = 8,
> which would result in an initial MTU of 512 - 16 = 496.  On such cards,
> IPv6 could only be employed if the MTU was manually increased to 1280 or
> more, i.e. IPv6 would not work without intervention from userland.
> 
> We now always initialize the MTU to 1500, which is the default according
> to RFC 2734 and RFC 3146.
> 
> On a VIA VT6316 based CardBus card which was affected by this, changing
> the MTU from 1008 to 1500 also increases TX bandwidth by 6 %.
> RX remains unaffected.
> 
> CC: netdev@vger.kernel.org
> CC: linux1394-devel@lists.sourceforge.net
> CC: Jarod Wilson <jarod@redhat.com>
> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
> ---
>  drivers/firewire/net.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index 99379542b263..03715e7d9d92 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -1463,13 +1463,7 @@ static int fwnet_probe(struct fw_unit *unit,
>  		goto out;
>  	dev->local_fifo = dev->handler.offset;
>  
> -	/*
> -	 * Use the RFC 2734 default 1500 octets or the maximum payload
> -	 * as initial MTU
> -	 */
> -	net->mtu = min(1500U,
> -		       (1U << (card->max_receive + 1))
> -		       - RFC2374_FRAG_HDR_SIZE - IEEE1394_GASP_HDR_SIZE);
> +	net->mtu = 1500U;

Should be able to do just net->mtu = ETH_DATA_LEN;

-- 
Jarod Wilson
jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


#1507139 — [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-24 14:30 +0200
Subject[PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Message-ID<svMy5-7xJ-13@gated-at.bofh.it>
In reply to#1506823
firewire-net, like the older eth1394 driver, reduced the initial MTU to
less than 1500 octets if the local link layer controller's asynchronous
packet reception limit was lower.

This is bogus, since this reception limit does not have anything to do
with the transmission limit.  Neither did this reduction affect the TX
path positively, nor could it prevent link fragmentation at the RX path.

Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU
of 1024 - 16 = 1008.  RFC 2734 and RFC 3146 allow a minimum max_rec = 8,
which would result in an initial MTU of 512 - 16 = 496.  On such cards,
IPv6 could only be employed if the MTU was manually increased to 1280 or
more, i.e. IPv6 would not work without intervention from userland.

We now always initialize the MTU to 1500, which is the default according
to RFC 2734 and RFC 3146.

On a VIA VT6316 based CardBus card which was affected by this, changing
the MTU from 1008 to 1500 also increases TX bandwidth by 6 %.
RX remains unaffected.

CC: netdev@vger.kernel.org
CC: linux1394-devel@lists.sourceforge.net
CC: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
v2: use ETH_DATA_LEN, add comment

 drivers/firewire/net.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 99379542b263..29dbcba38f59 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1463,13 +1463,8 @@ static int fwnet_probe(struct fw_unit *unit,
 		goto out;
 	dev->local_fifo = dev->handler.offset;
 
-	/*
-	 * Use the RFC 2734 default 1500 octets or the maximum payload
-	 * as initial MTU
-	 */
-	net->mtu = min(1500U,
-		       (1U << (card->max_receive + 1))
-		       - RFC2374_FRAG_HDR_SIZE - IEEE1394_GASP_HDR_SIZE);
+	/* MTU range: 68 - 65535, RFC 2734 default: 1500 */
+	net->mtu = ETH_DATA_LEN;
 	net->min_mtu = ETH_MIN_MTU;
 	net->max_mtu = ETH_MAX_MTU;
 
-- 
2.7.3



-- 
Stefan Richter
-======----- =-=- ==---
http://arcgraph.de/sr/

[toc] | [prev] | [next] | [standalone]


#1507941 — Re: [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards

FromJarod Wilson <jarod@redhat.com>
Date2016-10-25 05:10 +0200
SubjectRe: [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Message-ID<sw0hH-8lF-11@gated-at.bofh.it>
In reply to#1507139
On Mon, Oct 24, 2016 at 02:26:13PM +0200, Stefan Richter wrote:
> firewire-net, like the older eth1394 driver, reduced the initial MTU to
> less than 1500 octets if the local link layer controller's asynchronous
> packet reception limit was lower.
> 
> This is bogus, since this reception limit does not have anything to do
> with the transmission limit.  Neither did this reduction affect the TX
> path positively, nor could it prevent link fragmentation at the RX path.
> 
> Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU
> of 1024 - 16 = 1008.  RFC 2734 and RFC 3146 allow a minimum max_rec = 8,
> which would result in an initial MTU of 512 - 16 = 496.  On such cards,
> IPv6 could only be employed if the MTU was manually increased to 1280 or
> more, i.e. IPv6 would not work without intervention from userland.
> 
> We now always initialize the MTU to 1500, which is the default according
> to RFC 2734 and RFC 3146.
> 
> On a VIA VT6316 based CardBus card which was affected by this, changing
> the MTU from 1008 to 1500 also increases TX bandwidth by 6 %.
> RX remains unaffected.
> 
> CC: netdev@vger.kernel.org
> CC: linux1394-devel@lists.sourceforge.net
> CC: Jarod Wilson <jarod@redhat.com>
> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
> ---
> v2: use ETH_DATA_LEN, add comment

Acked-by: Jarod Wilson <jarod@redhat.com>

-- 
Jarod Wilson
jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | linux.kernel


csiph-web