Don't omit m_dup() for non-writeable mbufs that need checksum calculation

If the driver is not active or link is down the packet could remain
non-writeable. This commit makes all mbufs enqueued to the driver's
ring buffer to have correct attributes.

Pointed out by: wma
Reviewed by:    wma
Obtained from:  Semihalf
Sponsored by:   Cavium
Differential Revision: https://reviews.freebsd.org/D5800
This commit is contained in:
Zbigniew Bodek 2016-03-31 13:23:43 +00:00
parent 9b0488ed2a
commit 36a947e91e

View File

@ -661,12 +661,6 @@ nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
sq = &qs->sq[qidx];
if (((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING) || !nic->link_up) {
err = drbr_enqueue(ifp, sq->br, mbuf);
return (err);
}
if (mbuf->m_next != NULL &&
(mbuf->m_pkthdr.csum_flags &
(CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_SCTP)) != 0) {
@ -680,8 +674,15 @@ nicvf_if_transmit(struct ifnet *ifp, struct mbuf *mbuf)
}
err = drbr_enqueue(ifp, sq->br, mbuf);
if (err != 0)
if (((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING) || !nic->link_up || (err != 0)) {
/*
* Try to enqueue packet to the ring buffer.
* If the driver is not active, link down or enqueue operation
* failed, return with the appropriate error code.
*/
return (err);
}
if (NICVF_TX_TRYLOCK(sq) != 0) {
err = nicvf_xmit_locked(sq);