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: 158335 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1172517jaa; Thu, 14 Feb 2019 02:25:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYsLeuNjivKGbAZ2TZr35n5/WdivVM3Butj2VciwuRVboHGBBzuNbzlZS4iaba+YYaKVpEx X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr3246343plu.122.1550139915625; Thu, 14 Feb 2019 02:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550139915; cv=none; d=google.com; s=arc-20160816; b=VX47HfIIUPRtRp8iMyb/MSenMmaTJUsGJl+wzd4D8EqM6W6sT1PhSBj6uj84U+y42a lim8jDV28IacIPmn8JEubLd4+sCUZ0M1HYzNmjEO00VUiByHsaNoHJm+UEJSA1n4nk+l i9IkX82ky+wup8HfCVNxxamnYLfzr4ynQl8vGRLZpstT3nVCK3IIklmsfVlFYyfYMFTv TmjPI5O35tcfqM/pmGR15ipmqPROeM+Vd1WEEUnnDmao5MQGEvIfQ3nRoTJt/0YCuo+S aaNs+35tB4L/XjY1LCAM2/Krz9HweSaKUs3sxgUMkfx0q+4JOeNRI/xpcrITewqKYcu5 R7AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TfSOAHIGdINAAOEEKPVn4hWgc6DumBuewpwernfRgV8=; b=nKp0cE3xDztMCmpzYNA2iY+9I+kHnK6/JCHOHFBdPULSBIRqKgIAgVIvvxSwXvMXh1 mwqIer9p1gGWuoMoP9tjo8SnrssQR/Q0lzmudfoYDbc4sd/XH2npLu3Mob7JT3W+gxUz 04I8qybL7xhzWa5CKuIsOfQT/qh8bGj91wgMqrheiaaxQBVhrxbxZpuOooj6IS+EPnlJ 9EqtsnakPCZ2ziOVlxora7mu4XG46y75fiTxcK4maDoDLUKZj8huuWBltQmOfAj9K4EN Jwm/lNPxbpOvfnQ9fJa0m27+PCnMDuyd5S4HodcG946/HEPZF2fscuCVd3B7VwSuE/uj mOEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BLLUUujj; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si2132062plv.258.2019.02.14.02.25.15; Thu, 14 Feb 2019 02:25:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BLLUUujj; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387899AbfBNKZP (ORCPT + 15 others); Thu, 14 Feb 2019 05:25:15 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39769 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389001AbfBNKZO (ORCPT ); Thu, 14 Feb 2019 05:25:14 -0500 Received: by mail-lj1-f196.google.com with SMTP id g80so4743937ljg.6 for ; Thu, 14 Feb 2019 02:25:13 -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=burT/806cF+q9pyMf2I7jsa3FpynMrF9qNCtnq+qi1sJolDlONLUi4nwJYZOz/Iuq2 k/eSNiNEh33RB0IQR6/43jDOFt1Lof+hPIWYP808SBGU3iBnadYy08WqmaOBF6ilCQhM AEqV3R8q+3ACYz9k707QW2S/zK+yOB6OdXQUG01TpZCIw6FiCeKrcCrwvy8p02UAMVpS 13elDT+Nh21L845dzS/KpmuiugZ0ux1h7juTNfLzfUs7DHzS1ckggy/P7OuMmvX7TlzL O8WHLXBkUO88G4bgCEi6PElRVb2MSR7eaO8bQgkOKUjZg5sKFC+4IqddRlwNT1QD/xsm s/dQ== X-Gm-Message-State: AHQUAuZYkHmSIYEWSaeS1F4pbzm48Xxv5pHy7fCetz6RgsaeICUJ6aNh L/X5+XT9+op0rUPObbDPL3bft/8REVM= 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 Cc: "David S . Miller" , Eric Dumazet , Hauke Mehrtens , Dave Taht , Liping Zhang , John Youn , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , James Hughes , Felix Fietkau Subject: [PATCH 04/10] kaweth: use skb_cow_head() to deal with cloned skbs 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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.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(-) -- 2.20.1 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);