From patchwork Fri Jun 24 22:50:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 640476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rbtq120PXz9t0G for ; Sat, 25 Jun 2016 08:51:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=zVxdwZ5G; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2C26510DDE; Fri, 24 Jun 2016 15:51:08 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 3308110DDD for ; Fri, 24 Jun 2016 15:51:07 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id BA6BA16253B for ; Fri, 24 Jun 2016 16:51:06 -0600 (MDT) X-ASG-Debug-ID: 1466808665-0b32375af02c99d0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id E1dkPlxFOZ4FJgZI (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 24 Jun 2016 16:51:05 -0600 (MDT) X-Barracuda-Envelope-From: u9012063@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pf0-f193.google.com) (209.85.192.193) by mx3-pf3.cudamail.com with ESMTPS (AES128-SHA encrypted); 24 Jun 2016 22:51:05 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at _netblocks.google.com designates 209.85.192.193 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.85.192.193 X-Barracuda-RBL-IP: 209.85.192.193 Received: by mail-pf0-f193.google.com with SMTP id 66so10342099pfy.1 for ; Fri, 24 Jun 2016 15:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=opN6ri0SkIkP2YjJID15acTP3pbgzwH8EBHJ6PDGgO8=; b=zVxdwZ5GZwBHkOGKvOGFQGrQIlmMuqfUh1DjBY9ash94FqXJMVi5RYp3JBS80R8WLo X3Xh0TvzSSWRsFwoI+NPN4QGiJrA2Z2Xrww0k1nbMXRCOq0LauDqPkvpBitLdvDb9rW9 +BaGQq3mqOWtI/br9uxShVvYGZi+yg+LhUCaKS0ER5cqTsVNWN+HHjQIiO0Qovm2hFBj ro/lvnxc2kPc84dMrv5gnT3sfD7sPTvm9c3Ojt2fUCS0CVbJqzprdCnJ1vabWlySdZbB yTGcHJrwcdU209Epd0B8sQJA9RD3/16Rj9F7Y9ThcurzXnN3nc3vmPtjP7PBjRTY2kH5 g99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=opN6ri0SkIkP2YjJID15acTP3pbgzwH8EBHJ6PDGgO8=; b=fo1k/N0Q5gd0vMpq9wNv5tS4zCP/EvtRr8Dha70pOgZXCe9ap+lXu/o9J3g9909FGB ZBWwmGdxasownpruy56OoU/hD6GQcgu09vr7cIvg8IIFUX6/sbfuKCzsGrlDYp0iXTld rpG74NkdoYceE4+GMPWYcXL4SZglBmpjbYeW7QozYKnTyPZiYCfLyehT011GeymXnTq6 Zxn8TzLANQ2OOvO3uI3Q3o48VjHDPRZ/8fpBKNrmLvk0ynQLqytrLStpP2TVpPWmUFa7 1tyvtptQwad+kJ0jejurxZ20I8anF9YLe6YAN13t4VVXd7Txc2hDVYgW2LaUgeXwBotx a+lg== X-Gm-Message-State: ALyK8tKm5BnzOT//ldYT5RrDscJEnOfOeuMhlj7PKacBxDw8vDZ1zeLrtvJc+RAWZ8F1fw== X-Received: by 10.98.64.193 with SMTP id f62mr11475851pfd.108.1466808664522; Fri, 24 Jun 2016 15:51:04 -0700 (PDT) Received: from vm-dev.localdomain ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id y10sm2370399pas.24.2016.06.24.15.51.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jun 2016 15:51:03 -0700 (PDT) X-CudaMail-Envelope-Sender: u9012063@gmail.com From: William Tu To: dev@openvswitch.org X-CudaMail-MID: CM-V3-623048791 X-CudaMail-DTE: 062416 X-CudaMail-Originating-IP: 209.85.192.193 Date: Fri, 24 Jun 2016 15:50:58 -0700 X-ASG-Orig-Subj: [##CM-V3-623048791##][PATCH] datapath:backport: openvswitch: Add packet len info to upcall. Message-Id: <1466808658-5324-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.5.0 X-GBUdb-Analysis: 0, 209.85.192.193, Ugly c=0.405176 p=-0.0980392 Source Normal X-MessageSniffer-Rules: 0-0-0-9027-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1466808665 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 3.10 X-Barracuda-Spam-Status: No, SCORE=3.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, BSF_SC7_SA_HREF_FROM_MISMATCH_TEXT_URIx1_HL, DKIM_SIGNED, MAILTO_TO_SPAM_ADDR, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.30735 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.00 MAILTO_TO_SPAM_ADDR URI: Includes a link to a likely spammer email 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 2.50 BSF_SC7_SA_HREF_FROM_MISMATCH_TEXT_URIx1_HL Custom Rule HREF_FROM_MISMATCH_TEXT_URIx1_HL Subject: [ovs-dev] [PATCH] datapath:backport: openvswitch: Add packet len info to upcall. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Upstream commit: commit b95e5928fcc76d156352570858abdea7b2628efd Author: William Tu Date: Mon Jun 20 07:26:17 2016 -0700 The commit f2a4d086ed4c ("openvswitch: Add packet truncation support.") introduces packet truncation before sending to userspace upcall receiver. This patch passes up the skb->len before truncation so that the upcall receiver knows the original packet size. Potentially this will be used by sFlow, where OVS translates sFlow config header=N to a sample action, truncating packet to N byte in kernel datapath. Thus, only N bytes instead of full-packet size is copied from kernel to userspace, saving the kernel-to-userspace bandwidth. Signed-off-by: William Tu Cc: Pravin Shelar Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Tested-at: https://travis-ci.org/williamtu/ovs-travis/builds/140135299 Signed-off-by: William Tu --- datapath/datapath.c | 13 ++++++++++++- datapath/linux/compat/include/linux/openvswitch.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 169bbbb..b02807e 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -395,7 +395,8 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info, { size_t size = NLMSG_ALIGN(sizeof(struct ovs_header)) + nla_total_size(hdrlen) /* OVS_PACKET_ATTR_PACKET */ - + nla_total_size(ovs_key_attr_size()); /* OVS_PACKET_ATTR_KEY */ + + nla_total_size(ovs_key_attr_size()) /* OVS_PACKET_ATTR_KEY */ + + nla_total_size(sizeof(unsigned int)); /* OVS_PACKET_ATTR_LEN */ /* OVS_PACKET_ATTR_USERDATA */ if (upcall_info->userdata) @@ -530,6 +531,16 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, pad_packet(dp, user_skb); } + /* 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); + } + /* Only reserve room for attribute header, packet data is added * in skb_zerocopy() */ diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h index b92d9ed..f1e80db 100644 --- a/datapath/linux/compat/include/linux/openvswitch.h +++ b/datapath/linux/compat/include/linux/openvswitch.h @@ -188,6 +188,7 @@ enum ovs_packet_cmd { * output port is actually a tunnel port. Contains the output tunnel key * extracted from the packet as nested %OVS_TUNNEL_KEY_ATTR_* attributes. * @OVS_PACKET_ATTR_MRU: Present for an %OVS_PACKET_CMD_ACTION and + * @OVS_PACKET_ATTR_LEN: Packet size before truncation. * %OVS_PACKET_ATTR_USERSPACE action specify the Maximum received fragment * size. * @@ -207,6 +208,7 @@ enum ovs_packet_attr { OVS_PACKET_ATTR_PROBE, /* Packet operation is a feature probe, error logging should be suppressed. */ OVS_PACKET_ATTR_MRU, /* Maximum received IP fragment size. */ + OVS_PACKET_ATTR_LEN, /* Packet size before truncation. */ __OVS_PACKET_ATTR_MAX };