Commit 2ccd0b19 authored by Ben Hutchings's avatar Ben Hutchings

sfc: Copy RX prefix into skb head area in efx_rx_mk_skb()

We can potentially pull the entire packet contents into the head area
and then free the page it was in.  In order to read an inline
timestamp safely, we need to copy the prefix into the head area as
well.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 9ec06595
...@@ -521,15 +521,6 @@ enum nic_state { ...@@ -521,15 +521,6 @@ enum nic_state {
STATE_RECOVERY = 3, /* device recovering from PCI error */ STATE_RECOVERY = 3, /* device recovering from PCI error */
}; };
/*
* Alignment of the skb->head which wraps a page-allocated RX buffer
*
* The skb allocated to wrap an rx_buffer can have this alignment. Since
* the data is memcpy'd from the rx_buf, it does not need to be equal to
* NET_IP_ALIGN.
*/
#define EFX_PAGE_SKB_ALIGN 2
/* Forward declaration */ /* Forward declaration */
struct efx_nic; struct efx_nic;
......
...@@ -476,14 +476,18 @@ static struct sk_buff *efx_rx_mk_skb(struct efx_channel *channel, ...@@ -476,14 +476,18 @@ static struct sk_buff *efx_rx_mk_skb(struct efx_channel *channel,
struct sk_buff *skb; struct sk_buff *skb;
/* Allocate an SKB to store the headers */ /* Allocate an SKB to store the headers */
skb = netdev_alloc_skb(efx->net_dev, hdr_len + EFX_PAGE_SKB_ALIGN); skb = netdev_alloc_skb(efx->net_dev,
efx->rx_ip_align + efx->rx_prefix_size +
hdr_len);
if (unlikely(skb == NULL)) if (unlikely(skb == NULL))
return NULL; return NULL;
EFX_BUG_ON_PARANOID(rx_buf->len < hdr_len); EFX_BUG_ON_PARANOID(rx_buf->len < hdr_len);
skb_reserve(skb, EFX_PAGE_SKB_ALIGN); memcpy(skb->data + efx->rx_ip_align, eh - efx->rx_prefix_size,
memcpy(__skb_put(skb, hdr_len), eh, hdr_len); efx->rx_prefix_size + hdr_len);
skb_reserve(skb, efx->rx_ip_align + efx->rx_prefix_size);
__skb_put(skb, hdr_len);
/* Append the remaining page(s) onto the frag list */ /* Append the remaining page(s) onto the frag list */
if (rx_buf->len > hdr_len) { if (rx_buf->len > hdr_len) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment