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

Commit 99bc5c92 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'eth_skb_pad'



Alexander Duyck says:

====================
net: Add helper for padding short Ethernet frames

This patch series adds a pair of helpers to pad short Ethernet frames.  The
general idea is to clean up a number of code paths that were all writing
their own versions of the same or similar function.

An added advantage is that this will help to discourage introducing new
bugs as in at least one case I found the skb->len had been updated, but the
tail pointer update was overlooked.

v2: Added skb_put_padto for cases where length is not ETH_ZLEN
    Updated intel drivers and emulex driver to use skb_put_padto
    Updated eth_skb_pad to use skb_put_padto
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 177211b9 207c5f44
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1017,9 +1017,8 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
	 * to pad short packets (<= 32 bytes) to a 36-byte length.
	 */
	if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) {
		if (skb_padto(skb, 36))
		if (skb_put_padto(skb, 36))
			return NULL;
		skb->len = 36;
	}

	if (BEx_chip(adapter) || lancer_chip(adapter)) {
+2 −6
Original line number Diff line number Diff line
@@ -3136,12 +3136,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
	 * 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))
	if (eth_skb_pad(skb))
		return NETDEV_TX_OK;
		skb->len = ETH_ZLEN;
		skb_set_tail_pointer(skb, ETH_ZLEN);
	}

	mss = skb_shinfo(skb)->gso_size;
	/* The controller does a simple calculation to
+2 −6
Original line number Diff line number Diff line
@@ -5554,12 +5554,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
	/* The minimum packet size with TCTL.PSP set is 17 bytes so
	 * pad skb in order to meet this minimum size requirement
	 */
	if (unlikely(skb->len < 17)) {
		if (skb_pad(skb, 17 - skb->len))
	if (skb_put_padto(skb, 17))
		return NETDEV_TX_OK;
		skb->len = 17;
		skb_set_tail_pointer(skb, 17);
	}

	mss = skb_shinfo(skb)->gso_size;
	if (mss) {
+3 −8
Original line number Diff line number Diff line
@@ -578,14 +578,9 @@ static bool fm10k_cleanup_headers(struct fm10k_ring *rx_ring,
	if (skb_is_nonlinear(skb))
		fm10k_pull_tail(rx_ring, rx_desc, skb);

	/* if skb_pad returns an error the skb was freed */
	if (unlikely(skb->len < 60)) {
		int pad_len = 60 - skb->len;

		if (skb_pad(skb, pad_len))
	/* if eth_skb_pad returns an error the skb was freed */
	if (eth_skb_pad(skb))
		return true;
		__skb_put(skb, pad_len);
	}

	return false;
}
+2 −6
Original line number Diff line number Diff line
@@ -2399,12 +2399,8 @@ netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
	/* hardware can't handle really short frames, hardware padding works
	 * beyond this point
	 */
	if (unlikely(skb->len < I40E_MIN_TX_LEN)) {
		if (skb_pad(skb, I40E_MIN_TX_LEN - skb->len))
	if (skb_put_padto(skb, I40E_MIN_TX_LEN))
		return NETDEV_TX_OK;
		skb->len = I40E_MIN_TX_LEN;
		skb_set_tail_pointer(skb, I40E_MIN_TX_LEN);
	}

	return i40e_xmit_frame_ring(skb, tx_ring);
}
Loading