From patchwork Mon Jul 12 13:27:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 473348 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 035B0C07E99 for ; Mon, 12 Jul 2021 13:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E39BC61006 for ; Mon, 12 Jul 2021 13:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234597AbhGLNaE (ORCPT ); Mon, 12 Jul 2021 09:30:04 -0400 Received: from relay.sw.ru ([185.231.240.75]:49680 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234550AbhGLNaC (ORCPT ); Mon, 12 Jul 2021 09:30:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=6C5q1qZLgzA0flXfJ1uNtbk6wxdWzsUQzpBj7aDLaW8=; b=k2DOrEAxThK9s8h1RPE IZhZdQMYWwGTZwTyl8U8QGD1jYyi0qLTmpU6X0gCCTdnwychX9XtpfeEmnJ3QeaKEKkyTV9ATaz0G 2EYwx2uuIlbRkQzP7Py895qFE/alV7634WDMOviqnIXLmXJtscAC/b1WIMxnv8fhfAZRVsP48Ac=; Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1m2vxo-003iDg-1o; Mon, 12 Jul 2021 16:27:12 +0300 From: Vasily Averin Subject: [PATCH NET 5/7] vrf: use pskb_realloc_headroom in vrf_finish_output To: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Eric Dumazet Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <74e90fba-df9f-5078-13de-41df54d2b257@virtuozzo.com> Message-ID: Date: Mon, 12 Jul 2021 16:27:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Unlike skb_realloc_headroom, new helper pskb_realloc_headroom does not allocate a new skb if possible. Signed-off-by: Vasily Averin --- drivers/net/vrf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 28a6c4c..74b9538 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -863,18 +863,12 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s /* Be paranoid, rather than too clever. */ if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { - struct sk_buff *skb2; + skb = pskb_realloc_headroom(skb, hh_len); - skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev)); - if (!skb2) { - ret = -ENOMEM; - goto err; + if (!skb) { + dev->stats.tx_errors++; + return -ENOMEM; } - if (skb->sk) - skb_set_owner_w(skb2, skb->sk); - - consume_skb(skb); - skb = skb2; } rcu_read_lock_bh();