Subject: Re: [net] e1000: Small packets may get corrupted during padding by HW

From: Alexander Duyck <[email-masked]>
Date: Mon, 17 Sep 2012 12:40:59 -0700

On 09/15/2012 01:44 PM, Michał Mirosław wrote:
> 2012/9/15 Jeff Kirsher <[email-masked]>:
>> From: Tushar Dave <[email-masked]>
>>
>> On PCI/PCI-X HW, if packet size is less than ETH_ZLEN,
>> packets may get corrupted during padding by HW.
>> To WA this issue, pad all small packets manually.
>>
>> Signed-off-by: Tushar Dave <[email-masked]>
>> Tested-by: Aaron Brown <[email-masked]>
>> Signed-off-by: Jeff Kirsher <[email-masked]>
>> ---
>>  drivers/net/ethernet/intel/e1000/e1000_main.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
>> index 3bfbb8d..bde337e 100644
>> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
>> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
>> @@ -3149,6 +3149,17 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
>>                 return NETDEV_TX_OK;
>>         }
>>
>> +       /* On PCI/PCI-X HW, if packet size is less than ETH_ZLEN,
>> +        * packets may get corrupted during padding by HW.
>> +        * To WA this issue, pad all small packets manually.
>> +        */
>> +       if (skb->len < ETH_ZLEN) {
>> +               if (skb_pad(skb, ETH_ZLEN - skb->len))
>> +                       return NETDEV_TX_OK;
>> +               skb->len = ETH_ZLEN;
>> +               skb_set_tail_pointer(skb, ETH_ZLEN);
>> +       }
>> +
> Isn't there a skb_padto() that does just this?
>
> Best Regards,
> Michał Mirosław
>
The problem is skb_padto() doesn't update the packet length, it just
adds the padding but doesn't do anything to account for it.

Thanks,

Alex