Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4750924pxj; Wed, 12 May 2021 12:23:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq8aL+mtY8emGhZIPDtWC6RDm+iASuEHLBOJViIf7hzzhnUSxzPoopxwPHdtBUqELiyMyC X-Received: by 2002:a05:6402:100c:: with SMTP id c12mr27904032edu.165.1620847387489; Wed, 12 May 2021 12:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847387; cv=none; d=google.com; s=arc-20160816; b=cuUEHy7R6Bbckfabt6aNE6PZjS95JPo73KY/Dx3KHs/3mASfCepFgspqSJ/7G1To/z TNpL45WeiwtfdOoLZSsfb980K96T5BrVnINzliQbTa1I0SdBdCeu1GT6BPmFmoHSMcCv x6xRelS043rxXrUR7MMt92MtOCi2jQCFTr2HQbhXZ0jacVqY8O62BjdtXI/Rzf3ilIKi /C1QzgJXiIeFx9uV+lseHuphR1Sl1u/yqlPuz6Qox0FzL93DtM8e370Rz15o9n8Fw7it AADPwhsYt5wrm7uB9DAmWRqABHiOhXvLHiQuXKJU6d95S4abN+MHwBkPhKf/05S1EAY8 DmfA== 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=6biKdUfNYyCEMOHuDYV7ThynJd9gmrLTr5708Vmcsqw=; b=p8y0EiKx0FRs7xWzgCsGKEMU5kqTVnK5ksCx/ToF8BIAI/IQB9uycCt/9FHV9rSdsR hbuUJY25s5AKmmJkqplXNaWkICIl1Ls6nAjKQRVgA6pUQtWFZtOZaSxa4/XVxlVcfc6F ynqJCAQWm8l6EhTQQLCbWQAnp7Ac9ifvGN8TDwvOhqD69pl6/f543yKwkmrXzTo9n8pT xPKJ3HavY2VuhnW2UHi6NSbCr+MfPqpaLpPEiBVk/dS19p/sE7YdE3btJsGDxvxXvNr+ 0rjbcWt9L+GKEBD0mAs/GFXbusknzre1iHQWdQPCuBSd08BqgRw5fHeA6DBzgi56gvvZ NKBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="z/Qpwx87"; 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 d25si699635eje.106.2021.05.12.12.22.42; Wed, 12 May 2021 12:23:07 -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="z/Qpwx87"; 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 S1378486AbhELTRB (ORCPT + 99 others); Wed, 12 May 2021 15:17:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235326AbhELQrY (ORCPT ); Wed, 12 May 2021 12:47:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E77E461E7C; Wed, 12 May 2021 16:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620836123; bh=2G6sAQ0hTQ1PcU5WDpQLPQrstJqlBOFsUd9mPI4SJd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z/Qpwx87kw8Emxb7dELak+/bhufwe8ONwcu4kFamW92kf/BnLai4B9R8z8wMnlaGs itHLSg+0ZnzKqK+3BjdNnc4rZTychbbzTQdo+EcH0xHRQvNGEHNQ6gj4eXnLBy7Wip ObUtqVIMUN6uQJLUK/L4ZZUj6Kcee8VZvMDMoTgQ= 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.12 602/677] gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check Date: Wed, 12 May 2021 16:50:48 +0200 Message-Id: <20210512144857.366639294@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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 1f79b9aa9a3f..15fe36332fb8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5914,7 +5914,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]; @@ -5925,7 +5925,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), @@ -6143,7 +6143,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); @@ -6232,7 +6232,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