Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2949804rwo; Mon, 24 Jul 2023 04:08:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwUW4zKsPQ83ZY/o1NuQktlqnXq/bykq8a1Voa2SPb46GZFJELcguDo3U+jp23ZBZMP6Ze X-Received: by 2002:ac2:5507:0:b0:4fb:8492:83fb with SMTP id j7-20020ac25507000000b004fb849283fbmr5003769lfk.68.1690196918167; Mon, 24 Jul 2023 04:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690196918; cv=none; d=google.com; s=arc-20160816; b=oH+RvBvTGoDxY6ybJ5NmMbApQc4fJgpDBJNGnxnPClS7irR6Wz3gXwHZ7iL/KugzFL 2kww5qKyRffnr/4Cfcn6RKJOTWoTUyq1kGtZ00LQsbDe31rAJ/NqY2uvlLL8ymQKzNGk 2F/iYvt7B6pNCKSDr1IjZi+R0y7pCF9JgHYfwqSAbhZgauT+GB8qBtf6Suo2SzE3pZAJ A509VmUAi9pJ5IMOTdmgvz9kQ5vDoBkHYuS4Rvo/L2YHrx+7w6ogaNq9hVJcBv1sFtlk cbVP5ESo0qYN09hEcl/aHTOsBpffZ18wx+d5OmN3EF2tGmrw4jR2v+fkwz4eyjZrTWBH 6q2Q== 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:date:subject:to:from:dkim-signature; bh=FNuEXVvvuCAkiuz8BidvSXWcAbM3rfmu/apd1ht/nuU=; fh=XOy5TA+EKiaAwmqpsaO4Zcdq7C+A5s2ingQBUunGi3k=; b=BYu2Z/fHsqA2I+tcXGuIzYt9l/9CkkJ9Muj3+5ZqlGzfMIKnmmDYopIaz4VzKUPf/U k9D3BMYYjKfRJAh+GeHfnCkx8uZ2yc1hGqWI++cNj66cqtkbd2So6bO+Svd9XV+Rnedw weNuCXzUXnn2VYQeU9NPqmGJiB6SUFp4OyWZhs8fslkzleH3U4T0vLgOp8DSY7HjZDnf KMXRBtK4SYptNExBdSREU3GNflEUAPjGpf3AF9MzYJpObZt9tgFFPXev4iljMh5E0wzK Kp/w2u+pd3J8p0d9UFb6HrODsMZ/14c1FwrFQveKAClMme1U+FwXY700A85bkak+2T8q uBJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fklvpOQF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt23-20020a170906f21700b00988b90f50b3si5765051ejb.607.2023.07.24.04.08.14; Mon, 24 Jul 2023 04:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fklvpOQF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233184AbjGXK7d (ORCPT + 99 others); Mon, 24 Jul 2023 06:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbjGXK7c (ORCPT ); Mon, 24 Jul 2023 06:59:32 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C1C90; Mon, 24 Jul 2023 03:59:31 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b741cf99f8so58898051fa.0; Mon, 24 Jul 2023 03:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690196370; x=1690801170; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FNuEXVvvuCAkiuz8BidvSXWcAbM3rfmu/apd1ht/nuU=; b=fklvpOQFCL3HOgzNrOXZIkBrZQFgAKCKMBY2bbX0mpsbkqXGAVOISGudghz4K8hUey gVm/cb149EszqLSoP0AtoV9TI1ubXO5ZHvCnsQHWj442xcVEyhWJ4KeQdp3nwD7aSuMJ S1PZXsJOINa0G1OxZhZfDwsJqPwpNaQyajKanlpOiuOPHTMi6UVfrDrgR4vPVA0nUXvM 2xsmjktq6G/HENAk80/w8BAprtNDVx/ad6mHgU1udKfbFrJk8uVZ5TaoBdbMNzy1vpBZ Rhv1dd2D7SNjMBz8/RHzCZjqJLXTaLc8dGsCD8M4mg9PV8GeJqv6hB6ikpQct3QeFnTj 78mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690196370; x=1690801170; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FNuEXVvvuCAkiuz8BidvSXWcAbM3rfmu/apd1ht/nuU=; b=AcVfF42QpHV9YSmS2PHyXx6VkT+IZErqdH/GEOtG5/7Z31AwmtVpG5PwifCqrRqKsE IyfXSKzLw91Gd+J9QABv4bgeBi+W+jWbU202izF/Ly4AcUtEKxcBrZTFWmOjfYW2cWl6 Z0lfxsaVXyXrQM7yBXaTRnvZt8UiB3ZoG0eBJ9ylRc7PacorqoV2D9+PkF/SbEvFoCXg uyHDoeDuzgI5vHBTwwJoTNMDjLhvsdGwNVoI0wWTvh15Cns5KGsHcmIIVwVBLe35ysTp JMrDvynOYCAfRyzN88vb/eRUHjcz18C1g3+QNvNQmOymn7H42waDs48BORFrwgo1Ey+t NmLg== X-Gm-Message-State: ABy/qLZxyJdiNJi/wNEhEQ5jP4mviDrkNs4Nf2OBNGX4YM8CukmnCWFl dzw+RklhO8aUeEeg3l4EM80= X-Received: by 2002:a2e:7d14:0:b0:2b7:2ea:33c9 with SMTP id y20-20020a2e7d14000000b002b702ea33c9mr6296249ljc.20.1690196369662; Mon, 24 Jul 2023 03:59:29 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id m14-20020a7bcb8e000000b003fbc9371193sm10055353wmi.13.2023.07.24.03.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 03:59:29 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 1/3] net: dsa: tag_qca: return early if dev is not found Date: Mon, 24 Jul 2023 05:30:56 +0200 Message-Id: <20230724033058.16795-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev. To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway. Signed-off-by: Christian Marangi --- net/dsa/tag_qca.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index e757c8de06f1..e5ff7c34e577 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -75,10 +75,6 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) return NULL; } - /* Remove QCA tag and recalculate checksum */ - skb_pull_rcsum(skb, QCA_HDR_LEN); - dsa_strip_etype_header(skb, QCA_HDR_LEN); - /* Get source port information */ port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, hdr); @@ -86,6 +82,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) if (!skb->dev) return NULL; + /* Remove QCA tag and recalculate checksum */ + skb_pull_rcsum(skb, QCA_HDR_LEN); + dsa_strip_etype_header(skb, QCA_HDR_LEN); + return skb; } -- 2.40.1