From patchwork Wed Sep 16 17:33:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1365746 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.137; helo=fraxinus.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=lVSXe7R4; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BsJxy0lgZz9sTS for ; Thu, 17 Sep 2020 11:18:30 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8ADA386DC9; Wed, 16 Sep 2020 17:34:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vkcd5u-5nbiZ; Wed, 16 Sep 2020 17:34:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id C4DD186DE6; Wed, 16 Sep 2020 17:33:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 999C9C08A5; Wed, 16 Sep 2020 17:33:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id ECD4AC18D3 for ; Wed, 16 Sep 2020 17:33:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D81F28745F for ; Wed, 16 Sep 2020 17:33:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j329jVBhSQpP for ; Wed, 16 Sep 2020 17:33:35 +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 whitealder.osuosl.org (Postfix) with ESMTPS id C8FF187446 for ; Wed, 16 Sep 2020 17:33:31 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id t7so1973581pjd.3 for ; Wed, 16 Sep 2020 10:33:31 -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=VWxRxuacZOgk+GNduiyCig35VxR/Bp09go0nSptACAc=; b=lVSXe7R40O+02ZjgeZf3LWxsFB3pc8zxZFX2KK2sx3LYLKOUar71lNQ4XYU/iFhFbh 9Rfo1f1njfbVNbS6V43l31xchJjxw4x4WFd3A1E8DJ0/p50HcnjzT7vM/NjWVUE2SHyc Z1i5d4ra8hA1Vh/ffMvCPVhlCoAi4pujuzPr4ZCPtwMnGk6QO+8Ns2LSPzTb4s/dF7At ozHsBJNbiIBGNNeeZP5Oua0bWlKU3LC0+CWgprgSaCgcTa2iDW6vXfeL0RwSJE1sKG1Q U1eb2bpnO2d4CdcGKoxYMYxPzCk4l6OMx3ut7aYqHtRKK5nSk5nDYVLbiq7teeGM1uB7 q+kw== 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=VWxRxuacZOgk+GNduiyCig35VxR/Bp09go0nSptACAc=; b=kFEvu7/ugyJnAm4+zHNZD5HO3Vl41++GpIe03LIcrOnar4pjmXUkTC0O2DclIaOfuD UDWTKmYFHhhZ9nBByWys3Cjro16A2vQBzdUxYWQ3sOQ5Vnb8zkqGAURvrY8KpW7hX2TT uBVuzh8RIIp2Tk+MYVpLVb21sx+ZTk487y8SUjt9Fz42bNd0vlvxVU2NAcdQzJLx8TIX tN8/zebE/r/EFXL0LUPb5S4cOWfRKpiJveydepWUmlobtvMEqUVhs71ZyTuJyoi1sdNX +jHbE+IT4vJOM+M5uy5nWi1Ne6UMbS01xC34L7IaiifoF1nbUW6feB3j6YGXwI+JrNZY ebVg== X-Gm-Message-State: AOAM531U4KJnZukeOEfDw1DDbw4FoTwKhOu3U78PuGuPQjmlWi/F9B7v FBswyk50ZqaKJ98kTQX9PCHRE2ApbZ9KRg== X-Google-Smtp-Source: ABdhPJzZjjMOTtkrvm8lsoit1Uxv9Wx5UrSi4kUmOJRZd2qleaptBJWPiHMpY5SpXcIk7EMpwk/lXw== X-Received: by 2002:a17:90b:4acf:: with SMTP id mh15mr4735742pjb.204.1600277611017; Wed, 16 Sep 2020 10:33:31 -0700 (PDT) Received: from VMware-box.domain ([97.115.183.169]) by smtp.googlemail.com with ESMTPSA id o20sm16248519pgh.63.2020.09.16.10.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 10:33:30 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Wed, 16 Sep 2020 10:33:01 -0700 Message-Id: <20200916173311.30956-15-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200916173311.30956-1-gvrose8192@gmail.com> References: <20200916173311.30956-1-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH V3 14/24] 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 Reviewed-by: Tonghao Zhang Signed-off-by: Greg Rose Acked-by: Yi-Hung Wei --- datapath/datapath.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index f04ce210c..b9ac67635 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 */