From patchwork Thu Feb 14 10:24:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1041966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E5P7+613"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BLLUUujj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 440Xc11wWKz9sML for ; Thu, 14 Feb 2019 21:26:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LkxyeG0YEgNfmWQ5/xrB6rEej+QyhwVgmNntRBN2P7U=; b=E5P7+613J8fdPj /OVzcSPn0NaX88uO1f8F1mKmsVEkPPsYpE4lE7sbD5ymbqHUnCo27qBTjRmnirtmkyQMED1EjDW2v 0i9DZmEthEtc7kweSeCq1e5bdWhM939MfuHyyNSBKXZvm3jzfQfkn07K3yPWDafHPWTrkcFLJGiDK NHshpkS9oVpoRo+VynW7rOFnul99C7RWck3r8XaeQAgisW62nBH5JBamjmTulGB4rGqctUyFBZdRo RHbtlflx6cPDUEXdecPP5Mjnhe2Bbv90CVKJ2NiX0Fgo6H+F/JLtX9K3T1g/g/qhHj0FkTbu5qdK8 cBo1dG2SLDWYHTruDNCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1guEDS-00071Z-RG; Thu, 14 Feb 2019 10:26:02 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1guECg-0005Mh-Px for openwrt-devel@lists.openwrt.org; Thu, 14 Feb 2019 10:25:16 +0000 Received: by mail-lj1-x242.google.com with SMTP id q128so4717488ljb.11 for ; Thu, 14 Feb 2019 02:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TfSOAHIGdINAAOEEKPVn4hWgc6DumBuewpwernfRgV8=; b=BLLUUujjSwK704YlOwcft6n1Avr4OXpNms+r59jlfdGvRU+Ejdc8lGnm+8l2+m+ZZt fvyZYhmPOelHEk4/K5MNbWShRa8zV+ObatqchGWEB5pLdpay5Tfciohq/8jJXX/J2DYn dhGuY8btPFUTdyVEJwgfHjB0RkTY0XZrqIfK8lzCab1OBF6+2j+LuyrNSdC7rSMlb6vZ 0pLTqxbMdIkUIBwgtUA6GHIg3dpkcCjBdkvJzmZelXdsk6Ak6KV29+9lAezrsHwu7nB0 Vz+rKO+JifIX0xp0fHT9qiKOovAlU9w/9FaA9lBt9GFl3npyQL+LXCBZbxZx1I+3pBnj DcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TfSOAHIGdINAAOEEKPVn4hWgc6DumBuewpwernfRgV8=; b=oKl3g9unqDOi9RJQBD+5rkYSQO9PpAvi/V2hQ/LonVWCjqggvMPLpdNfvfA04L/YQF gFuHzYNAFGUD6J9SRd1znMUyJj+Zv9XJrVC3a23yzJfDv73KXEz+pHtEb7G+Mjk/8h/4 oCE1Sh2SRbzW7hACA239SyvXERTF9nOP93HWViOECZOaBODKZryuroDWkf4cipJEOnL6 0dIMgh25367qlNCtjbfIEHGSo94wVPCdqJW/tqm4vAK7vzsKjp/BR8c/Qu/z2CAi3vyT hR1MNyB/rqUVfWFE18Tp+TBBBZaCTWEpdCjCSb89qKfVc5/WUuQUZZEcLAushvLkGWEo zAmw== X-Gm-Message-State: AHQUAuaOqVSs+uRjnQYSFx2IM1/DTS3wwFcLrMVfnshFw6WuftI9WqTT mGah58yZH1LHRI1OabU0IpqDNQ== X-Google-Smtp-Source: AHgI3IbHNxXB4NfuMLMnmiTjcAyx6mcQkuyGl0Hj/zYml0O2lt7PINNuDo2a04TGE9rV36Of+wSSuA== X-Received: by 2002:a2e:4503:: with SMTP id s3-v6mr1878524lja.44.1550139912792; Thu, 14 Feb 2019 02:25:12 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n189sm380392lfn.82.2019.02.14.02.25.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 02:25:11 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Date: Thu, 14 Feb 2019 11:24:30 +0100 Message-Id: <20190214102436.5092-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214102436.5092-1-linus.walleij@linaro.org> References: <20190214102436.5092-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190214_022514_923622_CC9831C8 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH 04/10] kaweth: use skb_cow_head() to deal with cloned skbs X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Hughes , Liping Zhang , John Youn , Hauke Mehrtens , Dave Taht , Eric Dumazet , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , "David S . Miller" , Felix Fietkau Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Eric Dumazet We can use skb_cow_head() to properly deal with clones, especially the ones coming from TCP stack that allow their head being modified. This avoids a copy. Signed-off-by: Eric Dumazet Cc: James Hughes Signed-off-by: David S. Miller --- drivers/net/usb/kaweth.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 66b34ddbe216..72d9e7954b0a 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, } /* We now decide whether we can put our special header into the sk_buff */ - if (skb_cloned(skb) || skb_headroom(skb) < 2) { - /* no such luck - we make our own */ - struct sk_buff *copied_skb; - copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); - dev_kfree_skb_irq(skb); - skb = copied_skb; - if (!copied_skb) { - kaweth->stats.tx_errors++; - netif_start_queue(net); - spin_unlock_irq(&kaweth->device_lock); - return NETDEV_TX_OK; - } + if (skb_cow_head(skb, 2)) { + kaweth->stats.tx_errors++; + netif_start_queue(net); + spin_unlock_irq(&kaweth->device_lock); + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; } private_header = (__le16 *)__skb_push(skb, 2);