Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3521000pxf; Mon, 15 Mar 2021 11:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2RyAwCPGWIQ42IMooYk0p/oOLk6/XURjvIPlwDuG8wdAG2lTwdr17EPp7Uv3ZOUY95/Tj X-Received: by 2002:aa7:c3c1:: with SMTP id l1mr32017862edr.208.1615832628442; Mon, 15 Mar 2021 11:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832628; cv=none; d=google.com; s=arc-20160816; b=WRj61wH5BBQtpOMkTW9u9BXyLnClnyEe030vFdB6EYd1wW0n3T3Sz0RC704eOdNnAE d/8Tx0o/upkI+ggHSUbq5mp5fLSsBIhCdQELQlvHlT28X9c4wy1UyCDsTxtJPRfPHOCM SzMNwpOn8myUuSpq6PD4VnAvXAAmU4WqMg+BqHojJRCqsBK+MJCAG5aPekLFd/Qbe38c uWrnrj0z3ovbROLa7/0p0iMCUjg7BzboLg4SIx3rsDYBq5HyoiTuJNV+k/Xek98J0GME Xp3BVwQL9x2T7FCVTjdoL2LViTv0QE8mV6SGncGENijVlkWf2C6xrRPuCWMUjvr1337q TBbg== 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:dkim-signature; bh=fmx790zPxWDzfvHAa/02Z+gP/Y0bb07MN/lAHY4cQfI=; b=lxNpkD/158OKM/muhiRNdQXBJpHOSPKNpf7xVB+PdgCyeAEDnuZB35p+HTSFtfbXVU 8hyrOTSpvbiOrGfXLKobNdb73r/8I47ElqbcHQrVVwTBK6/a4EPeputV8WF8FdfTBzJ/ HpuAvwE4B+DrUyKXea7zGQ92Qsi48qzVVV8qy13r/EQRo4JTiMYTdXkQCiL24u7CKFyL i4gFUJX6J9h0B/lPJoMt8z/slHdCF9bR42DJ1bN+05l2bn3HRWWD1X3QiKF1Cx81vziF /Fznk5cQ4ssnHyzdqDpt2H7KJcqMC3LcSDE97k927WbmMjNdJGgvQzTL99JO2WskZdGd Qxeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=reUofijc; 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=pass (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 i26si8640337edb.84.2021.03.15.11.23.25; Mon, 15 Mar 2021 11:23:48 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=reUofijc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238381AbhCOOXI (ORCPT + 99 others); Mon, 15 Mar 2021 10:23:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:36594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232016AbhCOOAF (ORCPT ); Mon, 15 Mar 2021 10:00:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5426364F6E; Mon, 15 Mar 2021 13:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816788; bh=Urk2Yb0PYFEln6/sAQFmJc+KSUuE1VgJnDV/ISFiNWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=reUofijc1O0ka54A1ONk/sdaqXT6pboHwJxivSXKT8QUh4jhN7tvicYWClk8RoECV lNXvXL9YUJVjAOx+NL/YoqdbRBz07bQSbEybxDRPwKZhI2NMLJff3lvDWeFR58qaTF V3y+fZEGrm/jUwFS2qrhFPQfGnivtfFskIOrSH5A= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Eggers , Vladimir Oltean , Florian Fainelli , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 115/290] net: dsa: trailer: dont allocate additional memory for padding/tagging Date: Mon, 15 Mar 2021 14:53:28 +0100 Message-Id: <20210315135545.807996307@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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: Greg Kroah-Hartman From: Christian Eggers [ Upstream commit ef3f72fee286bd270453ce2344feb7295a798508 ] The caller (dsa_slave_xmit) guarantees that the frame length is at least ETH_ZLEN and that enough memory for tail tagging is available. Signed-off-by: Christian Eggers Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/dsa/tag_trailer.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index 3a1cc24a4f0a..5b97ede56a0f 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -13,42 +13,15 @@ static struct sk_buff *trailer_xmit(struct sk_buff *skb, struct net_device *dev) { struct dsa_port *dp = dsa_slave_to_port(dev); - struct sk_buff *nskb; - int padlen; u8 *trailer; - /* - * We have to make sure that the trailer ends up as the very - * last 4 bytes of the packet. This means that we have to pad - * the packet to the minimum ethernet frame size, if necessary, - * before adding the trailer. - */ - padlen = 0; - if (skb->len < 60) - padlen = 60 - skb->len; - - nskb = alloc_skb(NET_IP_ALIGN + skb->len + padlen + 4, GFP_ATOMIC); - if (!nskb) - return NULL; - skb_reserve(nskb, NET_IP_ALIGN); - - skb_reset_mac_header(nskb); - skb_set_network_header(nskb, skb_network_header(skb) - skb->head); - skb_set_transport_header(nskb, skb_transport_header(skb) - skb->head); - skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); - consume_skb(skb); - - if (padlen) { - skb_put_zero(nskb, padlen); - } - - trailer = skb_put(nskb, 4); + trailer = skb_put(skb, 4); trailer[0] = 0x80; trailer[1] = 1 << dp->index; trailer[2] = 0x10; trailer[3] = 0x00; - return nskb; + return skb; } static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev, -- 2.30.1