From patchwork Tue Sep 12 19:49:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xsFmm6Hf4z9s7M for ; Wed, 13 Sep 2017 05:51:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 20369AE1; Tue, 12 Sep 2017 19:50:05 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 784567AA for ; Tue, 12 Sep 2017 19:50:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 277E0159 for ; Tue, 12 Sep 2017 19:50:02 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id e69so4820696pfg.4 for ; Tue, 12 Sep 2017 12:50:02 -0700 (PDT) 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:content-transfer-encoding; bh=KU3xELQohawMfeRLdtGgKh2/UC4VEnJFCOlYqhZkrVI=; b=BF/3bPIfUMB+bmg++I5Cr1c1Xoxi6EVenNteZu1uNgKY/IbiXyivv857gw948cKl9t HNtv0en6YNZB5C3bNqVTPRLPOvOWrl96WjqGbUvNoWJ4LqDGY9E2bsSKSR/CpZ9RYG0Q ybCPFJQ0ZivEDjxGBJvqajYzC8O3ATIAx1WtpYqZr6Jpyp+AZhQGbPPMscRuRwej/uLP 7PJGxEexqAPLalXdp1OeuC5amIhXYo43WcbhEFiZFJyHAcmKU6XT5JkT6473SNcUiO++ H04sYCK4ZPlaKAh88YHSopMIGOepQpsloaNCSatKIv5EeYjsqk0W1w51r/59s1iOY6XN yDLA== X-Gm-Message-State: AHPjjUgV8NnxZXkT7QHID437k3WcYTHpwpTu9biqs9jTeDe1ZdsSLBCv 0byrw0DIojIDGi3x X-Google-Smtp-Source: AOwi7QCSl/uKKJR4tsV2YQ4TQpwc3R7UxxIe/ghKjoPozb8D2RvohsI9h8HTuAyAfSnfFg05OgXJYg== X-Received: by 10.159.245.149 with SMTP id a21mr1896661pls.57.1505245801652; Tue, 12 Sep 2017 12:50:01 -0700 (PDT) Received: from centos.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id j13sm23739951pfk.107.2017.09.12.12.50.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:50:01 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:07 -0700 Message-Id: <1505245749-3402-5-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1505245749-3402-1-git-send-email-azhou@ovn.org> References: <1505245749-3402-1-git-send-email-azhou@ovn.org> X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [merge native tunneling and patch port 5/7] ofproto-dpif-xlate: Refactor xlate_table_actions() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Allow xlate_table_actions() to generate actions with or without enclosed in clone(). Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9e39a4ff7f49..81853c29afbf 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -505,14 +505,20 @@ struct xlate_cfg { static OVSRCU_TYPE(struct xlate_cfg *) xcfgp = OVSRCU_INITIALIZER(NULL); static struct xlate_cfg *new_xcfg = NULL; +typedef void xlate_actions_handler(const struct ofpact *, size_t ofpacts_len, + struct xlate_ctx *, bool); + static bool may_receive(const struct xport *, struct xlate_ctx *); static void do_xlate_actions(const struct ofpact *, size_t ofpacts_len, struct xlate_ctx *, bool); +static void clone_xlate_actions(const struct ofpact *, size_t ofpacts_len, + struct xlate_ctx *, bool); static void xlate_normal(struct xlate_ctx *); static void xlate_table_action(struct xlate_ctx *, ofp_port_t in_port, uint8_t table_id, bool may_packet_in, bool honor_table_miss, bool with_ct_orig, - bool is_last_action); + bool is_last_action, xlate_actions_handler *); + static bool input_vid_is_valid(const struct xlate_ctx *, uint16_t vid, struct xbundle *); static void xvlan_copy(struct xvlan *dst, const struct xvlan *src); @@ -3560,7 +3566,7 @@ apply_nested_clone_actions(struct xlate_ctx *ctx, const struct xport *in_dev, if (xport_stp_forward_state(out_dev) && xport_rstp_forward_state(out_dev)) { xlate_table_action(ctx, flow->in_port.ofp_port, 0, true, true, - false, true); + false, true, clone_xlate_actions); if (!ctx->freezing) { xlate_action_set(ctx); } @@ -3575,7 +3581,7 @@ apply_nested_clone_actions(struct xlate_ctx *ctx, const struct xport *in_dev, mirror_mask_t old_mirrors2 = ctx->mirrors; xlate_table_action(ctx, flow->in_port.ofp_port, 0, true, true, - false, true); + false, true, clone_xlate_actions); ctx->mirrors = old_mirrors2; ctx->base_flow = old_base_flow; ctx->odp_actions->size = old_size; @@ -3894,7 +3900,8 @@ compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port, static void xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule, - bool deepens, bool is_last_action) + bool deepens, bool is_last_action, + xlate_actions_handler *actions_xlator) { struct rule_dpif *old_rule = ctx->rule; ovs_be64 old_cookie = ctx->rule_cookie; @@ -3910,8 +3917,8 @@ xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule, ctx->rule = rule; ctx->rule_cookie = rule->up.flow_cookie; actions = rule_get_actions(&rule->up); - do_xlate_actions(actions->ofpacts, actions->ofpacts_len, ctx, - is_last_action); + actions_xlator(actions->ofpacts, actions->ofpacts_len, ctx, + is_last_action); ctx->rule_cookie = old_cookie; ctx->rule = old_rule; ctx->depth -= deepens; @@ -3986,7 +3993,8 @@ tuple_swap(struct flow *flow, struct flow_wildcards *wc) static void xlate_table_action(struct xlate_ctx *ctx, ofp_port_t in_port, uint8_t table_id, bool may_packet_in, bool honor_table_miss, - bool with_ct_orig, bool is_last_action) + bool with_ct_orig, bool is_last_action, + xlate_actions_handler *xlator) { /* Check if we need to recirculate before matching in a table. */ if (ctx->was_mpls) { @@ -4038,7 +4046,7 @@ xlate_table_action(struct xlate_ctx *ctx, ofp_port_t in_port, uint8_t table_id, struct ovs_list *old_trace = ctx->xin->trace; xlate_report_table(ctx, rule, table_id); xlate_recursively(ctx, rule, table_id <= old_table_id, - is_last_action); + is_last_action, xlator); ctx->xin->trace = old_trace; } @@ -4341,7 +4349,7 @@ xlate_ofpact_resubmit(struct xlate_ctx *ctx, xlate_table_action(ctx, in_port, table_id, may_packet_in, honor_table_miss, resubmit->with_ct_orig, - is_last_action); + is_last_action, do_xlate_actions); } static void @@ -4888,7 +4896,8 @@ xlate_output_action(struct xlate_ctx *ctx, break; case OFPP_TABLE: xlate_table_action(ctx, ctx->xin->flow.in_port.ofp_port, - 0, may_packet_in, true, false, is_last_action); + 0, may_packet_in, true, false, is_last_action, + do_xlate_actions); break; case OFPP_NORMAL: xlate_normal(ctx); @@ -6554,7 +6563,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, ovs_assert(ctx->table_id < ogt->table_id); xlate_table_action(ctx, ctx->xin->flow.in_port.ofp_port, - ogt->table_id, true, true, false, last); + ogt->table_id, true, true, false, last, + do_xlate_actions); break; }