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: 943963 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="sP9JOf43"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41SbLv40bXz9s21 for ; Sun, 15 Jul 2018 02:52:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbeGNRL5 (ORCPT ); Sat, 14 Jul 2018 13:11:57 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34297 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbeGNRL5 (ORCPT ); Sat, 14 Jul 2018 13:11:57 -0400 Received: by mail-io0-f194.google.com with SMTP id l7-v6so33998622ioj.1 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=eyXMb8ZQjVVPmWJU8hgsQ8pVyc6nOxQQKUR8oj0MSBWj3mKirJqKmp72gtS+omz43Q MMT0cQun55rR9838KSkeXpDiSbdYWjW++GgJTkwKJfQJJ2m4wpNx0RZ2lXvfSZNypVK4 K8xl8zkJKizmq9AICfqnfcSXruDLJsYoL7YmgyGwk6IXhPuUQC6Cjr2qI9O2FJODzKxj p1Nb0CcpxHcRJL5zbx3WnAr4T36FjE8fPR2HqO1MNzYW7C50EsxWQvtgGhSMZuxh/RAB 4Zr33/SC99u+O7RV7+v91cWTZcVdJ3Xg4ZiXPb0RdkmXrPaIUjbExtF+mTMuxPXf6ucQ +V/A== X-Gm-Message-State: AOUpUlHBb4+CD3q+Ki7xiFmWgzsgJs64SOoyd5Qm52f+gwhreQpn6HRo J9Xe+mO1/OAHt/YKtRwTFZVm05WZ 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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) {