Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1505932
| From | Aaron Conole <aconole@bytheb.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers |
| Date | 2016-10-21 15:30 +0200 |
| Message-ID | <suI3v-63W-7@gated-at.bofh.it> (permalink) |
| References | (1 earlier) <supNf-2j8-3@gated-at.bofh.it> <supNg-2j8-39@gated-at.bofh.it> <sus8p-3Z6-7@gated-at.bofh.it> <suxUu-7SK-11@gated-at.bofh.it> <suyQx-8rm-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
"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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[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
csiph-web