virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jarod Wilson <jarod@redhat.com>
Cc: "VMware, Inc." <pv-drivers@vmware.com>,
	netdev@vger.kernel.org, Haiyang Zhang <haiyangz@microsoft.com>,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Shrikrishna Khare <skhare@vmware.com>
Subject: Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
Date: Wed, 19 Oct 2016 16:59:46 +0300	[thread overview]
Message-ID: <20161019165629-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20161019023333.15760-6-jarod@redhat.com>

On Tue, Oct 18, 2016 at 10:33:32PM -0400, Jarod Wilson wrote:
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fad84f3..4885a42 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 65535
> +

Do we need a common macro for this?

>  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) {
> +			dev->mtu = mtu;
>  			__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);

I think the logic is wrong here:

If mtu is legal, we set it but do not tell host.
If it's out of range we tell host we use it
but don't actually.

Should be the reverse.

> +		}
>  	}
>  
>  	if (vi->any_header_sg)

-- 
MST

  parent reply	other threads:[~2016-10-19 13:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20161019023333.15760-1-jarod@redhat.com>
2016-10-19  2:33 ` [PATCH net-next 5/6] net: use core MTU range checking in virt drivers Jarod Wilson
     [not found] ` <20161019023333.15760-6-jarod@redhat.com>
2016-10-19 13:06   ` Aaron Conole
2016-10-19 13:59   ` Michael S. Tsirkin [this message]
2016-10-19 14:03     ` Michael S. Tsirkin
2016-10-19 14:17       ` Jarod Wilson
2016-10-19 14:15     ` Jarod Wilson
2016-10-19 14:07   ` Haiyang Zhang via Virtualization
2016-10-19 14:23     ` Jarod Wilson
2016-10-19 22:21   ` Shrikrishna Khare
     [not found] ` <20161020175524.6184-1-jarod@redhat.com>
2016-10-20 17:55   ` [PATCH net-next v2 6/9] " Jarod Wilson
2016-10-20 18:05     ` Haiyang Zhang via Virtualization
2016-10-20 20:23     ` Michael S. Tsirkin
     [not found]     ` <20161020231559-mutt-send-email-mst@kernel.org>
2016-10-21  2:37       ` Jarod Wilson
2016-10-21  3:36         ` Michael S. Tsirkin
2016-10-21 13:24           ` Aaron Conole
2016-10-21 10:09     ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019165629-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=haiyangz@microsoft.com \
    --cc=jarod@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pv-drivers@vmware.com \
    --cc=skhare@vmware.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).