From 36a947e91e79ba80640f63ed5d79fd41c131bed1 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Thu, 31 Mar 2016 13:23:43 +0000 Subject: [PATCH] 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 --- sys/dev/vnic/nicvf_main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c index 8a33804ddd0..5b74ac9ea8f 100644 --- a/sys/dev/vnic/nicvf_main.c +++ b/sys/dev/vnic/nicvf_main.c @@ -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);