Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1716043pxb; Sun, 18 Apr 2021 04:51:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/jBt9JCtIeIJylA86LEJLJh6WMN8qAUlWW0BphEI90rFf3z18EYCv2zZn9n90CsWeRY+g X-Received: by 2002:a63:aa06:: with SMTP id e6mr7074567pgf.178.1618746702461; Sun, 18 Apr 2021 04:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618746702; cv=none; d=google.com; s=arc-20160816; b=0CzC+obk+OYD5rElRqoCazv7ME/V65pOVAcQPgWX/oh6FT7h9sPE1IBd8CdeV4RNfH 89G1XBeOeVGN71yc1GMCwbsK/feX8oBsByXZ07uzufKXvadwljI+VCBaRfpppFjU6gUq g3t1GzeCFeYpmDWcmFhCShxiUKPOJ/hUNmivbT7Eqsc4RX/ELtMvy1l2dhusNveS4CMM CrW6czhy+pH5PiSLgPCY03ZT9jhE3cG1TjfTBqBZqXp8fSNXZ9+yYvDsmmD+J2SGD+zI Su7EpxG4YYqLUMLcCcQ7IaQtHCUaxGWmCobs+kLc6BeIn+ni02D33AuzeuUyt0YAVhJb Geqw== 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 :message-id:subject:reply-to:cc:from:to:dkim-signature:date; bh=uFGkfd6SSEGyPUyf0IwGBqQSMt0EHtgOF4jDCcrsprA=; b=oyqyarnDP5/lpiQpAIW6s+GKpZYvZuv8DYcsQ1dndfdjBrntfmu4oHmyIzHmKJszuz 4OWJEqWOdVMrkySKp3fRl8AB8iwGPglKQdAz52reiC+CvWtcKADy+0XCA6M14Pd8xNb1 Suhk1jwV4UNB8WgMMingy2hVEPjuY3puOJxkj0V0Jd8063ucMjCjCbozDHdjhRltIS0p q8s+QovF6Hv/CBfqVCxJzRvRLuuA0TfxkeRmdHcN27MH7hHMhD8DVYDjn7GdgPiXO5qJ 0sJfCXp2Av+iCm9JyhRzP66VGX6BgqMul4/Rbv4KhfFJMuNqe7cRFQ694QuiUT7C9uHx mfqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=OCDgkUQx; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si14437771pln.80.2021.04.18.04.51.25; Sun, 18 Apr 2021 04:51:42 -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=@pm.me header.s=protonmail header.b=OCDgkUQx; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbhDRLnd (ORCPT + 99 others); Sun, 18 Apr 2021 07:43:33 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:52070 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhDRLnb (ORCPT ); Sun, 18 Apr 2021 07:43:31 -0400 Date: Sun, 18 Apr 2021 11:42:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1618746181; bh=uFGkfd6SSEGyPUyf0IwGBqQSMt0EHtgOF4jDCcrsprA=; h=Date:To:From:Cc:Reply-To:Subject:From; b=OCDgkUQxPBc75HEKHfPWHcuo79aNHy6390QgJujnEubklCI857H1O2zOn1BXBYAud xh3SYKREtiBNzTlQwGaS1+p3pfyWSoIEa34INqo05sRCj/QPwxk249SMHpPWY2ClVC E2jKvtYiYDGeLM+uNfXiKivd0Cpl5LFaa40kh4SVZTsUD2gESceyXX5+Zz4QgRsFfm gCBir0x/0t9zRWDOqj+xdzHa1l4l4h0Cq31KpkbLLIxtPW0Ng8ATsRB8VvFyNmBrkz J+ePLL354nJR0HFLfGvTOZjxmQslqppFPtdT7wjSVC8DD1QTp/gVxIz0zyCt85tBG7 nqF4hhIve8CWA== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eric Dumazet , Wei Wang , Cong Wang , Taehee Yoo , =?utf-8?Q?Bj=C3=B6rn_T=C3=B6pel?= , "Michael S. Tsirkin" , Alexander Lobakin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH net] gro: fix napi_gro_frags() Fast GRO breakage due to IP alignment check Message-ID: <20210418114200.5839-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 38ec4944b593 ("gro: ensure frag0 meets IP header alignment") Signed-off-by: Alexander Lobakin --- 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..965d5f9b6fee 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, =09return head; } -static void skb_gro_reset_offset(struct sk_buff *skb) +static void skb_gro_reset_offset(struct sk_buff *skb, u32 nhoff) { =09const struct skb_shared_info *pinfo =3D skb_shinfo(skb); =09const skb_frag_t *frag0 =3D &pinfo->frags[0]; @@ -5925,7 +5925,7 @@ static void skb_gro_reset_offset(struct sk_buff *skb) =09if (!skb_headlen(skb) && pinfo->nr_frags && =09 !PageHighMem(skb_frag_page(frag0)) && -=09 (!NET_IP_ALIGN || !(skb_frag_off(frag0) & 3))) { +=09 (!NET_IP_ALIGN || !((skb_frag_off(frag0) + nhoff) & 3))) { =09=09NAPI_GRO_CB(skb)->frag0 =3D skb_frag_address(frag0); =09=09NAPI_GRO_CB(skb)->frag0_len =3D min_t(unsigned int, =09=09=09=09=09=09 skb_frag_size(frag0), @@ -6143,7 +6143,7 @@ gro_result_t napi_gro_receive(struct napi_struct *nap= i, struct sk_buff *skb) =09skb_mark_napi_id(skb, napi); =09trace_napi_gro_receive_entry(skb); -=09skb_gro_reset_offset(skb); +=09skb_gro_reset_offset(skb, 0); =09ret =3D napi_skb_finish(napi, skb, dev_gro_receive(napi, skb)); =09trace_napi_gro_receive_exit(ret); @@ -6232,7 +6232,7 @@ static struct sk_buff *napi_frags_skb(struct napi_str= uct *napi) =09napi->skb =3D NULL; =09skb_reset_mac_header(skb); -=09skb_gro_reset_offset(skb); +=09skb_gro_reset_offset(skb, hlen); =09if (unlikely(skb_gro_header_hard(skb, hlen))) { =09=09eth =3D skb_gro_header_slow(skb, hlen, 0); -- 2.31.1