From patchwork Fri Jan 15 09:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 12022039 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8377C433E6 for ; Fri, 15 Jan 2021 09:37:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 994F22339D for ; Fri, 15 Jan 2021 09:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbhAOJh3 (ORCPT ); Fri, 15 Jan 2021 04:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726849AbhAOJh2 (ORCPT ); Fri, 15 Jan 2021 04:37:28 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53BD4C0613C1; Fri, 15 Jan 2021 01:36:56 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id p18so5634030pgm.11; Fri, 15 Jan 2021 01:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=OTtsm6dyKrVJ0jbDg2f7EoVgwZ5It1gTjh6wfzgk4d0=; b=ruZCSYW1oaH2ZJTusFo2uZ/K0IMbZDczPU59YHk6oizEtzQABrl5XR6MypzlQADjhb WtQHqCEMQ+Vpyg2tE9zydMVaom0CRU1KQXcc3xSGVKKsvCiOP789sAQ0xSBFckK64kzi BbYWThJg/NPdu70urKVQ+0//sHJhwZQTyrzgeTfrEh+2WYiIpo1jiBCwoJM7y6i6T4sK lzw4m3hP2RMEndRGIFoPBmTmGlYF82xG1saJj9gE7+ZQkiPVSmfxvSB1hdVR8ybo6u5+ ZkW7I3LX1RmGcu0zWaEdZYA6zk+VhV8in8rIVOhdtxC+LgryjF8gelKUWxPBlv1NCBcR Lceg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=OTtsm6dyKrVJ0jbDg2f7EoVgwZ5It1gTjh6wfzgk4d0=; b=jU3ehZmHG71ujNYB4alnq+s/1mdPQkmzHbcGKsfMa+uuYcTB7YjQgGaNOaW5PaNaMH UvweSHZgSJIEglQfYWAEVESgXpjQoqCCtZuf7xwJMv6P/6FrwI1fkIU0XiID+5WVF59U uI/oYje2lvUMsnX7PO66PsSIte/4B18HqDRN+jS3N00t6OpUJiX/q0e7AoP8nKmqrY27 ly1d9NUqNUVZzheT1mvXV3HSs4vi8n7fF/qgwO8f06PeJERFLrIAfd95uT3lxfzHnNr5 BwWgPSjDlI8vH3fICOaqu6Wp4ZTOubFu7/uymebYqxQhIletzEDoC0HobrWnhN/abZdg gyXw== X-Gm-Message-State: AOAM530aU6C2c6YMN6HLtSdFIKjnE312zWSNsDYq0rEqQ+Pjr1NxIdzl GFcuzCwkEouZAJ/Uq2//btg4Tg/YIvSZBw== X-Google-Smtp-Source: ABdhPJwPl2srwtVq1yf83n3skm/79nBDwiN9RbAJwUTcuWmGFlsxzZ3eXyoWlVZf3lkbJviIL9wcBQ== X-Received: by 2002:aa7:9055:0:b029:19e:4bf4:c6bc with SMTP id n21-20020aa790550000b029019e4bf4c6bcmr12002200pfo.58.1610703415627; Fri, 15 Jan 2021 01:36:55 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id o83sm259099pfd.158.2021.01.15.01.36.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2021 01:36:55 -0800 (PST) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: Marcelo Ricardo Leitner , Neil Horman , davem@davemloft.net, Jakub Kicinski , Alexander Duyck Subject: [PATCHv3 net-next 1/2] net: move the hsize check to the else block in skb_segment Date: Fri, 15 Jan 2021 17:36:38 +0800 Message-Id: X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org After commit 89319d3801d1 ("net: Add frag_list support to skb_segment"), it goes to process frag_list when !hsize in skb_segment(). However, when using skb frag_list, sg normally should not be set. In this case, hsize will be set with len right before !hsize check, then it won't go to frag_list processing code. So the right thing to do is move the hsize check to the else block, so that it won't affect the !hsize check for frag_list processing. v1->v2: - change to do "hsize <= 0" check instead of "!hsize", and also move "hsize < 0" into else block, to save some cycles, as Alex suggested. Signed-off-by: Xin Long Reviewed-by: Alexander Duyck --- net/core/skbuff.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 6039069..e835193 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -3894,12 +3894,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, } hsize = skb_headlen(head_skb) - offset; - if (hsize < 0) - hsize = 0; - if (hsize > len || !sg) - hsize = len; - if (!hsize && i >= nfrags && skb_headlen(list_skb) && + if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) && (skb_headlen(list_skb) == len || sg)) { BUG_ON(skb_headlen(list_skb) > len); @@ -3942,6 +3938,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, skb_release_head_state(nskb); __skb_push(nskb, doffset); } else { + if (hsize > len || !sg) + hsize = len; + else if (hsize < 0) + hsize = 0; + nskb = __alloc_skb(hsize + doffset + headroom, GFP_ATOMIC, skb_alloc_rx_flag(head_skb), NUMA_NO_NODE); From patchwork Fri Jan 15 09:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 12022041 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39A20C433E0 for ; Fri, 15 Jan 2021 09:37:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2A5322A84 for ; Fri, 15 Jan 2021 09:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728891AbhAOJhi (ORCPT ); Fri, 15 Jan 2021 04:37:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbhAOJhg (ORCPT ); Fri, 15 Jan 2021 04:37:36 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4699C0613D3; Fri, 15 Jan 2021 01:37:04 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id x18so4412862pln.6; Fri, 15 Jan 2021 01:37:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6y2PAyUtL03Nbrmo9xCdhafDQCYKT4PC/qS4knYVGiM=; b=hwltHPYFd2W+GcK7Vzqd6MSZF6ZrtrHJPAyvYuEOZID3gI6rcpRwdHNIhm2sMxTRIb rNUbhnpJ4H4psQblSK3w26bafNsfQQYiJh+dxNh/QktdwcvENqJ6jn+CWDB1m4wvyc2N QrNkccRLn7ZEPC9S9ypmDawMvb6jywu5mZY9yDcRUJq66UZ8jbB/EmLqLNRhoyvVmpl6 aJAgyu54fUInL2XO+spe2ve3bdYHRdLqICcWZsgah2ChIvA+EVLHrjQ/cHvi7aBE0LRS CuG9SuM/Y3VQ3NHbI87l+TBJ79XHGiYidrZrQzTvzQxDKcSiImWX23cguyw50QAL3eWY TmNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=6y2PAyUtL03Nbrmo9xCdhafDQCYKT4PC/qS4knYVGiM=; b=YCz5x/ec2O7Md2lbPPdCpMlnNBBkKnOtU9GkrP0PxfSE3Qlrk6cUFbLhIjmT77ElFi sWMrZ61N6iCVg/CdOokWONM4F9QEi0tCJGQl36iEmQQikCSvDL+Fcdv/kvE4zDsdRzMU afuSllwXc0+6YwPOVR2JCUjA1WesnWZDLHuVXfFAERi8AD9Kl9mB8evDjxyvnuIjBeYM 5eaA5JvcB6cd0J5lZGCdRgcJQqnE/PXqmZWK9ld7gV55w1duIhjeSjl8zlR2uPlxXrF0 OV+56dqpGvlGSJxj/WVevmTEgfkdJBh/Ak2Cmc3T1keLJQ6N9f3/5dfDeErj3LeqfAdo AsDw== X-Gm-Message-State: AOAM531NaAhBN0KsFT+SmzYqK1VMZgYftyVYILyQNvqMEzEnyoIoQ/GF WISqgFBwsXiOqt6x12Qzt8gJEiyUM/5lQg== X-Google-Smtp-Source: ABdhPJzGP5v9Rj+D1hzOSXYgAbwpN47Hhs5WJWWg07+//oaPf9hFN0Q9md7Kx1RhCg+mM8/d8ba1oQ== X-Received: by 2002:a17:902:a517:b029:de:79a7:48d9 with SMTP id s23-20020a170902a517b02900de79a748d9mr692150plq.45.1610703424148; Fri, 15 Jan 2021 01:37:04 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id g2sm8669740pjd.18.2021.01.15.01.37.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2021 01:37:03 -0800 (PST) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: Marcelo Ricardo Leitner , Neil Horman , davem@davemloft.net, Jakub Kicinski , Alexander Duyck Subject: [PATCHv3 net-next 2/2] sctp: remove the NETIF_F_SG flag before calling skb_segment Date: Fri, 15 Jan 2021 17:36:39 +0800 Message-Id: <0aeb3e215c9e47a0bdd87c9d5cc81560e2f71d23.1610703289.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It makes more sense to clear NETIF_F_SG instead of set it when calling skb_segment() in sctp_gso_segment(), since SCTP GSO is using head_skb's fraglist, of which all frags are linear skbs. This will make SCTP GSO code more understandable. Suggested-by: Alexander Duyck Signed-off-by: Xin Long --- net/sctp/offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sctp/offload.c b/net/sctp/offload.c index ce281a9..eb874e3 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c @@ -68,7 +68,7 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, goto out; } - segs = skb_segment(skb, features | NETIF_F_HW_CSUM | NETIF_F_SG); + segs = skb_segment(skb, (features | NETIF_F_HW_CSUM) & ~NETIF_F_SG); if (IS_ERR(segs)) goto out;