Author: zbb
Date: Thu Mar 31 13:23:43 2016
New Revision: 297453
URL: https://svnweb.freebsd.org/changeset/base/297453

Log:
  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

Modified:
  head/sys/dev/vnic/nicvf_main.c

Modified: head/sys/dev/vnic/nicvf_main.c
==============================================================================
--- head/sys/dev/vnic/nicvf_main.c      Thu Mar 31 13:20:02 2016        
(r297452)
+++ head/sys/dev/vnic/nicvf_main.c      Thu Mar 31 13:23:43 2016        
(r297453)
@@ -661,12 +661,6 @@ nicvf_if_transmit(struct ifnet *ifp, str
 
        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, str
        }
 
        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);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to