Author: cem
Date: Sat Jun 20 17:22:46 2020
New Revision: 362439
URL: https://svnweb.freebsd.org/changeset/base/362439

Log:
  oce(4): Account and trace mbufs before handing to hw
  
  Once tx mbufs have been handed to hardware, nothing serializes the tx
  path against completion and potential use-after-free of the outbound
  mbuf.  Perform accounting and BPF tap before queueing to hardware to
  avoid this race.
  
  Submitted by: Steve Wirtz <steve_wirtz AT dell.com>
  Reviewed by:  markj, rstone
  Sponsored by: Dell EMC Isilon
  Differential Revision:        https://reviews.freebsd.org/D25364

Modified:
  head/sys/dev/oce/oce_if.c

Modified: head/sys/dev/oce/oce_if.c
==============================================================================
--- head/sys/dev/oce/oce_if.c   Sat Jun 20 15:44:15 2020        (r362438)
+++ head/sys/dev/oce/oce_if.c   Sat Jun 20 17:22:46 2020        (r362439)
@@ -1225,6 +1225,11 @@ retry:
                 */
                oce_is_pkt_dest_bmc(sc, m, &os2bmc, &m_new);
 
+               if_inc_counter(sc->ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
+               if (m->m_flags & M_MCAST)
+                       if_inc_counter(sc->ifp, IFCOUNTER_OMCASTS, 1);
+               ETHER_BPF_MTAP(sc->ifp, m);
+
                OCE_WRITE_REG32(sc, db, wq->db_offset, reg_value);
 
        } else if (rc == EFBIG) {
@@ -1400,7 +1405,7 @@ oce_start(struct ifnet *ifp)
        if (!sc->link_status)
                return;
        
-       do {
+       while (true) {
                IF_DEQUEUE(&sc->ifp->if_snd, m);
                if (m == NULL)
                        break;
@@ -1417,12 +1422,7 @@ oce_start(struct ifnet *ifp)
                        }
                        break;
                }
-               if (m != NULL)
-                       ETHER_BPF_MTAP(ifp, m);
-
-       } while (TRUE);
-
-       return;
+       }
 }
 
 
@@ -1500,10 +1500,6 @@ oce_multiq_transmit(struct ifnet *ifp, struct mbuf *m,
                        break;
                }
                drbr_advance(ifp, br);
-               if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len);
-               if (next->m_flags & M_MCAST)
-                       if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
-               ETHER_BPF_MTAP(ifp, next);
        }
 
        return 0;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to