Patch "net: macb: fix PTP TX timestamp failure due to packet padding" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: macb: fix PTP TX timestamp failure due to packet padding

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-macb-fix-ptp-tx-timestamp-failure-due-to-packet-.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c2075f1ab6177fa27c8cfc2bd8db66187e054fd0
Author: Robert Hancock <robert.hancock@xxxxxxxxxx>
Date:   Mon Jan 16 15:41:33 2023 -0600

    net: macb: fix PTP TX timestamp failure due to packet padding
    
    [ Upstream commit 7b90f5a665acd46efbbfa677a3a3a18d01ad6487 ]
    
    PTP TX timestamp handling was observed to be broken with this driver
    when using the raw Layer 2 PTP encapsulation. ptp4l was not receiving
    the expected TX timestamp after transmitting a packet, causing it to
    enter a failure state.
    
    The problem appears to be due to the way that the driver pads packets
    which are smaller than the Ethernet minimum of 60 bytes. If headroom
    space was available in the SKB, this caused the driver to move the data
    back to utilize it. However, this appears to cause other data references
    in the SKB to become inconsistent. In particular, this caused the
    ptp_one_step_sync function to later (in the TX completion path) falsely
    detect the packet as a one-step SYNC packet, even when it was not, which
    caused the TX timestamp to not be processed when it should be.
    
    Using the headroom for this purpose seems like an unnecessary complexity
    as this is not a hot path in the driver, and in most cases it appears
    that there is sufficient tailroom to not require using the headroom
    anyway. Remove this usage of headroom to prevent this inconsistency from
    occurring and causing other problems.
    
    Fixes: 653e92a9175e ("net: macb: add support for padding and fcs computation")
    Signed-off-by: Robert Hancock <robert.hancock@xxxxxxxxxx>
    Reviewed-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>
    Tested-by: Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx> # on SAMA7G5
    Reviewed-by: Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 78219a9943a7..d948b582f4c9 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -1752,7 +1752,6 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
 	bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) ||
 		      skb_is_nonlinear(*skb);
 	int padlen = ETH_ZLEN - (*skb)->len;
-	int headroom = skb_headroom(*skb);
 	int tailroom = skb_tailroom(*skb);
 	struct sk_buff *nskb;
 	u32 fcs;
@@ -1766,9 +1765,6 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
 		/* FCS could be appeded to tailroom. */
 		if (tailroom >= ETH_FCS_LEN)
 			goto add_fcs;
-		/* FCS could be appeded by moving data to headroom. */
-		else if (!cloned && headroom + tailroom >= ETH_FCS_LEN)
-			padlen = 0;
 		/* No room for FCS, need to reallocate skb. */
 		else
 			padlen = ETH_FCS_LEN;
@@ -1777,10 +1773,7 @@ static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
 		padlen += ETH_FCS_LEN;
 	}
 
-	if (!cloned && headroom + tailroom >= padlen) {
-		(*skb)->data = memmove((*skb)->head, (*skb)->data, (*skb)->len);
-		skb_set_tail_pointer(*skb, (*skb)->len);
-	} else {
+	if (cloned || tailroom < padlen) {
 		nskb = skb_copy_expand(*skb, 0, padlen, GFP_ATOMIC);
 		if (!nskb)
 			return -ENOMEM;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux