Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3004558pxu; Mon, 14 Dec 2020 17:35:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJsAp9KrS8FYjZVe9r5x8J4NMeJTHrLgzQnaYXMIgUuFwUq8fpaJI5yS4lHdgrlQnWLyWe X-Received: by 2002:a05:6402:404:: with SMTP id q4mr27986507edv.295.1607996145022; Mon, 14 Dec 2020 17:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607996145; cv=none; d=google.com; s=arc-20160816; b=go2KQ4aiGGxycVuIrkq9nENi5mBJisQP0v/mxzhtiIqmD0Ay8Wy23U7qmy9OrpB7ql ZerBfIRoKGfTsC7Q/fQsX1pXcW5aF8smynTJXpKTuRsQlcCYin4NLF+PuUQ9UMnBuqNJ 0LFcAaBypXd5IE8frJhxFqQ2rwdXcWG3Kau6iDNKIl1Wb2hl7FyCTcvq7/gmvs54qAOw WzhnnTQLdr7wlWFXQt/zsQdeDbeSB6uF13tBnZo7ZKYdHkigk1Og3L2bBR7OsT/DDyX/ 6k34AitWy8zvEQsqkmEvb+Oph+AF8VdEaGJh2EZvVbWBqL+BHsHlpH8wzOWZPhjrWgq/ dadg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=YgbvPQqIrQtMuDokK6zgAyQ6CJ890vSxMgIM9hG5PUE=; b=Ys0IJyBKpNlINgW19GlFuILMp20ctfCh2WFKztg4HWf2w/IYQR0O+LHAmLCFNULzL1 Gv9y88khcuyIAm+L4mpC95Op8saqhBh5TmO9zSNIIOHBuoGwTfpCTtRVzJgbggoCOhex oqorh5loESRMIx0b4NXUUfB1TNv32fKtST3HdyAYq9M6SJC2xMC1Zxk+MsrNjjdB4qhx po+5cXT6Ftwm2LRcb001Scmjp3jUFur6jv6R8IQecOQo5c/mDsH2NnrwmJJnIzLjNWFO 1My1CyjL2MixGPc8WsngcySe1HwziCnZpQ5u5PIKOuCWTxwzdD6ZmZWxW9yijE+UhXAP sNZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si154734ejq.383.2020.12.14.17.35.22; Mon, 14 Dec 2020 17:35:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408921AbgLNTIm (ORCPT + 99 others); Mon, 14 Dec 2020 14:08:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:47654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408583AbgLNRhK (ORCPT ); Mon, 14 Dec 2020 12:37:10 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Eckelmann , Simon Wunderlich , Sasha Levin Subject: [PATCH 5.9 013/105] batman-adv: Dont always reallocate the fragmentation skb head Date: Mon, 14 Dec 2020 18:27:47 +0100 Message-Id: <20201214172555.910112049@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201214172555.280929671@linuxfoundation.org> References: <20201214172555.280929671@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Eckelmann [ Upstream commit 992b03b88e36254e26e9a4977ab948683e21bd9f ] When a packet is fragmented by batman-adv, the original batman-adv header is not modified. Only a new fragmentation is inserted between the original one and the ethernet header. The code must therefore make sure that it has a writable region of this size in the skbuff head. But it is not useful to always reallocate the skbuff by this size even when there would be more than enough headroom still in the skb. The reallocation is just to costly during in this codepath. Fixes: ee75ed88879a ("batman-adv: Fragment and send skbs larger than mtu") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/fragmentation.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index dbd913bac9dd1..b7169c4147f55 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -527,13 +527,14 @@ int batadv_frag_send_packet(struct sk_buff *skb, frag_header.no++; } - /* Make room for the fragment header. */ - if (batadv_skb_head_push(skb, header_size) < 0 || - pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) { - ret = -ENOMEM; + /* make sure that there is at least enough head for the fragmentation + * and ethernet headers + */ + ret = skb_cow_head(skb, ETH_HLEN + header_size); + if (ret < 0) goto put_primary_if; - } + skb_push(skb, header_size); memcpy(skb->data, &frag_header, header_size); /* Send the last fragment */ -- 2.27.0