Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Mar 2016 08:48:16 +0000 (UTC)
From:      "George V. Neville-Neil" <gnn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r296829 - head/usr.sbin/bhyve
Message-ID:  <201603140848.u2E8mGti074223@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gnn
Date: Mon Mar 14 08:48:16 2016
New Revision: 296829
URL: https://svnweb.freebsd.org/changeset/base/296829

Log:
  Fix typo: nmd->cur_tx_ring should be used in pci_vtnet_netmap_writev()
  The buffer length should be checked to avoid overflow, but there
  is no API to get the slot length, so the hardcoded value is used.
  Return the currently-first request chain back to the available
  queue if there are no more packets.
  Report the link as up if we managed to open vale port.
  Use consistent coding style.
  
  Submitted by: btw
  MFC after: 1 week
  Differential Revision:	https://reviews.freebsd.org/D5595

Modified:
  head/usr.sbin/bhyve/pci_virtio_net.c

Modified: head/usr.sbin/bhyve/pci_virtio_net.c
==============================================================================
--- head/usr.sbin/bhyve/pci_virtio_net.c	Mon Mar 14 07:26:38 2016	(r296828)
+++ head/usr.sbin/bhyve/pci_virtio_net.c	Mon Mar 14 08:48:16 2016	(r296829)
@@ -381,7 +381,7 @@ pci_vtnet_tap_rx(struct pci_vtnet_softc 
 	vq_endchains(vq, 1);
 }
 
-static int
+static __inline int
 pci_vtnet_netmap_writev(struct nm_desc *nmd, struct iovec *iov, int iovcnt)
 {
 	int r, i;
@@ -396,7 +396,7 @@ pci_vtnet_netmap_writev(struct nm_desc *
 			r++;
 			if (r > nmd->last_tx_ring)
 				r = nmd->first_tx_ring;
-			if (r == nmd->cur_rx_ring)
+			if (r == nmd->cur_tx_ring)
 				break;
 			continue;
 		}
@@ -405,6 +405,8 @@ pci_vtnet_netmap_writev(struct nm_desc *
 		buf = NETMAP_BUF(ring, idx);
 
 		for (i = 0; i < iovcnt; i++) {
+			if (len + iov[i].iov_len > 2048)
+				break;
 			memcpy(&buf[len], iov[i].iov_base, iov[i].iov_len);
 			len += iov[i].iov_len;
 		}
@@ -418,7 +420,7 @@ pci_vtnet_netmap_writev(struct nm_desc *
 	return (len);
 }
 
-static inline int
+static __inline int
 pci_vtnet_netmap_readv(struct nm_desc *nmd, struct iovec *iov, int iovcnt)
 {
 	int len = 0;
@@ -548,6 +550,7 @@ pci_vtnet_netmap_rx(struct pci_vtnet_sof
 			 * No more packets, but still some avail ring
 			 * entries.  Interrupt if needed/appropriate.
 			 */
+			vq_retchain(vq);
 			vq_endchains(vq, 0);
 			return;
 		}
@@ -884,8 +887,9 @@ pci_vtnet_init(struct vmctx *ctx, struct
 	pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_NET);
 	pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
 
-	/* Link is up if we managed to open tap device. */
-	sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0);
+	/* Link is up if we managed to open tap device or vale port. */
+	sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0 ||
+	    sc->vsc_nmd != NULL);
 	
 	/* use BAR 1 to map MSI-X table and PBA, if we're using MSI-X */
 	if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix()))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603140848.u2E8mGti074223>