Subject: Re: NetBSD/xen network problems (need help)
To: Andreas Wrede <andreas@planix.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-xen
Date: 03/16/2006 21:20:58
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
can you try the attached patch ? obviously m_copyback() doesn't work
the way I though it was, and as it's not even capable of allocating
a cluster when needeed it's probably less efficient than plain MCLGET/memcpy.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff
Index: if_xennet.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/xen/if_xennet.c,v
retrieving revision 1.43
diff -u -r1.43 if_xennet.c
--- if_xennet.c 6 Mar 2006 22:04:18 -0000 1.43
+++ if_xennet.c 16 Mar 2006 20:18:49 -0000
@@ -787,16 +787,21 @@
* memory, copy data and push the receive
* buffer back to the hypervisor.
*/
- m->m_len = MHLEN;
- m->m_pkthdr.len = 0;
- m_copyback(m, 0, rx->status, pktp);
- xennet_rx_push_buffer(sc, rx->id);
- if (m->m_pkthdr.len < rx->status) {
- /* out of memory, just drop packets */
- ifp->if_ierrors++;
- m_freem(m);
- continue;
+ if (rx->status > MHLEN) {
+ MCLGET(m, M_DONTWAIT);
+ if (__predict_false(
+ (m->m_flags & M_EXT) == 0)) {
+ /* out of memory, just drop packets */
+ ifp->if_ierrors++;
+ m_freem(m);
+ xennet_rx_push_buffer(sc, rx->id);
+ continue;
+ }
}
+
+ m->m_len = m->m_pkthdr.len = rx->status;
+ memcpy(mtod(m, void *), pktp, rx->status);
+ xennet_rx_push_buffer(sc, rx->id);
}
#ifdef XENNET_DEBUG_DUMP
--sdtB3X0nJg68CQEu--