From patchwork Sat Nov 7 19:59:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 541371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 5CEBD1402C6 for ; Sun, 8 Nov 2015 07:01:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nicira_com.20150623.gappssmtp.com header.i=@nicira_com.20150623.gappssmtp.com header.b=cJ6cdNZo; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id DB9AE10A7C; Sat, 7 Nov 2015 12:00:32 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 7183E10A57 for ; Sat, 7 Nov 2015 12:00:31 -0800 (PST) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id E569E1E0295 for ; Sat, 7 Nov 2015 13:00:30 -0700 (MST) X-ASG-Debug-ID: 1446926430-09eadd03648fb80001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id KPB3SXqOtFFY9CBR (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 07 Nov 2015 13:00:30 -0700 (MST) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f49.google.com) (209.85.220.49) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 7 Nov 2015 20:00:30 -0000 Received-SPF: unknown (mx1-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.49 Received: by pasz6 with SMTP id z6so160772596pas.2 for ; Sat, 07 Nov 2015 12:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicira_com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=tm0s8p9QjL8o1XfySBoaAgnYohDjIZ3pFeVS5FvZzzo=; b=cJ6cdNZo9uiejAg2ewioZkNno5FN8KaI1sWi9P+8CAZq8xSgGyCqW4UEL3s4wkSh+Q VlrZMtk1vS+FK9frG6tPaT4aHjV4tsh+zAr1/KES8hZIExVLcl4wssbZD0Vm9AGOOKMS PfXOzRzzj99BnbrCKa/9qfykOCCpWlCLGbQMPzeHCPf6Tcamu5qm2tXu7wtHCnLort/d Ik3GIq5Dk1e1YYXBW1O/bUbx55EDpY9GERnfn1IPNEgY075N5PfZaxY5BTwY+QadcR0W RhIk7sRKQQSB1uELTLaI4eIXBOeo2y9yvoKNThbdqt5TN2LsPypXbzKWg/iWk6NyvxQ0 ZmZA== 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:in-reply-to :references; bh=tm0s8p9QjL8o1XfySBoaAgnYohDjIZ3pFeVS5FvZzzo=; b=l3OFEnpqz6fYcxtethzN+bz159BHo+twwNlGl3Ao8vvLPu2ZhxFegVFLQRnxooUZ/E Ty7oFTRIFKaWlIkzQodKixd+TIOoV8y85OuDEWqXbDWU+luAasybBn6g+uNMEnRzr4Ws MfgkdLEi9w/dUNCCPuXJjQ1Rv/iXENQ+BNx0CTseVS++2TLbs52mlPN9s1quDYkj6INu xZ2/Y3ugQIcjgPep8R33NlYCHCTctbaBKUD2KDsvPHcfyc2RrvPpkfxbceCzxZNwSW+4 A8FHslnkIJq4kagIaNoBG52bhMjqrqx3lnmOAmWsPz4bMNu+sH7ky7+67zRMyAkYcUUJ 1yQg== X-Gm-Message-State: ALoCoQmn3PYP0+PECP3pprH/7CkkO/dmI8QLB7qBVsitp882WZLiEXY5Z/tFtsqZyFlGZloZHEZe X-Received: by 10.68.217.2 with SMTP id ou2mr27145843pbc.81.1446926429921; Sat, 07 Nov 2015 12:00:29 -0800 (PST) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id nu5sm7312219pbb.65.2015.11.07.12.00.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Nov 2015 12:00:29 -0800 (PST) X-CudaMail-Envelope-Sender: joestringer@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1106023138 X-CudaMail-DTE: 110715 X-CudaMail-Originating-IP: 209.85.220.49 Date: Sat, 7 Nov 2015 11:59:51 -0800 X-ASG-Orig-Subj: [##CM-E2-1106023138##][PATCH 13/23] datapath: Serialize acts with original netlink len Message-Id: <1446926401-55723-14-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446926401-55723-1-git-send-email-joestringer@nicira.com> References: <1446926401-55723-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1446926430 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 13/23] datapath: Serialize acts with original netlink len 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" Previously, we used the kernel-internal netlink actions length to calculate the size of messages to serialize back to userspace. However,the sw_flow_actions may not be formatted exactly the same as the actions on the wire, so store the original actions length when de-serializing and re-use the original length when serializing. Upstream: 8e2fed1 "openvswitch: Serialize acts with original netlink len" Signed-off-by: Joe Stringer --- datapath/datapath.c | 2 +- datapath/flow.h | 1 + datapath/flow_netlink.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index f6a0cd3a5b09..9e6f6147d407 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -725,7 +725,7 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts, /* OVS_FLOW_ATTR_ACTIONS */ if (should_fill_actions(ufid_flags)) - len += nla_total_size(acts->actions_len); + len += nla_total_size(acts->orig_len); return len + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */ diff --git a/datapath/flow.h b/datapath/flow.h index 1abb2e15ad5d..61fa708451d7 100644 --- a/datapath/flow.h +++ b/datapath/flow.h @@ -143,6 +143,7 @@ struct sw_flow_id { struct sw_flow_actions { struct rcu_head rcu; + size_t orig_len; /* From flow_cmd_new netlink actions size */ u32 actions_len; struct nlattr actions[]; }; diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c index af3639b34e6e..c510c4fc61bc 100644 --- a/datapath/flow_netlink.c +++ b/datapath/flow_netlink.c @@ -1660,6 +1660,7 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len); acts->actions_len = (*sfa)->actions_len; + acts->orig_len = (*sfa)->orig_len; kfree(*sfa); *sfa = acts; @@ -2259,6 +2260,7 @@ int ovs_nla_copy_actions(const struct nlattr *attr, if (IS_ERR(*sfa)) return PTR_ERR(*sfa); + (*sfa)->orig_len = nla_len(attr); err = __ovs_nla_copy_actions(attr, key, 0, sfa, key->eth.type, key->eth.tci, log); if (err)