Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630225pxj; Wed, 12 May 2021 09:36:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmSHXLMzVKk6yoxOkcPL03cf6f5s7dAKuBzcO1pwhwx0Gr3VZWm73vl+AH4MFK/2hHKOc+ X-Received: by 2002:a05:6402:1354:: with SMTP id y20mr44860429edw.115.1620837392005; Wed, 12 May 2021 09:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837391; cv=none; d=google.com; s=arc-20160816; b=jmVPgnDlOMTsgFG1RLXoPQFpgktxVQOPdYxp4//wZa2MHopyfpvw/kqev6Pvj2DCXR cd47VGR+UjlJOcqmAlTv+qD+6NujkuxOV6y0Xf9d8p1kKRDLIcbsMpeXUECxyXQaoQx4 NZKQKFXlpaDmrKq3YTu1G6RmIyI2+vgiYB5ibSNjb3Xh44ho0ZuHXFhWFonr9bDcDnZ/ JaRIYbfXxfIW2lnJYhN0T1nrxp8s2jMY+gt1xosevtGjKDvO/N/GFr610QI+9a2oRMP0 h0NQqoIPlzj4/ulSARfKtFXXWPpJOZWunEBDXiCA3DbWMvif+qs9ng8x1cp+STzn/rW2 a30g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iG67FdH83eFXEAveQD3uEGPSz1JmJNI80gKbsVlIpZU=; b=BDrXe6ZQNRYt/yIDAzWhFTOVWlWIsYFT/2pjYv3IWnSltLv5t36HnTgBImHHFxtZ5y zTVt1dvjlbbLetNn24IxAMmCApyX+kqGTIabEkgYJ75+XkV018P1z4ZUcDbVqgpBmhSZ 9CicrwrONCFjPuPMD6fzOBdjjqfJq6c2lzQ4pwErfvQwBihimyPilAsDpiQUKJMq1QpK XvnHCnV1z8f9xgydqa3YaSUu/uM0GPKBP417T2U5uUhCFgKoYEVUw+EQrV5gLhmBALk+ vb+YzShCfhynyjydRjNeVi8nZYLmSWmKw8/nSz7fbzeBwUyvzipWETUxErOt6NKcIFUU uEMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mL7zbhWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k9si461611eje.640.2021.05.12.09.36.07; Wed, 12 May 2021 09:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mL7zbhWo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242272AbhELQeA (ORCPT + 99 others); Wed, 12 May 2021 12:34:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbhELPla (ORCPT ); Wed, 12 May 2021 11:41:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C61C61419; Wed, 12 May 2021 15:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832902; bh=IxcVmoEDSOcLe6wKdiFuAwZ2BzGHj9LWnYjuVFfoxSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mL7zbhWoz5c3T/tPLcEd55qi70fvNeAzwC5a2Vgtr8Pr6zu2og0rSSvPnWbkwypKo Q46oKl38lJplveHAeP6gMgTMgzmTLFqqh0MLm0WBWD87d2kasyWa0b/1/34TSUI1vV P03VW/IoUI8OLpBg9aIBFnB39tw26P4BWEUDzDiE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Alexander Lobakin , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 469/530] gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check Date: Wed, 12 May 2021 16:49:39 +0200 Message-Id: <20210512144835.177370972@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Lobakin [ 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@pm.me Fixes: 38ec4944b593 ("gro: ensure frag0 meets IP header alignment") Reviewed-by: Eric Dumazet Signed-off-by: Alexander Lobakin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -- 2.30.2