RE: [PATCH] usbnet: remove generic hard_header_len check

From: David Laight
Date: Thu Feb 13 2014 - 06:49:40 EST


From: Emil Goode
> > > int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> > > {
> > > + /* This check is no longer done by usbnet */
> > > + if (skb->len < dev->net->hard_header_len)
> > > + return 0;
> > > +
> >
> > Wouldn't it be better to test against ETH_HLEN, since that is a constant
> > and "obviously correct" in this case?
>
> Some minidrivers change the default hard_header_len value so using it
> guarantees that the patch will not make any change to how the code is
> currently working. Using ETH_HLEN could be more informative about what
> the minidriver should check before passing skbs to usbnet_skb_return().
> Then I think the comment should be changed as well. My intention was to
> not make any changes that affect how the code works for devices I cannot
> test, but I think either way is fine and if you insist on changing it
> let me know.

I think that test is to ensure that the data passed to the mini-driver
contains the ethernet frame encapsulation header (this typically
contains the actual frame length and some flags) so that the minidriver
won't read off the end of the usb data.

Any check for stupidly short ethernet frames would be later on.
IIRC the absolute minimum 802.3 ethernet frame is 17 bytes
(after frame padding has been stripped).

David