From patchwork Sat Jul 29 11:55:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1000949vqg; Sat, 29 Jul 2023 05:26:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlFzPODkKFM1YMO21LOPbHXVQzhrFwzg6FTWKzE0h8d/xd3+UwOlAw6D4jUymDg+ytdHa6Zl X-Received: by 2002:a17:902:da89:b0:1b8:3601:9bf7 with SMTP id j9-20020a170902da8900b001b836019bf7mr5412568plx.24.1690633587002; Sat, 29 Jul 2023 05:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690633586; cv=none; d=google.com; s=arc-20160816; b=S05mXLJjHMwgT83gTcmyZy6hiSAo0RUCaWnehHTSefKxcClQRii8pPPGx606DEgKrj cZH3wT2qpHs7n3OKJaRvS0FDsxrhVCvdthfd0eXpdMOv6yuQ6kx/AwVzP1jRYKEQYblZ eU0CqAnvDmYlXsBdlaARONRg+nFZ6SfJ3bM4Rwmx5MovsT+iTDiOHgnkMb2KUfbucQnV 2GcXTcQwkteJjesyqFD2yKYOqh/fwLo+k+Ij/x9Wp4M/PIcR2gDDnM/rBExK+BhEaw27 o6zDD0OfLuE7OVBi9Xmd5cjtOY+PikiteE0/4rNyXE7K8j8bJoDEOW97X/PUNz+BdgJt Bcbg== 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:cc:to:from:dkim-signature; bh=3q+L7EE1TkpxxmtRm93suLpVPlWGwO+iRnmPNbcpp6s=; fh=Oew/6E1ENQAh5GvI/ZomWrmwHkVqdSnWJdtcQgJEhKI=; b=H32BDRHCVL/9tuNDikZpstHj0RG8pimkxsbx/z3BvEjsMPT3N5uwuq6u5TZ9tvmpiC lufBOfkicsnvjPWvCAupa/H0vsXkiTHMhnpU5S0jz/hZpa3fgHEVQit4iU4NOAYXkN81 d5zlFDM2bBq/NoJ2WOXIrhJyHFxmslEW4eTusaymAhalMQra2BYCPDk093q3ifEnSgxO pudhSyi740rbGuxA5zLcePwh+dAHuCiIOlCUAyHBus5JYb+ccHAW4k/3PTGVyWVL83qS 0RWs3a9pNFXkmy274414yJsNhQo/3x50DnIEHJJ0BX31AWmGGG3nt1IHpmbb8y79/J8f FZvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mBzFMgkv; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a170902cec100b001bb1d822685si4699201plg.358.2023.07.29.05.26.13; Sat, 29 Jul 2023 05:26:26 -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=mBzFMgkv; 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 S230448AbjG2LzW (ORCPT + 99 others); Sat, 29 Jul 2023 07:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbjG2LzS (ORCPT ); Sat, 29 Jul 2023 07:55:18 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C14EC3A99; Sat, 29 Jul 2023 04:55:16 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3174aac120aso2908158f8f.2; Sat, 29 Jul 2023 04:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690631715; x=1691236515; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3q+L7EE1TkpxxmtRm93suLpVPlWGwO+iRnmPNbcpp6s=; b=mBzFMgkv1OVQE4vElaM8tRO+UIjOimxmAb5DV5QeM94ZFzpWQFOdFk2M2fD41NhPc4 tflz9ASQxYW29cxIZ6grhdZ9ItdUiW8LSJyrZ0LrBSGUXIlBehKvmyuoJfZYBieA3p/E r65MSx8lgQerIVQT/U6kTi1LTzc69NGnJV9gyAGOPEeCmjZtMLWTlQ/yNuYvQTYrE9Nv HplMhnrYmsng8g3v0koRlPXdcB4dRu+Ai1Jl/Qkp40vn8oQuMzl19Lnw+VoIfgudva3m 6w0QCX0y4eV1e9wDe4zXbuT9GWznY4MaT0So4WLHFKfnC/5yX/itBOz8+F+69VVoS7c0 JQTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690631715; x=1691236515; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3q+L7EE1TkpxxmtRm93suLpVPlWGwO+iRnmPNbcpp6s=; b=cVO41m/ZdiNPhSQX1ZUtrXuasSc7fUbb2OlMPqPrhk7uof24111Wtplkw86voWV4st xsg1LM3qSDLSDV9P3GPyHFC7tnWb+7AQ+ZTU1SKAJIeNuUEcjRrTYqHmMkVieYMHxlqp 1p0KtK8jj4wKC64QlkxrnhfKuO2nrmsB5jD59i6nXL0feHviL0Vofr9MTvIEx9jUDUb/ TbsjR50MMnMVBP8u71/0y9b+twWrZ4B+dfoceS1bTQcxvhrHt8bsQMRskzKOJnS0o8MS 44lufaYsFgdEMIuRQyUuUBIXgT5lXpvcHXkVY7rbAt5/g1BHhANwgSYDrcP7ZHdhvWDB uw2Q== X-Gm-Message-State: ABy/qLaodeEgqp+Vr6gB074Ds8/3yvohwiLWWwSWaz0+8VRGHVHEyhYI hYXTdMhwtug/gw8b8qx4If4= X-Received: by 2002:a5d:690e:0:b0:317:5cc7:794b with SMTP id t14-20020a5d690e000000b003175cc7794bmr3638169wru.13.1690631714702; Sat, 29 Jul 2023 04:55:14 -0700 (PDT) Received: from localhost.localdomain (host-87-11-86-47.retail.telecomitalia.it. [87.11.86.47]) by smtp.googlemail.com with ESMTPSA id x1-20020a5d54c1000000b003176f2d9ce5sm7295289wrv.71.2023.07.29.04.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Jul 2023 04:55:14 -0700 (PDT) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , Yang Yingliang , "Russell King (Oracle)" , Atin Bainada , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Simon Horman , Florian Fainelli Subject: [net-next PATCH v2 1/5] net: dsa: tag_qca: return early if dev is not found Date: Sat, 29 Jul 2023 13:55:05 +0200 Message-Id: <20230729115509.32601-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772757803988621309 X-GMAIL-MSGID: 1772757803988621309 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 Reviewed-by: Simon Horman Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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; }