From patchwork Sat Jul 14 16:52:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 10524771 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 D33426028E for ; Sat, 14 Jul 2018 16:52:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B110228B41 for ; Sat, 14 Jul 2018 16:52:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6942128C35; Sat, 14 Jul 2018 16:52:25 +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 87D9828B41 for ; Sat, 14 Jul 2018 16:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726979AbeGNRL6 (ORCPT ); Sat, 14 Jul 2018 13:11:58 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:36951 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbeGNRL5 (ORCPT ); Sat, 14 Jul 2018 13:11:57 -0400 Received: by mail-io0-f193.google.com with SMTP id z19-v6so33958511ioh.4 for ; Sat, 14 Jul 2018 09:52:18 -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=lVbsTY1CenNcRYRRFz/WqhnyER/0YpQ0/mosd+cob7Q=; b=sP9JOf43B/qhGKYbD5yR3RmaR5om7roynGm+zsF0CtBoSysnVL7PTN8W+buDeRagbY 6tF2AwkFaw7tWrdg2wAjoYGhuzsSilz/vuVJWlzr+V3DGww5zoq1XgpVQ0etuWVToXHV xKVEInffwAWQPgGvdd/EPfZDPb+YQqrGBaXvt7vEj+Efoy5n+3+HTu2S2FAi5cH7ZkCe 6RArP+8iwwfWtCNxvJCtw4RhSckxCPnWKsRB1Qz8VW58vd//Teo+z9WoZ7ttnUND5R56 U79VXw/HfZrTU/iR0vVq+Qu9p6qlQB+aC960vX/qPz007gjm3tA8XAT+SiMFWFakrVpu zDBQ== 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=lVbsTY1CenNcRYRRFz/WqhnyER/0YpQ0/mosd+cob7Q=; b=PIhS7kI9HOqNKCeQ5r8NNxaVeM4R3rYvrcgSvJdUP37IVJqYTli6eSoSTLY47Pzh6C ELPzfN+XwiWDhX/fIQN+urTxXaOMqB/14Nh/m+AzvGaVpNaETXhD4hhV88Umu55ZJAep DdF1X9/LVehdbLnFR+/fdOSk5hQIgU/aqy2gxHSEOXUb1WaQgA/HH53P4rI/GQr4HVv/ FRkt1XyaMt3MS0nUyAJsFrD8eHQMbZH/7N4lMei512Zmb0nO8Dd2xRPk5VrdsMgJsr1C 86sh3Kuqhf0bvDFexkh+0P/HcRBafAH6l79LjcLuFRe/EB8T1/BWnboGkzsiSGh4oSMX 1sEg== X-Gm-Message-State: AOUpUlF8DKrnlA9xNikJ0EFWC/cxd6ZThGtzNRKIDXXRhwmaoqUi8jwd iLrPGeXOywJAa/1DcECrrPz7Uw== X-Google-Smtp-Source: AAOMgpcHD03rcq1Ntcqgb+6nXC/Gn77eNMja4Crza7gSy//jkHzujZMiPXtMYt2hCLW384oGFIPs8w== X-Received: by 2002:a6b:6503:: with SMTP id z3-v6mr26094470iob.129.1531587137608; Sat, 14 Jul 2018 09:52:17 -0700 (PDT) Received: from localhost.localdomain (ecp01.openface.ca. [207.115.96.130]) by smtp.gmail.com with ESMTPSA id j11-v6sm5678114itb.16.2018.07.14.09.52.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Jul 2018 09:52:17 -0700 (PDT) From: Alexander Aring To: stefan@osg.samsung.com Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, david.palma@ntnu.no, rabinarayans0828@gmail.com, Alexander Aring Subject: [PATCHv2 wpan] net: 6lowpan: fix reserved space for single frames Date: Sat, 14 Jul 2018 12:52:10 -0400 Message-Id: <20180714165210.20517-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 --- changes since v2: skb to nskb, pointed out by stefan 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..ca53efa17be1 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(nskb)) { + 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) {