Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp44567rdh; Wed, 25 Oct 2023 15:40:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXIr06cIX4s/tUmYbYjQ6UIoMh5gQbGr+ksTMX0zDGi3R4nlReP0f0bmIE9ZfxiOEjBqXV X-Received: by 2002:a05:6870:e2cc:b0:1e9:a8f0:d6b6 with SMTP id w12-20020a056870e2cc00b001e9a8f0d6b6mr19231390oad.39.1698273638794; Wed, 25 Oct 2023 15:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698273638; cv=none; d=google.com; s=arc-20160816; b=YrsmLCrY8iZZkAWt+byg2KwWze/5tq3y6upYw0jEVYpCLpQH0/5eGI1x4HGCNKqn88 M227BXIr6VFqT4tfUjfV6EBeH57l5LfW5rKqJ4UYGZIWp7YfAIrGF4lg1MIDOvbaUb7y C0yjzDlNcYcv64/KT0BcGeGW0O1lFhADCAWWA+FeXubJ5HOnpC6Mshubz4GL1Gq9668J xMzp9ifL7G/qj63n4D7KjAR6lPU1V1UyYbYFPeefcWMD1EtI3qXHOirHgMn4VSdSHYQw 0HN987g7A7uNn561xZiRzwD9wEi3CgXvSswVJ9k0V1ZCI+Zg2wTTsCJsz1NjYx8cTe+8 OJyg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=lsyaeEbOKHbDGyFd7bZPwT49uJ/UVgZh6pgU2HET7Ro=; fh=AcTGurn0TBmUH9C3rmBXgsWwMpAUE9uxkALV2ciEPjg=; b=iNYDjPJA+PNHY/yM2TgzyG7Nw7pVYQz0tqizJR4w1w73CUNz/f1fEy/ZxPySJhoQ7u jGbFq2jU7bDWtBYYnbKMF6HWK9pFtsuXG3Ykyd/mvLNIyeQNdhjjO7Mb47w9whh7QtMI DzSEgryBVrwKl2wAFvcNgxLBP2WslU6t0KSo9y6bP9ecHvNB/BFo8dhqGyndVJmTOGZN 6n5y8pTyC/vohXy7+5in+sG8G6Chf00wRzQ/PJJhpiUr89XqsPejHGV/CEZ+Yi/yUzew tz4vmNMWxMLTRr7G8SUil3vrip49aZJz9VftSCDub2nB3x1Q6lrcp4lkeG9WlyEoOaC+ J0KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8l6OsMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s10-20020a81770a000000b005a7b0942ecesi12683620ywc.387.2023.10.25.15.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 15:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8l6OsMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 301B48182DE4; Wed, 25 Oct 2023 15:40:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbjJYWk2 (ORCPT + 99 others); Wed, 25 Oct 2023 18:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjJYWk1 (ORCPT ); Wed, 25 Oct 2023 18:40:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAC1CC for ; Wed, 25 Oct 2023 15:40:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3367C433C7; Wed, 25 Oct 2023 22:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698273625; bh=qfels1GYMTPfnHoxUp0H97xy17t+4MpcMZslcbdXlTU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Z8l6OsMGIrBIB1ROCA2X/RxkK0jc9MA4OXyVteCFe/oFT+HDvYrQMymtXnhMDxFva kls3WJ1IEuuleQujkDmi9oe7qwd4Fd/dakjSeOeavZjGyp8ovUwnt4sABCeg/uBxuP 8/ARvVtNmeq1Insw+oAdbJg3x4p3NsOC87W2FdHMAblx0DShIzvY6COZnO84N37XAF 717r/5Ihc4yHEvzZHit/YnaUbUJFTbpYJerrXB0tCrzuL/MlhDqjN8Z8i7FOjVuTjF iks7d6HCVAhdiBRSzZxxSsZmnvP3Sfzl7+ITC8IThqdBm9c/sO8pJirlMUrzTPW0Vk 2IUXy2kn8noWQ== Date: Wed, 25 Oct 2023 15:40:23 -0700 From: Jakub Kicinski To: "Radu Pirea (NXP OSS)" Cc: sd@queasysnail.net, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, richardcochran@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, sebastian.tobuschat@oss.nxp.com Subject: Re: [PATCH net-next v8 4/7] net: macsec: introduce mdo_insert_tx_tag Message-ID: <20231025154023.576a2f7b@kernel.org> In-Reply-To: <20231023094327.565297-5-radu-nicolae.pirea@oss.nxp.com> References: <20231023094327.565297-1-radu-nicolae.pirea@oss.nxp.com> <20231023094327.565297-5-radu-nicolae.pirea@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 15:40:36 -0700 (PDT) On Mon, 23 Oct 2023 12:43:24 +0300 Radu Pirea (NXP OSS) wrote: > + if (unlikely(skb_headroom(skb) < ops->needed_headroom || > + skb_tailroom(skb) < ops->needed_tailroom)) { This sort of "if head / tail room is to small, realloc" helper would be more widely applicable, we should factor it out. > + struct sk_buff *nskb = skb_copy_expand(skb, And this should perhaps be pskb_expand_head(). > + ops->needed_headroom, > + ops->needed_tailroom, > + GFP_ATOMIC); > + if (likely(nskb)) { > + consume_skb(skb); > + skb = nskb; > + } else { > + err = -ENOMEM; > + goto cleanup; > + } > + } else { > + skb = skb_unshare(skb, GFP_ATOMIC); You don't need to unshare if tailroom is 0, you just need to call skb_cow_head(). I think we have this sort of code in DSA already, IIRC Vladimir wrote it. dsa_realloc_skb() ? Can we factor out / reuse that? > + if (!skb) > + return ERR_PTR(-ENOMEM); > + } > + > + err = ops->mdo_insert_tx_tag(phydev, skb); > + if (unlikely(err)) > + goto cleanup; > + > + if (unlikely(skb->len - ETH_HLEN > macsec_priv(dev)->real_dev->mtu)) { You can check that first, if the packet is going to be dropped no point doing the expansions. > + err = -EINVAL; > + goto cleanup; > + }