]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
virtio_net: fix adding vids on big-endian
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 19 Apr 2018 05:30:49 +0000 (08:30 +0300)
committerKhalid Elmously <khalid.elmously@canonical.com>
Tue, 12 Jun 2018 06:28:55 +0000 (02:28 -0400)
BugLink: http://bugs.launchpad.net/bugs/1775483
[ Upstream commit d7fad4c840f33a6bd333dd7fbb3006edbcf0017a ]

Programming vids (adding or removing them) still passes
guest-endian values in the DMA buffer. That's wrong
if guest is big-endian and when virtio 1 is enabled.

Note: this is on top of a previous patch:
virtio_net: split out ctrl buffer

Fixes: 9465a7a6f ("virtio_net: enable v1.0 support")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/virtio_net.c

index 94bf219417a08f6c34ecb114a052288308428a63..5ef484dd30e76bc6857d4cbcaaee009bc1e0de91 100644 (file)
@@ -124,7 +124,7 @@ struct control_buf {
        struct virtio_net_ctrl_mq mq;
        u8 promisc;
        u8 allmulti;
-       u16 vid;
+       __virtio16 vid;
        u64 offloads;
 };
 
@@ -1647,7 +1647,7 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev,
        struct virtnet_info *vi = netdev_priv(dev);
        struct scatterlist sg;
 
-       vi->ctrl->vid = vid;
+       vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
        sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
 
        if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
@@ -1662,7 +1662,7 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev,
        struct virtnet_info *vi = netdev_priv(dev);
        struct scatterlist sg;
 
-       vi->ctrl->vid = vid;
+       vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
        sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
 
        if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,