From patchwork Thu Aug 20 22:49:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1348658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=N87zNIHo; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BXfxp37Jvz9sPf for ; Fri, 21 Aug 2020 08:50:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B76808855F; Thu, 20 Aug 2020 22:50:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lgFMxTlVC95g; Thu, 20 Aug 2020 22:50:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 6A178885B5; Thu, 20 Aug 2020 22:50:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4FC0DC08A8; Thu, 20 Aug 2020 22:50:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86EBEC08A2 for ; Thu, 20 Aug 2020 22:50:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6E4438853D for ; Thu, 20 Aug 2020 22:50:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6keBsOe3YFzz for ; Thu, 20 Aug 2020 22:50:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id A4AEA8856C for ; Thu, 20 Aug 2020 22:50:27 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id kr4so93084pjb.2 for ; Thu, 20 Aug 2020 15:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l1C40JIK8GpqHiXirctRDKmrElQBebl3B0hZsxDuKps=; b=N87zNIHoxYGrrPpIskZE8AQHQrEGcOsi2dpKfOrlTLtxvw/lo8XvADB3wQXb5YJxfL RVZUStT0vImOBbzLSlKX99ML6rB7gg3rqYoIjzCX0uQjDEKCOWJ/1hYGtOuttIXEpKuJ TNwj7GMzahv0iW4FwIfvYlq/7AoSA3TRhfe3Xy2o8QleMSO7skOyQHUKTxqeEGJJMAcc Fx1DQwnlo8MzrMuSMr9S2uFkTwcg05f1IzM/SGDafd3M2Zhr6iCcXmydiO8VYPxm0cgv 9Zoxpv+w8MLcSStS24S7oFKBweyWUyPVlJjACRRQz1z3/Qvodm1EzxAR23PKNAetKJ9n r1Iw== 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:in-reply-to :references; bh=l1C40JIK8GpqHiXirctRDKmrElQBebl3B0hZsxDuKps=; b=iOVyQKJ430vPfdXSS4FWucgUPVJflCBE133cxMz70kuF5LjrcaI3rBRiszfzGQvnJG d+3yQBJD/X5lpbLCPisVVGVziJsg2Oe80o3XLBcbCgq3Zqc7Ool0fQno/M4D95aDag5O JKosJDLOKdrhKIw0ILuRnMlz3MXCYcsoylbY8BzuJT3S9nPaHVDjfFOtP0QGTmHOcE05 GZ8aW0CmlDEmbvtlh2SZGwTStN9ZZrpO2bdfeDelDImz2OLd27v65OXlCDMRODxTg5u/ hU3NFvunfSImdgGXxkpqmXzMtOwU8FReW/jF5mLsvIz3fTUo/HQ/h7HrQ+yEJ53gAdqP 3BTQ== X-Gm-Message-State: AOAM531PvFFvl86PjKP7bPyMh/qcJzuCtMGGMQfQvi9EtMlTVepLY5sH ro8/OPC86b4On/nnzcoXL8r4RVcpeLO2Dg== X-Google-Smtp-Source: ABdhPJyvGjg+mZpWWr1529F2s6O2Bv8pwCqtsEFgUtYBrycTR8IrRNwNJHwOpxKiVqoXRTK2HSkLnQ== X-Received: by 2002:a17:902:c212:: with SMTP id 18mr22248pll.250.1597963826889; Thu, 20 Aug 2020 15:50:26 -0700 (PDT) Received: from gizo.domain (97-115-99-106.ptld.qwest.net. [97.115.99.106]) by smtp.gmail.com with ESMTPSA id y6sm116866pfr.61.2020.08.20.15.50.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 15:50:26 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 20 Aug 2020 15:49:42 -0700 Message-Id: <1597963790-12362-16-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> References: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 15/23] datapath: don't call pad_packet if not necessary X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang Upstream commit: commit 61ca533c0e94104c35fcb7858a23ec9a05d78143 Author: Tonghao Zhang Date: Thu Nov 14 23:51:08 2019 +0800 net: openvswitch: don't call pad_packet if not necessary The nla_put_u16/nla_put_u32 makes sure that *attrlen is align. The call tree is that: nla_put_u16/nla_put_u32 -> nla_put attrlen = sizeof(u16) or sizeof(u32) -> __nla_put attrlen -> __nla_reserve attrlen -> skb_put(skb, nla_total_size(attrlen)) nla_total_size returns the total length of attribute including padding. Cc: Joe Stringer Cc: William Tu Signed-off-by: Tonghao Zhang Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Cc: Tonghao Zhang Signed-off-by: Greg Rose Reviewed-by: Tonghao Zhang --- datapath/datapath.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index f04ce21..b9ac676 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -512,23 +512,17 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, } /* Add OVS_PACKET_ATTR_MRU */ - if (upcall_info->mru) { - if (nla_put_u16(user_skb, OVS_PACKET_ATTR_MRU, - upcall_info->mru)) { - err = -ENOBUFS; - goto out; - } - pad_packet(dp, user_skb); + if (upcall_info->mru && + nla_put_u16(user_skb, OVS_PACKET_ATTR_MRU, upcall_info->mru)) { + err = -ENOBUFS; + goto out; } /* Add OVS_PACKET_ATTR_LEN when packet is truncated */ - if (cutlen > 0) { - if (nla_put_u32(user_skb, OVS_PACKET_ATTR_LEN, - skb->len)) { - err = -ENOBUFS; - goto out; - } - pad_packet(dp, user_skb); + if (cutlen > 0 && + nla_put_u32(user_skb, OVS_PACKET_ATTR_LEN, skb->len)) { + err = -ENOBUFS; + goto out; } /* Add OVS_PACKET_ATTR_HASH */