Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ecd09dd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: ftgmac100/ftmac100: dont pull too much data



Drivers should pull only ethernet header from page frag
to skb->head.

Pulling 64 bytes is too much for TCP (without options) on IPv4.

However, it makes sense to pull all the frame if it fits the
128 bytes bloc allocated for skb->head, to free one page per
small incoming frame.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Po-Yu Chuang <ratbert@faraday-tech.com>
Acked-by: default avatarYan-Pai Chen <yanpai.chen@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent db8dacf9
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -479,9 +479,14 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
		rxdes = ftgmac100_current_rxdes(priv);
		rxdes = ftgmac100_current_rxdes(priv);
	} while (!done);
	} while (!done);


	if (skb->len <= 64)
	/* Small frames are copied into linear part of skb to free one page */
	if (skb->len <= 128) {
		skb->truesize -= PAGE_SIZE;
		skb->truesize -= PAGE_SIZE;
	__pskb_pull_tail(skb, min(skb->len, 64U));
		__pskb_pull_tail(skb, skb->len);
	} else {
		/* We pull the minimum amount into linear part */
		__pskb_pull_tail(skb, ETH_HLEN);
	}
	skb->protocol = eth_type_trans(skb, netdev);
	skb->protocol = eth_type_trans(skb, netdev);


	netdev->stats.rx_packets++;
	netdev->stats.rx_packets++;
+7 −4
Original line number Original line Diff line number Diff line
@@ -441,11 +441,14 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
	skb->len += length;
	skb->len += length;
	skb->data_len += length;
	skb->data_len += length;


	/* page might be freed in __pskb_pull_tail() */
	if (length > 128) {
	if (length > 64)
		skb->truesize += PAGE_SIZE;
		skb->truesize += PAGE_SIZE;
	__pskb_pull_tail(skb, min(length, 64));
		/* We pull the minimum amount into linear part */

		__pskb_pull_tail(skb, ETH_HLEN);
	} else {
		/* Small frames are copied into linear part to free one page */
		__pskb_pull_tail(skb, length);
	}
	ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);
	ftmac100_alloc_rx_page(priv, rxdes, GFP_ATOMIC);


	ftmac100_rx_pointer_advance(priv);
	ftmac100_rx_pointer_advance(priv);