On Thu, Mar 30, 2017 at 12:47:35AM +0200, Mark Kettenis wrote:
> Looking at the code, it is possible for the device to return a packet
> that is larger than what fits into a standard 2k mbuf cluster.  So
> let's replace the handrolled mbuf allocation./copy code with an
> invocation of m_devget(9), which will make sure a chain is allocated
> for large packets.
> 
> Lightly tested on my Odroid XU4.
> 
> ok?

ok.  Works on my 100mbit ure things too.

> 
> 
> Index: dev/usb/if_ure.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_ure.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 if_ure.c
> --- dev/usb/if_ure.c  11 Mar 2017 13:40:46 -0000      1.4
> +++ dev/usb/if_ure.c  29 Mar 2017 22:41:26 -0000
> @@ -118,7 +118,6 @@ void              ure_rxeof(struct usbd_xfer *, void
>  void         ure_txeof(struct usbd_xfer *, void *, usbd_status);
>  int          ure_rx_list_init(struct ure_softc *);
>  int          ure_tx_list_init(struct ure_softc *);
> -struct mbuf *        ure_newbuf(void);
>  
>  void         ure_tick_task(void *);
>  void         ure_tick(void *);
> @@ -1299,17 +1298,13 @@ ure_rxeof(struct usbd_xfer *xfer, void *
>               total_len -= pktlen;
>               buf += sizeof(rxhdr);
>  
> -             m = ure_newbuf();
> +             m = m_devget(buf, pktlen, ETHER_ALIGN);
>               if (m == NULL) {
>                       DPRINTF(("unable to allocate mbuf for next packet\n"));
>                       ifp->if_ierrors++;
>                       goto done;
>               }
>  
> -             m->m_pkthdr.len = m->m_len = pktlen;
> -             m_adj(m, ETHER_ALIGN);
> -
> -             memcpy(mtod(m, char *), buf, pktlen);
>               ml_enqueue(&ml, m);
>       } while (total_len > 0);
>  
> @@ -1428,24 +1423,6 @@ ure_rx_list_init(struct ure_softc *sc)
>       }
>  
>       return 0;
> -}
> -
> -struct mbuf *
> -ure_newbuf(void)
> -{
> -     struct mbuf *m;
> -
> -     MGETHDR(m, M_DONTWAIT, MT_DATA);
> -     if (m == NULL)
> -             return NULL;
> -
> -     MCLGET(m, M_DONTWAIT);
> -     if (!(m->m_flags & M_EXT)) {
> -             m_freem(m);
> -             return NULL;
> -     }
> -
> -     return m;
>  }
>  
>  int
> 

  • ure(4) fix Mark Kettenis
    • Re: ure(4) fix Jonathan Matthew

Reply via email to