Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4567857pxj; Wed, 12 May 2021 08:21:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8kwPAykVVf6ItzTDXrhLWy46vv0gjQrkEQEuPEZQJ9SdIpr9MbpDTzKkoM8UAMiY42sx6 X-Received: by 2002:a17:907:781a:: with SMTP id la26mr6028105ejc.435.1620832860149; Wed, 12 May 2021 08:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620832860; cv=none; d=google.com; s=arc-20160816; b=dT2H7fu8sv9wEne+1gkBQxseFCPoVUvpWL1CPHiFQt+RCU0ge1Q50Hj2Q6Kic6BAqi M3AalGo7bqZ/nqXeMPxThPRXe97SARMkPl7hrioNsAgXaYf+m2GQcjV2rBBOcBWC4mI9 hCkeMkZ5aVe/EqAKqmyBZRQqynmZs4sm8CoqC2nYMfB2cE+nGdBreE/SqtGoaeQ5c/0Z +n69LXInJTNdsiYUgU1uKbmxhpUgXke4dF3rZcd5dZh6EQFh6GNNU3j49qCnd0QfRHZz vOzr0To0vpjc3t3AujfvSjftb/+Eh+6r8tOTpewmy02LOJ3TmiKzrTpRZDL/sA5cxVEe 0qWg== 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=T+27p57vnWFniTYc9QcddQTJOK1jUuNHZ85FZMRiKhQ=; b=AISIkXiPFyplR57Oh7VEGtLWqHhdU3IWjMbJ+mO71/EO9dmwdFKhYBmV9OFfnJgm9E e5c72DYQv3wQqFH7iytLtIB4pUK3pGpt8TSygwLyw0ccj1LLD/8Zb+k69x3KUtYhcMNK 6Lyem0TOryybmy2HvEIlGNB3RYKCGGkuzz98rK4oLmnkpvS555k9PwaPRRW6SIURXPoB +S96vTfL+YBaJnwd6OCOmO11Neu4CLC72ozDd/9dCwcMyZulDLRN+brax5lobghDsdLe cGY7JX93W0YShmVdBY0Afk3J6OyxKnvq3mq0NW7MEWsS85VQRs4DwBwn1y2R8W8Bl+by 4LyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Brw/SMaa"; 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 g16si223432ejr.663.2021.05.12.08.20.36; Wed, 12 May 2021 08:21:00 -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="Brw/SMaa"; 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 S234323AbhELPQ1 (ORCPT + 99 others); Wed, 12 May 2021 11:16:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbhELPGd (ORCPT ); Wed, 12 May 2021 11:06:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB69261492; Wed, 12 May 2021 15:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831676; bh=M/ITsn40P+MARB6DAzeE/er124OCvqchV5xbpydqlG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Brw/SMaaTxDzvmqBDlUoaTdefSOqSx6Ci6sluPnzZwgJcyxou8LQ+WcW7Uj2m87ky ax+jIsSQ4rGhyhTwsmgqhmnkyqETdtzSW9kFZHOb/7nPJYwBn092sWKFkhETi6c0m+ Br9SUAEETX48bl0H+5mwzlmQJa7qLqysro8isr90= 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.4 215/244] gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check Date: Wed, 12 May 2021 16:49:46 +0200 Message-Id: <20210512144749.877573316@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144743.039977287@linuxfoundation.org> References: <20210512144743.039977287@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 91909e5d6807..a30878346f54 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5395,7 +5395,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]; @@ -5407,7 +5407,7 @@ static void skb_gro_reset_offset(struct sk_buff *skb) if (skb_mac_header(skb) == skb_tail_pointer(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), @@ -5640,7 +5640,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); @@ -5733,7 +5733,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