Skip to content

Commit 55c80ad

Browse files
mstsirkingregkh
authored andcommitted
virtio_net: fix adding vids on big-endian
[ Upstream commit d7fad4c ] 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: 9465a7a ("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>
1 parent d86aaca commit 55c80ad

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/virtio_net.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct control_buf {
123123
struct virtio_net_ctrl_mq mq;
124124
u8 promisc;
125125
u8 allmulti;
126-
u16 vid;
126+
__virtio16 vid;
127127
u64 offloads;
128128
};
129129

@@ -1602,7 +1602,7 @@ static int virtnet_vlan_rx_add_vid(struct net_device *dev,
16021602
struct virtnet_info *vi = netdev_priv(dev);
16031603
struct scatterlist sg;
16041604

1605-
vi->ctrl->vid = vid;
1605+
vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
16061606
sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
16071607

16081608
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
@@ -1617,7 +1617,7 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev,
16171617
struct virtnet_info *vi = netdev_priv(dev);
16181618
struct scatterlist sg;
16191619

1620-
vi->ctrl->vid = vid;
1620+
vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
16211621
sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
16221622

16231623
if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,

0 commit comments

Comments
 (0)