From ba1362c5499d4f876b449d0947f706b65ecd690f Mon Sep 17 00:00:00 2001 From: Damien Bergamini Date: Sun, 13 Nov 2005 17:25:21 +0000 Subject: [PATCH] Be more robust when handling Rx interrupts. If we can't allocate a new mbuf, just discard the received frame and reuse the old mbuf. This should prevent the connection from stalling after high network traffic. MFC after: 2 weeks --- sys/dev/usb/if_ural.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c index 6ec1596427a6..92d103aab773 100644 --- a/sys/dev/usb/if_ural.c +++ b/sys/dev/usb/if_ural.c @@ -846,7 +846,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ural_rx_desc *desc; struct ieee80211_frame *wh; struct ieee80211_node *ni; - struct mbuf *m; + struct mbuf *mnew, *m; int len; if (status != USBD_NORMAL_COMPLETION) { @@ -880,8 +880,17 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) goto skip; } - /* finalize mbuf */ + mnew = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (mnew == NULL) { + ifp->if_ierrors++; + goto skip; + } + m = data->m; + data->m = mnew; + data->buf = mtod(data->m, uint8_t *); + + /* finalize mbuf */ m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = (le32toh(desc->flags) >> 16) & 0xfff; m->m_flags |= M_HASFCS; /* hardware appends FCS */ @@ -895,15 +904,6 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) /* node is no longer needed */ ieee80211_free_node(ni); - data->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (data->m == NULL) { - printf("%s: could not allocate rx mbuf\n", - USBDEVNAME(sc->sc_dev)); - return; - } - - data->buf = mtod(data->m, uint8_t *); - DPRINTFN(15, ("rx done\n")); skip: /* setup a new transfer */