PERFORCE change 127408 for review

Kip Macy kmacy at FreeBSD.org
Thu Oct 11 21:01:46 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=127408

Change 127408 by kmacy at kmacy_home:ethng on 2007/10/12 04:00:59

	initialize pkthdr len in packet batching case as well with value of first packet

Affected files ...

.. //depot/projects/ethng/src/sys/dev/cxgb/sys/uipc_mvec.c#16 edit

Differences ...

==== //depot/projects/ethng/src/sys/dev/cxgb/sys/uipc_mvec.c#16 (text+ko) ====

@@ -171,13 +171,15 @@
 int
 busdma_map_sg_collapse(struct mbuf **m, bus_dma_segment_t *segs, int *nsegs)
 {
-	struct mbuf *m0, *n = *m, *mhead;
+	struct mbuf *m0, *mhead, *n = *m;
 	struct mbuf_iovec *mi;
 	struct mbuf *marray[TX_MAX_SEGS];
 	int i, type, seg_count, defragged = 0, err = 0;
 	struct mbuf_vec *mv;
 	uma_zone_t zone;
 
+	KASSERT(n->m_pkthdr.len, ("packet has zero header len"));
+		
 	if (n->m_flags & M_PKTHDR && !SLIST_EMPTY(&n->m_pkthdr.tags)) 
 		m_tag_delete_chain(n, NULL);
 
@@ -277,6 +279,7 @@
 	
 	memcpy(m0, *m, sizeof(struct m_hdr) + sizeof(struct pkthdr));
 	m0->m_type = type;
+	KASSERT(m0->m_pkthdr.len, ("empty packet being marshalled"));
 	mv = mtomv(m0);
 	mv->mv_count = seg_count;
 	mv->mv_first = 0;
@@ -326,6 +329,7 @@
 	}
 
 	m0->m_flags = 0;
+	m0->m_pkthdr.len = m0->m_len = (*m)->m_len; /* not the real length but needs to be non-zero */
 	mv = mtomv(m0);
 	mv->mv_count = count;
 	mv->mv_first = 0;
@@ -334,6 +338,7 @@
 			m_tag_delete_chain(*mp, NULL);
 		busdma_map_mbuf_fast(*mp, segs);
 		_mcl_collapse_mbuf(mi, *mp);
+		KASSERT(mi->mi_len, ("empty packet"));
 	}
 
 	for (mp = m, i = 0; i < count; i++, mp++) {


More information about the p4-projects mailing list