From patchwork Mon Jul 2 20:32:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 10502357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3BEA60532 for ; Mon, 2 Jul 2018 20:32:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B14CF28C3B for ; Mon, 2 Jul 2018 20:32:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1D8828D09; Mon, 2 Jul 2018 20:32:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDD5328C3B for ; Mon, 2 Jul 2018 20:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513AbeGBUcR (ORCPT ); Mon, 2 Jul 2018 16:32:17 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:37743 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752566AbeGBUcQ (ORCPT ); Mon, 2 Jul 2018 16:32:16 -0400 Received: by mail-it0-f65.google.com with SMTP id p17-v6so114056itc.2 for ; Mon, 02 Jul 2018 13:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=CROXa6TVDDKnefY1VmU2CrtV7TryFJaJ7EedxyxeVYs=; b=1+0AreKLCK6ugnuD0Tedqr/oGf1Qx1oBS725j71fA63mikSAr+pdYjoac3z1cNkt27 7W3X5KqWz0PCoN3n5TL/YIuJ0c0eYKmrbHlsWRSb54mU70T8b9JeMX9848clA/irtY4B COCASHUHA7HK4ZfTopi5thDsu2Y2B+Ogp2Ww0PelVMPZJ6MUXolUTcJGwAw25KPKD7X6 H44fdzhr9V76zDErnw832Q+tOD7w7XUmOYV6ioWPt+iOWJsuYZWNDK9zTWLoEZ0dMwJc DpSPRLOfqr7oW3qAABHwC+n6nSAYgqnvuAhsS2P7kC2p4l7kIKXiiUMWsuGOwOdKcCvi bYpg== 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; bh=CROXa6TVDDKnefY1VmU2CrtV7TryFJaJ7EedxyxeVYs=; b=UWVDegiYfA9EU9kuB4P1G3ENmN6iwEU5PiAeQSSZrhESeCaf+xvUS452Pvrbe/Kw/d zRYIdX6CCg58qCGfRnObcm/fO7z9/rQ3B3DxdkQJJF+v9TbrmdQtYNxyuS1mHbtiG2wn dqwI2GWJ9e/w8KzPxvOCKBCD932s1rk2bO97uan01vfk6NeKm7SkncGmDlr0FIGvvPPC du3TBZXhRM/P8ifFYp1l3hrwaeGLXNXyYIZ7ftCOByXynQg2nW2AFRvRTX+hdIu+GAw4 HYqCWm0yfAAe5QFCwtuionDXpoi0qDAOneS9XY8qJFnpkP7gOvrFLtb3coXyqb5xfIPI KP0g== X-Gm-Message-State: APt69E3VLdnOZcjjWWrfHfiDn4Wd3Gznmw+ReRHjt09hQor+Xh/80Akk ZcJ/8dl3oRGrNnbQp2HfA4Sbb2Ye X-Google-Smtp-Source: AAOMgpewHQsTr0rHnUcRQNnPA8SWxIgmZjIbx+w1jw3gvLqIWgTwAm48OftnYiSZvvVFOWEawdKdzw== X-Received: by 2002:a24:4112:: with SMTP id x18-v6mr7054633ita.83.1530563535726; Mon, 02 Jul 2018 13:32:15 -0700 (PDT) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id h75-v6sm725562ioh.50.2018.07.02.13.32.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 13:32:14 -0700 (PDT) From: Alexander Aring To: stefan@osg.samsung.com Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, kernel@mojatatu.com, Alexander Aring Subject: [PATCH wpan 1/2] net: 6lowpan: fix reserved space for single frames Date: Mon, 2 Jul 2018 16:32:02 -0400 Message-Id: <20180702203203.21316-1-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes patch add handling to take care tail and headroom for single 6lowpan frames. We need to be sure we have a skb with the right head and tailroom for single frames. This patch do it by using skb_copy_expand() if head and tailroom is not enough allocated by upper layer. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059 Reported-by: David Palma Reported-by: Rabi Narayan Sahoo Signed-off-by: Alexander Aring --- net/ieee802154/6lowpan/tx.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c index e6ff5128e61a..d0c4d220de08 100644 --- a/net/ieee802154/6lowpan/tx.c +++ b/net/ieee802154/6lowpan/tx.c @@ -265,9 +265,24 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev) /* We must take a copy of the skb before we modify/replace the ipv6 * header as the header could be used elsewhere */ - skb = skb_unshare(skb, GFP_ATOMIC); - if (!skb) - return NET_XMIT_DROP; + if (unlikely(skb_headroom(skb) < ldev->needed_headroom || + skb_tailroom(skb) < ldev->needed_tailroom)) { + struct sk_buff *nskb; + + nskb = skb_copy_expand(skb, ldev->needed_headroom, + ldev->needed_tailroom, GFP_ATOMIC); + if (likely(skb)) { + consume_skb(skb); + skb = nskb; + } else { + kfree_skb(skb); + return NET_XMIT_DROP; + } + } else { + skb = skb_unshare(skb, GFP_ATOMIC); + if (!skb) + return NET_XMIT_DROP; + } ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset); if (ret < 0) {