Patch "gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check" has been added to the 5.10-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

    gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check

to the 5.10-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:
     gro-fix-napi_gro_frags-fast-gro-breakage-due-to-ip-a.patch
and it can be found in the queue-5.10 subdirectory.

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



commit a344f4693b481782f527088d053f259e48493ac5
Author: Alexander Lobakin <alobakin@xxxxx>
Date:   Mon Apr 19 12:53:06 2021 +0000

    gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check
    
    [ Upstream commit 7ad18ff6449cbd6beb26b53128ddf56d2685aa93 ]
    
    Commit 38ec4944b593 ("gro: ensure frag0 meets IP header alignment")
    did the right thing, but missed the fact that napi_gro_frags() logics
    calls for skb_gro_reset_offset() *before* pulling Ethernet header
    to the skb linear space.
    That said, the introduced check for frag0 address being aligned to 4
    always fails for it as Ethernet header is obviously 14 bytes long,
    and in case with NET_IP_ALIGN its start is not aligned to 4.
    
    Fix this by adding @nhoff argument to skb_gro_reset_offset() which
    tells if an IP header is placed right at the start of frag0 or not.
    This restores Fast GRO for napi_gro_frags() that became very slow
    after the mentioned commit, and preserves the introduced check to
    avoid silent unaligned accesses.
    
    From v1 [0]:
     - inline tiny skb_gro_reset_offset() to let the code be optimized
       more efficively (esp. for the !NET_IP_ALIGN case) (Eric);
     - pull in Reviewed-by from Eric.
    
    [0] https://lore.kernel.org/netdev/20210418114200.5839-1-alobakin@xxxxx
    
    Fixes: 38ec4944b593 ("gro: ensure frag0 meets IP header alignment")
    Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Signed-off-by: Alexander Lobakin <alobakin@xxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/core/dev.c b/net/core/dev.c
index 64f4c7ec729d..2f17a4ac82f0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5857,7 +5857,7 @@ static struct list_head *gro_list_prepare(struct napi_struct *napi,
 	return head;
 }
 
-static void skb_gro_reset_offset(struct sk_buff *skb)
+static inline void skb_gro_reset_offset(struct sk_buff *skb, u32 nhoff)
 {
 	const struct skb_shared_info *pinfo = skb_shinfo(skb);
 	const skb_frag_t *frag0 = &pinfo->frags[0];
@@ -5868,7 +5868,7 @@ static void skb_gro_reset_offset(struct sk_buff *skb)
 
 	if (!skb_headlen(skb) && pinfo->nr_frags &&
 	    !PageHighMem(skb_frag_page(frag0)) &&
-	    (!NET_IP_ALIGN || !(skb_frag_off(frag0) & 3))) {
+	    (!NET_IP_ALIGN || !((skb_frag_off(frag0) + nhoff) & 3))) {
 		NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
 		NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int,
 						    skb_frag_size(frag0),
@@ -6101,7 +6101,7 @@ gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 	skb_mark_napi_id(skb, napi);
 	trace_napi_gro_receive_entry(skb);
 
-	skb_gro_reset_offset(skb);
+	skb_gro_reset_offset(skb, 0);
 
 	ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb));
 	trace_napi_gro_receive_exit(ret);
@@ -6194,7 +6194,7 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi)
 	napi->skb = NULL;
 
 	skb_reset_mac_header(skb);
-	skb_gro_reset_offset(skb);
+	skb_gro_reset_offset(skb, hlen);
 
 	if (unlikely(skb_gro_header_hard(skb, hlen))) {
 		eth = skb_gro_header_slow(skb, hlen, 0);



[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