Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111565827
D27381.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D27381.diff
View Options
Index: head/usr.sbin/bhyve/pci_virtio_net.c
===================================================================
--- head/usr.sbin/bhyve/pci_virtio_net.c
+++ head/usr.sbin/bhyve/pci_virtio_net.c
@@ -111,6 +111,8 @@
net_backend_t *vsc_be;
+ bool features_negotiated; /* protected by rx_mtx */
+
int resetting; /* protected by tx_mtx */
uint64_t vsc_features; /* negotiated features */
@@ -176,6 +178,7 @@
* Receive operation will be enabled again once the guest adds
* the first receive buffers and kicks us.
*/
+ sc->features_negotiated = false;
netbe_rx_disable(sc->vsc_be);
/* Set sc->resetting and give a chance to the TX thread to stop. */
@@ -246,6 +249,12 @@
struct vqueue_info *vq;
vq = &sc->vsc_queues[VTNET_RXQ];
+
+ /* Features must be negotiated */
+ if (!sc->features_negotiated) {
+ return;
+ }
+
for (;;) {
struct virtio_net_rxhdr *hdr;
uint32_t riov_bytes;
@@ -406,8 +415,14 @@
/*
* A qnotify means that the rx process can now begin.
+ * Enable RX only if features are negotiated.
*/
pthread_mutex_lock(&sc->rx_mtx);
+ if (!sc->features_negotiated) {
+ pthread_mutex_unlock(&sc->rx_mtx);
+ return;
+ }
+
vq_kick_disable(vq);
netbe_rx_enable(sc->vsc_be);
pthread_mutex_unlock(&sc->rx_mtx);
@@ -750,6 +765,10 @@
netbe_set_cap(sc->vsc_be, negotiated_features, sc->vhdrlen);
sc->be_vhdrlen = netbe_get_vnet_hdr_len(sc->vsc_be);
assert(sc->be_vhdrlen == 0 || sc->be_vhdrlen == sc->vhdrlen);
+
+ pthread_mutex_lock(&sc->rx_mtx);
+ sc->features_negotiated = true;
+ pthread_mutex_unlock(&sc->rx_mtx);
}
#ifdef BHYVE_SNAPSHOT
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 6, 8:35 AM (19 m, 57 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17011311
Default Alt Text
D27381.diff (1 KB)
Attached To
Mode
D27381: [bhyve] virtio-net: Do not allow receiving packets until features have been negotiated.
Attached
Detach File
Event Timeline
Log In to Comment