From patchwork Sun Jul 30 07:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 128201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1438158vqg; Sun, 30 Jul 2023 03:53:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3pbo8KUENHUNf7Ya2XnvpZqqYZh31A13Ah7bexeOKZjVSZZhzHpsp9BvmbgHtx5qDNKH9 X-Received: by 2002:a05:6a20:258a:b0:12e:44:a1a6 with SMTP id k10-20020a056a20258a00b0012e0044a1a6mr7748476pzd.11.1690714381017; Sun, 30 Jul 2023 03:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690714381; cv=none; d=google.com; s=arc-20160816; b=UTBo22/RtrHW58hbhxGU+/6AiU7E4T29UnEccSeiUtMoIHBwAgAa4oNHHTxg83Ct7o s2sE08reF6WSZ/YPFoKne3j9c7MyLBsLWBJ8iOrjQ8mrZ6L03Emvr/AkNCjCO/C9CfyE 6Wk8NOb05m2Y8lQhxjKXLepi7ELcYrxcEYo67RZRaXk9LTVr4y7di0llI6kc/7Ian677 VzdbzjSP2UulWjyuHKTlTXTRmHN0DGPcI50NsqmIRn3l81bFZ6G3fspDuZiJ0fbw184f aZHmL/f+qGQKH1tlL967YmrVqa4qkgmif16egice36iqmXHoGWO3F0HqeKCcTGhouBR5 jxlw== 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=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; fh=4Kg3l5zis6WIABGLRaUIw3JMQczAglYDh1n+zAW+gtc=; b=KOUXUoyHdJiGJr4sIcYlYcsUjeh3x19HuD3/Eg/g09J+24gIqS1HZT2JmqqvKIhUix JBMX7C8ZtATJxWEDRxgmet5ncmWAzujx5ySmXA3kiY7r6MVdxJ47KulzrHfKyn0lJ/gg Kn9u6MDq7jsFjKcog5TIZ1pyxLrlf9Bmk6FfF3m52rTYEctSXVj6N+PklyS1eoVN/dwi luvH5bXz3zZmufk0o8z+JCbYKvjDaObi1t4Jeis1NiORyjP8KesNYyYlkXcCL5f25MZh pO7EUXGYDSsGOIACjTd/Y3dR4htnPf5g3UTsBYeAIp0ETPatcMH0uRsZHgb8QTuPCysc +GFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=s3ymq2gE; 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 be15-20020a056a001f0f00b00682ad23bb40si3943744pfb.251.2023.07.30.03.52.47; Sun, 30 Jul 2023 03:53:00 -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=s3ymq2gE; 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 S229806AbjG3Jj4 (ORCPT + 99 others); Sun, 30 Jul 2023 05:39:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjG3Jjy (ORCPT ); Sun, 30 Jul 2023 05:39:54 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF48A1BDA; Sun, 30 Jul 2023 02:39:52 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d58b3efbso3159550f8f.0; Sun, 30 Jul 2023 02:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690709991; x=1691314791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; b=s3ymq2gEh2sqzFH6eqK2NbhQ/Qz5ntzHr8uZDZKVNQKk3orQ9D+ZJj8CdbFWvcgGFP lcP4q446xVKGTZAYMyFLyr8kUufoq4COJyzqm9jbRxgAP0PntzFddF2mrEaYTvnW1KrS axFJm/Y6NX5gR73g5JJPKTo8gjF1xHw8fg5JLBmfhK5H7Im9UDMgK3DI6loXO9XUEqTQ DBGjGmTH/YqmUvrIhP3O5o9G+ROPVdcAFCCezifE+9h0kuxxxQjwlEWlH43QYCpxfHty U6Y5u+8vdRU2/+eeN8Y9j/DO+rm+685K70BbRzEzqSmFz33otwp03iTbj445QB9ikyoY he8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690709991; x=1691314791; 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=MRAG2y5s5jsU57Ef4re95fs4ggBIVFmrGwBiaiHU1mc=; b=AhrJ8qWaH7BUdEUdcnCVl/Q72hkbVPMdxlXXZHWz470jlYUWoARAIecwwm0lqCcb3c aiuEvcI7I7ySLnLIV1APzDlqZp76MNrx6jYoHe5CI5kaqFTDDO7m95TUd7M7PdOAQPIz CWv9KopuJ4QZ6BJfBEPC861oG9OtKOkk3ZtssxUD/lqTIPew/ww5K6PRmVuOe9dMwy64 jS8lOz98VEObOX/ahHJCcZeIvD5yV+E0UbSnrU45sAqfRKJ4gcmopJgvUwtdA1KVtRb0 iY2xkPEiZ3yTxC30JHSsgoY4BtI20W34FkEpcdRkcBvg1qbM8bphmKTr3WmKyuutS6tw fHvQ== X-Gm-Message-State: ABy/qLZM2/QIx+Rnub0dxng2PntZVcQqtmFjXyPWYacNOL2DK4wXTKNB q8v2vXMUwHQzGVRZrQKjgY0= X-Received: by 2002:a5d:4f05:0:b0:317:66c0:9d82 with SMTP id c5-20020a5d4f05000000b0031766c09d82mr4471002wru.64.1690709991021; Sun, 30 Jul 2023 02:39:51 -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 h16-20020adffa90000000b0031423a8f4f7sm9574599wrr.56.2023.07.30.02.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 02:39:50 -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 , Michal Kubiak , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Simon Horman , Florian Fainelli Subject: [net-next PATCH v3 1/5] net: dsa: tag_qca: return early if dev is not found Date: Sun, 30 Jul 2023 09:41:09 +0200 Message-Id: <20230730074113.21889-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: 1772842522679680461 X-GMAIL-MSGID: 1772842522679680461 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 --- changes v2: - Add review tag 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; }