Skip to content

Commit

Permalink
Merge branch 'freebsd/current/main' into hardened/current/master
Browse files Browse the repository at this point in the history
  • Loading branch information
HardenedBSD Sync Services committed Jul 4, 2024
2 parents 233ec8c + 0916445 commit e090df4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
66 changes: 39 additions & 27 deletions sys/dev/virtio/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,38 +1177,45 @@ vtblk_request_error(struct vtblk_request *req)
return (error);
}

static struct bio *
vtblk_queue_complete_one(struct vtblk_softc *sc, struct vtblk_request *req)
{
struct bio *bp;

if (sc->vtblk_req_ordered != NULL) {
MPASS(sc->vtblk_req_ordered == req);
sc->vtblk_req_ordered = NULL;
}

bp = req->vbr_bp;
if (req->vbr_mapp != NULL) {
switch (bp->bio_cmd) {
case BIO_READ:
bus_dmamap_sync(sc->vtblk_dmat, req->vbr_mapp,
BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->vtblk_dmat, req->vbr_mapp);
break;
case BIO_WRITE:
bus_dmamap_sync(sc->vtblk_dmat, req->vbr_mapp,
BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(sc->vtblk_dmat, req->vbr_mapp);
break;
}
}
bp->bio_error = vtblk_request_error(req);
return (bp);
}

static void
vtblk_queue_completed(struct vtblk_softc *sc, struct bio_queue *queue)
{
struct vtblk_request *req;
struct bio *bp;

while ((req = virtqueue_dequeue(sc->vtblk_vq, NULL)) != NULL) {
if (sc->vtblk_req_ordered != NULL) {
MPASS(sc->vtblk_req_ordered == req);
sc->vtblk_req_ordered = NULL;
}
bp = vtblk_queue_complete_one(sc, req);

bp = req->vbr_bp;
if (req->vbr_mapp != NULL) {
switch (bp->bio_cmd) {
case BIO_READ:
bus_dmamap_sync(sc->vtblk_dmat, req->vbr_mapp,
BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->vtblk_dmat,
req->vbr_mapp);
break;
case BIO_WRITE:
bus_dmamap_sync(sc->vtblk_dmat, req->vbr_mapp,
BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(sc->vtblk_dmat,
req->vbr_mapp);
break;
}
}
bp->bio_error = vtblk_request_error(req);
TAILQ_INSERT_TAIL(queue, bp, bio_queue);

vtblk_request_enqueue(sc, req);
}
}
Expand Down Expand Up @@ -1412,8 +1419,6 @@ vtblk_ident(struct vtblk_softc *sc)
error = vtblk_poll_request(sc, req);
VTBLK_UNLOCK(sc);

vtblk_request_enqueue(sc, req);

if (error) {
device_printf(sc->vtblk_dev,
"error getting device identifier: %d\n", error);
Expand All @@ -1423,7 +1428,9 @@ vtblk_ident(struct vtblk_softc *sc)
static int
vtblk_poll_request(struct vtblk_softc *sc, struct vtblk_request *req)
{
struct vtblk_request *req1 __diagused;
struct virtqueue *vq;
struct bio *bp;
int error;

vq = sc->vtblk_vq;
Expand All @@ -1436,13 +1443,18 @@ vtblk_poll_request(struct vtblk_softc *sc, struct vtblk_request *req)
return (error);

virtqueue_notify(vq);
virtqueue_poll(vq, NULL);
req1 = virtqueue_poll(vq, NULL);
KASSERT(req == req1,
("%s: polling completed %p not %p", __func__, req1, req));

error = vtblk_request_error(req);
bp = vtblk_queue_complete_one(sc, req);
error = bp->bio_error;
if (error && bootverbose) {
device_printf(sc->vtblk_dev,
"%s: IO error: %d\n", __func__, error);
}
if (req != &sc->vtblk_dump_request)
vtblk_request_enqueue(sc, req);

return (error);
}
Expand Down
4 changes: 0 additions & 4 deletions sys/net/debugnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,6 @@ debugnet_input_one(struct ifnet *ifp, struct mbuf *m)
m->m_len, m->m_pkthdr.len);
goto done;
}
if ((m->m_flags & M_HASFCS) != 0) {
m_adj(m, -ETHER_CRC_LEN);
m->m_flags &= ~M_HASFCS;
}
eh = mtod(m, struct ether_header *);
etype = ntohs(eh->ether_type);
if ((m->m_flags & M_VLANTAG) != 0 || etype == ETHERTYPE_VLAN) {
Expand Down
1 change: 0 additions & 1 deletion sys/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
/*
* Ethernet-specific mbuf flags.
*/
#define M_HASFCS M_PROTO5 /* FCS included at end of frame */
#define M_BRIDGE_INJECT M_PROTO6 /* if_bridge-injected frame */

/*
Expand Down
10 changes: 0 additions & 10 deletions sys/net/if_ethersubr.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,6 @@ ether_input_internal(struct ifnet *ifp, struct mbuf *m)
*/
ETHER_BPF_MTAP(ifp, m);

/*
* If the CRC is still on the packet, trim it off. We do this once
* and once only in case we are re-entered. Nothing else on the
* Ethernet receive path expects to see the FCS.
*/
if (m->m_flags & M_HASFCS) {
m_adj(m, -ETHER_CRC_LEN);
m->m_flags &= ~M_HASFCS;
}

if (!(ifp->if_capenable & IFCAP_HWSTATS))
if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);

Expand Down

0 comments on commit e090df4

Please sign in to comment.