diff options
author | Jason Wang <jasowang@redhat.com> | 2018-03-09 01:50:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-09 12:02:59 -0500 |
commit | 303fd71b37fb710b26f5ff5444029d62cfd627bd (patch) | |
tree | 293b96678dda7f617ccf9a8e167f4ac977f3a17c /drivers/vhost | |
parent | ab7e34b3431c5d29817c503ad4d3bf2732f92ad3 (diff) |
vhost_net: keep private_data and rx_ring synced
We get pointer ring from the exported sock, this means we should keep
rx_ring and vq->private synced during both vq stop and backend set,
otherwise we may see stale rx_ring.
Fixes: c67df11f6e480 ("vhost_net: try batch dequing from skb array")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/net.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 60f1080bffc7..efb93063fda1 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -973,6 +973,7 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n, | |||
973 | vhost_net_disable_vq(n, vq); | 973 | vhost_net_disable_vq(n, vq); |
974 | vq->private_data = NULL; | 974 | vq->private_data = NULL; |
975 | vhost_net_buf_unproduce(nvq); | 975 | vhost_net_buf_unproduce(nvq); |
976 | nvq->rx_ring = NULL; | ||
976 | mutex_unlock(&vq->mutex); | 977 | mutex_unlock(&vq->mutex); |
977 | return sock; | 978 | return sock; |
978 | } | 979 | } |
@@ -1162,14 +1163,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) | |||
1162 | vhost_net_disable_vq(n, vq); | 1163 | vhost_net_disable_vq(n, vq); |
1163 | vq->private_data = sock; | 1164 | vq->private_data = sock; |
1164 | vhost_net_buf_unproduce(nvq); | 1165 | vhost_net_buf_unproduce(nvq); |
1165 | if (index == VHOST_NET_VQ_RX) | ||
1166 | nvq->rx_ring = get_tap_ptr_ring(fd); | ||
1167 | r = vhost_vq_init_access(vq); | 1166 | r = vhost_vq_init_access(vq); |
1168 | if (r) | 1167 | if (r) |
1169 | goto err_used; | 1168 | goto err_used; |
1170 | r = vhost_net_enable_vq(n, vq); | 1169 | r = vhost_net_enable_vq(n, vq); |
1171 | if (r) | 1170 | if (r) |
1172 | goto err_used; | 1171 | goto err_used; |
1172 | if (index == VHOST_NET_VQ_RX) | ||
1173 | nvq->rx_ring = get_tap_ptr_ring(fd); | ||
1173 | 1174 | ||
1174 | oldubufs = nvq->ubufs; | 1175 | oldubufs = nvq->ubufs; |
1175 | nvq->ubufs = ubufs; | 1176 | nvq->ubufs = ubufs; |