Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1745040pxu; Fri, 16 Oct 2020 23:03:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjhtR4Pwb50sbl2he+lys+lofzF4PwCUQY6Yu+LM02Tue7L9v00sjImhZf+Q7VDqDJwEXU X-Received: by 2002:a17:906:eb02:: with SMTP id mb2mr7204348ejb.506.1602914605294; Fri, 16 Oct 2020 23:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602914605; cv=none; d=google.com; s=arc-20160816; b=YZRHP9eb+ak5ein2cltffbaX3Z2btuJYUOBR4xYbiwSl7A662gm6aHq4M81683u8E8 0VqMoGTmMbSY4rYZ+Qb0jTl/2GF7gEDdcobqs8jdDNSTOiH0TqXPP70p5OwzVtHjfXja RI41IRytFj6mWGDTqMO1oIn3yihHQ0FPfMRoDIGYybHEmY4NM1+3NPh+L5wAvd/Js3hG z3R1M6qjBx0BiIhdwL7rpamBZh6jH3ej96MLg9ucBs2Y5m6hHliONLJXJu45bm1WMa16 4ZGdcwzTfRmzOOe/BjsXjODYML8QGVgLWfTuHNGFzOibVc3Cwx5Lxla/V/asophGZE2E 9Y0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=XB376N0VueE3LFToRxxe5fvCbU7rR1aPZMq5nuWveWs=; b=S1SIzqgw2ssTUgSMRW9XdFSYKFwH5iEiqIjbNIpWvV0UPFwToug5+Yrt/xmHGn9zdC XTnD5fXFLhtZJYfGLZ4Ozd54JfNpOFWoDUAsYWw9cPzkwMSPXCjA7TzHA/KXF8ktTyFh xvihf8lMmKYUA5rsLkzWoVtFxJygGL0Dci4uwLXJYxMBYmgF9GJk2Dd+5zYEWVwFSo9i xQp21dK23yz2hjYKGHyJDEy0WOB5KG4wpJirTQzJjKIHxTEBEqajJiRx8GlM4RAneBqN jpKdgboDyOOvO+ZUdIWbtGxNs0d3xW+Q7sYb5GSED73wIl8LDv18VjbDXBYpClcz7IBr CvFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PU3BfFUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si3489498edw.389.2020.10.16.23.03.03; Fri, 16 Oct 2020 23:03:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PU3BfFUg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2436694AbgJQGBo (ORCPT + 99 others); Sat, 17 Oct 2020 02:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436630AbgJQGBk (ORCPT ); Sat, 17 Oct 2020 02:01:40 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0591C0604C0; Fri, 16 Oct 2020 19:36:02 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id p11so2220646pld.5; Fri, 16 Oct 2020 19:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=XB376N0VueE3LFToRxxe5fvCbU7rR1aPZMq5nuWveWs=; b=PU3BfFUgUUqOiGuKQrRFJLMYgVdHZxIDG6EMw+4DNK19YLIHPpx3WGSNAdImYopbTF oIQi5hv81R0R9cm/UGWi6nHyaEEHtB2DQRphBq9Q4E1u4CVyn3FKmU0tKKDvEQfLGCZW W6IgnAM5aSHwI+fL2bSHxTxr2qZ0G9gVsRpomU+npmomuX0Dlo/wUvGgdpb5oelqwYp7 AKC+eBCne0dtDAlFbCzUhdW+LAEJ9/MdRjgX5TEG02s+tQe4L5LG8oilJ6F+7Fwndad5 3E580qnASrKOeVDBtsNSP33cUZI/cvt9q0R+a+sLG+4NEFl9b8LfsEFoV5picVKrEVnR KYlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=XB376N0VueE3LFToRxxe5fvCbU7rR1aPZMq5nuWveWs=; b=c7sv+OK3AGU275rSUG4w+m5Pv1QlgR0DoKXi0VQnlewrPj9G0sB9SyjG4rm7jxoX9u hReo2cdZUDHiILgbm6pfJy/xf6Me/Y1j6FfIwTgp9CySX5LWu0U8Z5cojjdlg1DYvj61 HZclXx7/zta6ZMSJvMnbs3tkCNGCpt5LdGObbuNpcQdo2jPkwua+kjFXOAjUqEcP+EkL T9mCTkw2aWaWNn+D5HYzzoJWJ+1KoySnmofHIsuOUAXsP3y9lRjYZAWAmNWLO5wkYICz nF67i7L4M0ufhz8mjI2ApiraTHEYeLTG7964kHi58XmrK4LxVO1RxCKhUQl+cO2ydHfV aAng== X-Gm-Message-State: AOAM530NBSvXrgDjcH1Eb3HwCmqNW+WYHN45Sf4P/eg25Mq5zOq+NbVZ vvIKVrh+GfvikPrrhnAP5SlzlB/pGKE= X-Received: by 2002:a17:90b:3649:: with SMTP id nh9mr7026543pjb.123.1602902161747; Fri, 16 Oct 2020 19:36:01 -0700 (PDT) Received: from [192.168.1.3] (ip68-111-84-250.oc.oc.cox.net. [68.111.84.250]) by smtp.gmail.com with ESMTPSA id r3sm4148271pfl.67.2020.10.16.19.35.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Oct 2020 19:36:00 -0700 (PDT) To: Christian Eggers , Andrew Lunn , Vivien Didelot , Vladimir Oltean , Jakub Kicinski , Kurt Kanzenbach Cc: "David S . Miller" , Woojung Huh , Microchip Linux Driver Support , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20201016200226.23994-1-ceggers@arri.de> <20201016200226.23994-2-ceggers@arri.de> From: Florian Fainelli Subject: Re: [PATCH net-next 1/3] net: dsa: don't pass cloned skb's to drivers xmit function Message-ID: <3b14e77c-9307-356e-b1cf-d9e9e51716e5@gmail.com> Date: Fri, 16 Oct 2020 19:35:58 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <20201016200226.23994-2-ceggers@arri.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/16/2020 1:02 PM, Christian Eggers wrote: > Ensure that the skb is not cloned and has enough tail room for the tail > tag. This code will be removed from the drivers in the next commits. > > Signed-off-by: Christian Eggers > --- [snip] > + /* We have to pad he packet to the minimum Ethernet frame size, > + * if necessary, before adding the trailer (tail tagging only). > + */ > + padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; > + > + /* To keep the slave's xmit() methods simple, don't pass cloned skbs to > + * them. Additionally ensure, that suitable room for tail tagging is > + * available. > + */ > + if (skb_cloned(skb) || > + (p->tail_tag && skb_tailroom(skb) < (padlen + p->overhead))) { > + struct sk_buff *nskb; > + > + nskb = alloc_skb(NET_IP_ALIGN + skb->len + > + padlen + p->overhead, GFP_ATOMIC); > + if (!nskb) { > + kfree_skb(skb); > + return NETDEV_TX_OK; > + } > + skb_reserve(nskb, NET_IP_ALIGN); > + > + skb_reset_mac_header(nskb); > + skb_set_network_header(nskb, > + skb_network_header(skb) - skb->head); > + skb_set_transport_header(nskb, > + skb_transport_header(skb) - skb->head); > + skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); > + consume_skb(skb); > + > + if (padlen) > + skb_put_zero(nskb, padlen); > + > + skb = nskb; > + } Given the low number of tail taggers, maybe this should be a helper function that is used by them where applicable? If nothing else you may want to sprinkle unlikely() conditions to sort of hing the processor that these are unlikely conditions. -- Florian