From 72c9514b3fe03e2af58b7386b4ea1b1b8d03bb73 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sun, 13 Sep 2009 14:42:53 +0000 Subject: M_DUP_PKTHDR() define -> m_dup_pkthdr() function to properly deal with m_tag_copy_chain() failures. Use m_defrag() to eliminate hand rolled defragging of mbufs and some uses of M_DUP_PKTHDR(). Original diff from thib@, claudio@'s feedback integrated by me. Tests kevlo@ claudio@, "reads ok" blambert@ ok thib@ claudio@, "m_defrag() bits ok" kettenis@ --- sys/dev/ic/bwi.c | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'sys/dev/ic/bwi.c') diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c index 027b20d03ff..b4115985ad8 100644 --- a/sys/dev/ic/bwi.c +++ b/sys/dev/ic/bwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwi.c,v 1.90 2009/08/02 19:33:01 blambert Exp $ */ +/* $OpenBSD: bwi.c,v 1.91 2009/09/13 14:42:52 krw Exp $ */ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. @@ -8849,40 +8849,11 @@ bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m, } if (error) { /* error == EFBIG */ - struct mbuf *m_new; - - error = 0; - - MGETHDR(m_new, M_DONTWAIT, MT_DATA); - if (m_new == NULL) { - m_freem(m); - error = ENOBUFS; + if (m_defrag(m, M_DONTWAIT)) { printf("%s: can't defrag TX buffer\n", sc->sc_dev.dv_xname); goto back; } - - M_DUP_PKTHDR(m_new, m); - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m_new, M_DONTWAIT); - if (!(m_new->m_flags & M_EXT)) { - m_freem(m); - m_freem(m_new); - error = ENOBUFS; - } - } - - if (error) { - printf("%s: can't defrag TX buffer\n", - sc->sc_dev.dv_xname); - goto back; - } - - m_copydata(m, 0, m->m_pkthdr.len, mtod(m_new, caddr_t)); - m_freem(m); - m_new->m_len = m_new->m_pkthdr.len; - m = m_new; - error = bus_dmamap_load_mbuf(sc->sc_dmat, tb->tb_dmap, m, BUS_DMA_NOWAIT); if (error) { -- cgit v1.2.3