From patchwork Wed Sep 21 01:47:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 672504 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 3sf2Zr1rSrz9s4n for ; Wed, 21 Sep 2016 11:48:20 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BC774106BC; Tue, 20 Sep 2016 18:47:43 -0700 (PDT) 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 25840106B0 for ; Tue, 20 Sep 2016 18:47:43 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id B14551E03E2 for ; Tue, 20 Sep 2016 19:47:42 -0600 (MDT) X-ASG-Debug-ID: 1474422461-09eadd3531861a20001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar5.cudamail.com with ESMTP id CPRJNfScwtbuBWSA (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 20 Sep 2016 19:47:41 -0600 (MDT) X-Barracuda-Envelope-From: joe@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO relay6-d.mail.gandi.net) (217.70.183.198) by mx3-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Sep 2016 01:47:41 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.198 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.198 X-Barracuda-RBL-IP: 217.70.183.198 Received: from mfilter20-d.gandi.net (mfilter20-d.gandi.net [217.70.178.148]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id CF395FB8B6; Wed, 21 Sep 2016 03:47:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter20-d.gandi.net Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter20-d.gandi.net (mfilter20-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id YyOVfl6f0OIE; Wed, 21 Sep 2016 03:47:38 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from archer.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3B8DEFB887; Wed, 21 Sep 2016 03:47:36 +0200 (CEST) X-CudaMail-Envelope-Sender: joe@ovn.org From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-919063185 X-CudaMail-DTE: 092016 X-CudaMail-Originating-IP: 217.70.183.198 Date: Tue, 20 Sep 2016 18:47:33 -0700 X-ASG-Orig-Subj: [##CM-V1-919063185##][PATCH 4/6] revalidator: Reuse xlate_ukey from deletion. Message-Id: <20160921014735.25191-5-joe@ovn.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160921014735.25191-1-joe@ovn.org> References: <20160921014735.25191-1-joe@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1474422461 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 4/6] revalidator: Reuse xlate_ukey from deletion. 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" This code was already very similar to the actual revalidation code, but previously it wasn't structured quite closely enough to share it. Do so. xlate_actions_for_side_effects() is now unused, so remove it. Signed-off-by: Joe Stringer --- ofproto/ofproto-dpif-upcall.c | 48 ++++++++++++++++++++----------------------- ofproto/ofproto-dpif-xlate.c | 18 ---------------- ofproto/ofproto-dpif-xlate.h | 1 - 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 052e502de696..1caff84cfd38 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1837,23 +1837,22 @@ struct reval_context { struct flow flow; }; -/* Translates 'ukey->key' into a flow, populating 'ctx' as it goes along. +/* Translates 'key' into a flow, populating 'ctx' as it goes along. * * Returns 0 on success, otherwise a positive errno value. * * The caller is responsible for uninitializing ctx->xout on success. */ static int -xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey, - const struct dpif_flow_stats *push, struct reval_context *ctx) +xlate_key(struct udpif *udpif, const struct nlattr *key, unsigned int len, + const struct dpif_flow_stats *push, struct reval_context *ctx) { struct ofproto_dpif *ofproto; ofp_port_t ofp_in_port; struct xlate_in xin; int error; - if (odp_flow_key_to_flow(ukey->key, ukey->key_len, &ctx->flow) - == ODP_FIT_ERROR) { + if (odp_flow_key_to_flow(key, len, &ctx->flow) == ODP_FIT_ERROR) { return EINVAL; } @@ -1876,6 +1875,13 @@ xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey, return 0; } +static int +xlate_ukey(struct udpif *udpif, const struct udpif_key *ukey, + const struct dpif_flow_stats *push, struct reval_context *ctx) +{ + return xlate_key(udpif, ukey->key, ukey->key_len, push, ctx); +} + static enum reval_result revalidate_ukey__(struct udpif *udpif, struct udpif_key *ukey, const struct dpif_flow_stats *push, @@ -2115,10 +2121,10 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) if (push->n_packets || netflow_exists()) { const struct nlattr *key = op->dop.u.flow_del.key; size_t key_len = op->dop.u.flow_del.key_len; - struct ofproto_dpif *ofproto; struct netflow *netflow; - ofp_port_t ofp_in_port; - struct flow flow; + struct reval_context ctx = { + .netflow = &netflow, + }; int error; if (op->ukey) { @@ -2133,26 +2139,16 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) key_len = op->ukey->key_len; } - if (odp_flow_key_to_flow(key, key_len, &flow) - == ODP_FIT_ERROR) { - continue; - } - - error = xlate_lookup(udpif->backer, &flow, &ofproto, NULL, NULL, - &netflow, &ofp_in_port); - if (!error) { - struct xlate_in xin; - - xlate_in_init(&xin, ofproto, - ofproto_dpif_get_tables_version(ofproto), - &flow, ofp_in_port, NULL, - push->tcp_flags, NULL, NULL, NULL); - xin.resubmit_stats = push->n_packets ? push : NULL; - xin.allow_side_effects = push->n_packets > 0; - xlate_actions_for_side_effects(&xin); + error = xlate_key(udpif, key, key_len, push, &ctx); + if (error) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rl, "xlate_actions failed (%s)!", + xlate_strerror(error)); + } else { + xlate_out_uninit(&ctx.xout); if (netflow) { - netflow_flow_clear(netflow, &flow); + netflow_flow_clear(netflow, &ctx.flow); } } } diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 74a4b5b7c0f1..ff0a07f02dc7 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5083,24 +5083,6 @@ xlate_out_uninit(struct xlate_out *xout) recirc_refs_unref(&xout->recircs); } } - -/* Translates the 'ofpacts_len' bytes of "struct ofpact"s starting at 'ofpacts' - * into datapath actions, using 'ctx', and discards the datapath actions. */ -void -xlate_actions_for_side_effects(struct xlate_in *xin) -{ - struct xlate_out xout; - enum xlate_error error; - - error = xlate_actions(xin, &xout); - if (error) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - - VLOG_WARN_RL(&rl, "xlate_actions failed (%s)!", xlate_strerror(error)); - } - - xlate_out_uninit(&xout); -} static struct skb_priority_to_dscp * get_skb_priority(const struct xport *xport, uint32_t skb_priority) diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index 1768740edd42..24b061991526 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -208,7 +208,6 @@ void xlate_in_init(struct xlate_in *, struct ofproto_dpif *, ovs_version_t, uint16_t tcp_flags, const struct dp_packet *packet, struct flow_wildcards *, struct ofpbuf *odp_actions); void xlate_out_uninit(struct xlate_out *); -void xlate_actions_for_side_effects(struct xlate_in *); enum ofperr xlate_resume(struct ofproto_dpif *, const struct ofputil_packet_in_private *,