mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
net: Add functions for handling padding frame and adding to length
This patch adds two new helper functions skb_put_padto and eth_skb_pad. These functions deviate from the standard skb_pad or skb_padto in that they will also update the length and tail pointers so that they reflect the padding added to the frame. The eth_skb_pad helper is meant to be used with Ethernet devices to update either Rx or Tx frames so that they report the correct size. The skb_put_padto helper is meant to be used primarily in the transmit path for network devices that need frames to be padded up to some minimum size and don't wish to simply update the length somewhere external to the frame. The motivation behind this is that there are a number of implementations throughout the network device drivers that are all doing the same thing, but each a little bit differently and as a result several implementations contain bugs such as updating the length without updating the tail offset and other similar issues. Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
177211b993
commit
9c0c112422
2 changed files with 35 additions and 1 deletions
|
@ -392,4 +392,16 @@ static inline unsigned long compare_ether_header(const void *a, const void *b)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* eth_skb_pad - Pad buffer to mininum number of octets for Ethernet frame
|
||||
* @skb: Buffer to pad
|
||||
*
|
||||
* An Ethernet frame should have a minimum size of 60 bytes. This function
|
||||
* takes short frames and pads them with zeros up to the 60 byte limit.
|
||||
*/
|
||||
static inline int eth_skb_pad(struct sk_buff *skb)
|
||||
{
|
||||
return skb_put_padto(skb, ETH_ZLEN);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_ETHERDEVICE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue