From patchwork Tue Sep 12 19:49:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813027 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 3xsFkh5rknz9sPm for ; Wed, 13 Sep 2017 05:50:03 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 22309A6E; Tue, 12 Sep 2017 19:50:00 +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 B611A8EE for ; Tue, 12 Sep 2017 19:49:58 +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 5945B159 for ; Tue, 12 Sep 2017 19:49:58 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id q76so6599617pfq.5 for ; Tue, 12 Sep 2017 12:49:58 -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 :content-transfer-encoding; bh=pbGCKlZzCM7kP2hmglhTVS/8MNKF/nLC3OXsVHaOEb0=; b=VwKD3CaN4e1V4R9FNXcjhF4cAt/P+lt0/kxw9zN5pe4dDIeTcPtNnVIntztq2Sga2b z7Sj36wUu4OwP+nmysTCPZHge2/3Eegby2pJMDcUCvtH0k3zKtLaj1M3VZRsTQT8BE8f OP5wNakgXjg7FmneSOgZXaXuRmssBcMUOAuK2iCeNlvl2wYIINq1GWviLeWrvmkoa6q6 3SV9TRXPQ9jriejlLDSx9sAaMDR294NM5Xw3sZj42L1YR4ihEZnyOGvx6W+i90+Srnnx ddc2ssJvWaSp0p0Oezr6pnPU+1fAMS4zPXN8jVx8QSFQnh04/6nUsvkZ02L0ndzIZzBF SzJQ== X-Gm-Message-State: AHPjjUj3fR+1DMxL/vl2wi1q8zUTjGSA2ACwp62HZz77Doj1753rDcJr NKK9lFoqQOlqYMWY X-Google-Smtp-Source: ADKCNb61l/7w0dJN0Bsm7P9GQjmCFH46PqR+mXj7uQEEYT47bnScwgv29GRlYfjGQp9u3m5rSOfsnA== X-Received: by 10.98.32.92 with SMTP id g89mr16061198pfg.285.1505245797804; Tue, 12 Sep 2017 12:49:57 -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.49.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:49:56 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:03 -0700 Message-Id: <1505245749-3402-1-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.8.3.1 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 1/7] ofproto-dpif: Unfreeze within clone 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 When translating actions within open flow clone, actions generated by finish_freezeing() should also be enclosed within the datapath clone netlink encoding. Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9e1f837cb23e..e5ad832d7c47 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5353,6 +5353,9 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) if (reversible_actions(oc->actions, oc_actions_len)) { old_flow = ctx->xin->flow; do_xlate_actions(oc->actions, oc_actions_len, ctx); + if (ctx->freezing) { + finish_freezing(ctx); + } goto xlate_done; } @@ -5372,6 +5375,9 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE); ac_offset = ctx->odp_actions->size; do_xlate_actions(oc->actions, oc_actions_len, ctx); + if (ctx->freezing) { + finish_freezing(ctx); + } nl_msg_end_non_empty_nested(ctx->odp_actions, offset); goto dp_clone_done; } @@ -5382,6 +5388,9 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) ac_offset = nl_msg_start_nested(ctx->odp_actions, OVS_SAMPLE_ATTR_ACTIONS); do_xlate_actions(oc->actions, oc_actions_len, ctx); + if (ctx->freezing) { + finish_freezing(ctx); + } if (nl_msg_end_non_empty_nested(ctx->odp_actions, ac_offset)) { nl_msg_cancel_nested(ctx->odp_actions, offset); } else { From patchwork Tue Sep 12 19:49:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813028 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 3xsFlP1lbbz9s7M for ; Wed, 13 Sep 2017 05:50:41 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 35497A84; Tue, 12 Sep 2017 19:50:03 +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 871FF7AA for ; Tue, 12 Sep 2017 19:49:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4E6DC159 for ; Tue, 12 Sep 2017 19:49:59 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id i130so4623433pgc.0 for ; Tue, 12 Sep 2017 12:49:59 -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=D3gc1sOhBGgkbekQh/SXzXgvGHuQWmxNo4bzRRLcrrc=; b=Kmdw1ni6qvzaS7tEgGbqrlacy8PvHfyJQcfc4/rzzsGrk8RSvo71kfHW6ZZMMrJOjt dSMSSZUZawHwvcKBcfaQTYkPVcwXdPM96hzR3Spqi7PpQg1Rjj4O/81G29PPtdgnlnVT RLakaKdI6TcCSPEzzkwSmO/khZQGSm3zy1QTI1yzZMQdudGwShxXAZ1Q/7bWbyVV0okL M5aOxx8XZ9ISURfrzhM+siH+CFOp4Yc6dX3n1uQGPelKxzBPS2tz9WQQkpPO06EdAefI M0n1fpV4OQK4Lz4BdzzkbFcHWQ+myjVTOpIJCfIQ9Isj6bRp6Ty11h41eDmj2zjem9pk eFBg== X-Gm-Message-State: AHPjjUjfmtyqUS+hMvMU7fBJncLxHLMR1s0Wu4UYHDnSTHsbkT3wA2d2 LCXryna+w++Ujpvh X-Google-Smtp-Source: ADKCNb40vmjfhnjo1pCid1CCUvjYAUbRya7t35Ocas449OOd+C5qDavJ9gGWptXoyJJvv34FpPo3cA== X-Received: by 10.84.129.226 with SMTP id b89mr17790509plb.84.1505245798888; Tue, 12 Sep 2017 12:49:58 -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.49.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:49:58 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:04 -0700 Message-Id: <1505245749-3402-2-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.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 2/7] ofproto-dpif-xlate: Remove uncessary assignment 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 Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index e5ad832d7c47..d5b47666e974 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5373,7 +5373,6 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) if (ctx->xbridge->support.clone) { /* Use clone action */ /* Use clone action as datapath clone. */ offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE); - ac_offset = ctx->odp_actions->size; do_xlate_actions(oc->actions, oc_actions_len, ctx); if (ctx->freezing) { finish_freezing(ctx); From patchwork Tue Sep 12 19:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813029 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 3xsFm80tfdz9sNV for ; Wed, 13 Sep 2017 05:51:20 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2834AA73; Tue, 12 Sep 2017 19:50:04 +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 69986A73 for ; Tue, 12 Sep 2017 19:50:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2F268159 for ; Tue, 12 Sep 2017 19:50:00 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id v5so6615892pgn.4 for ; Tue, 12 Sep 2017 12:50:00 -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=h8tqtdRbdmFHuSecgdtXYGQ7ojJ1pzNjzBFVKhkt2mU=; b=DGlLP5uxed+upMHg31LqZkL8610IsQKwy6RjjAMyHkTSPJ2gSm8rHOSXUVwI3qPgQJ v1I3RdMqp+6GtkNDXUPP9bRUGREhucgu3/kamRYj/l24CF7zr2DQkt4Cwu4fdFFvAA++ hTv0NrqVmciuoExlOw7kuHpxhNGOxcREdiCUrScSUvvoYPQrI9LUmrb7uUouDLY7oc4k Mku/EUY+q+blhA1Kna5fhsrMvX4YA1UDu1+WVDWIF5bDX8Wi//JrVPHULgjC40Ne+IZn YcmBypxl+wIe7uYZFf/cLjMp0nCdL9lrkMAOgYUE21NuD5X/o2lmMtat3Ae8Op5g5tPP Gz6A== X-Gm-Message-State: AHPjjUgpZDs3prihFSlpcMS0Umv+V2F/2S29YTaIzKKWN0G6OfO9Xa7T HnHXJOlGgabegrVR X-Google-Smtp-Source: ADKCNb6zjGiI7Mv0XwagS34qTUP9oaLVwYGr/f4O67PKdIzsxbuFWrbUWttiTnnlHf9Pbf2aLQm/qA== X-Received: by 10.101.93.5 with SMTP id e5mr15747904pgr.55.1505245799707; Tue, 12 Sep 2017 12:49:59 -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.49.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:49:59 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:05 -0700 Message-Id: <1505245749-3402-3-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 3/7] ofproto-dpif: Refactor compose_clone() 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 Add a new function clone_xlate_actions(), which shares the same signature as do_xlate_actions(); Later patch will make use of this function. Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index d5b47666e974..223313d4ecba 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5334,7 +5334,8 @@ reversible_actions(const struct ofpact *ofpacts, size_t ofpacts_len) } static void -compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) +clone_xlate_actions(const struct ofpact *actions, size_t actions_len, + struct xlate_ctx *ctx) { struct ofpbuf old_stack = ctx->stack; union mf_subvalue new_stack[1024 / sizeof(union mf_subvalue)]; @@ -5347,12 +5348,11 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) ofpbuf_put(&ctx->action_set, old_action_set.data, old_action_set.size); size_t offset, ac_offset; - size_t oc_actions_len = ofpact_nest_get_action_len(oc); struct flow old_flow = ctx->xin->flow; - if (reversible_actions(oc->actions, oc_actions_len)) { + if (reversible_actions(actions, actions_len)) { old_flow = ctx->xin->flow; - do_xlate_actions(oc->actions, oc_actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx); if (ctx->freezing) { finish_freezing(ctx); } @@ -5373,7 +5373,7 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) if (ctx->xbridge->support.clone) { /* Use clone action */ /* Use clone action as datapath clone. */ offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE); - do_xlate_actions(oc->actions, oc_actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx); if (ctx->freezing) { finish_freezing(ctx); } @@ -5386,7 +5386,7 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_SAMPLE); ac_offset = nl_msg_start_nested(ctx->odp_actions, OVS_SAMPLE_ATTR_ACTIONS); - do_xlate_actions(oc->actions, oc_actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx); if (ctx->freezing) { finish_freezing(ctx); } @@ -5425,6 +5425,14 @@ xlate_done: } static void +compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) +{ + size_t oc_actions_len = ofpact_nest_get_action_len(oc); + + clone_xlate_actions(oc->actions, oc_actions_len, ctx); +} + +static void xlate_meter_action(struct xlate_ctx *ctx, const struct ofpact_meter *meter) { if (meter->provider_meter_id != UINT32_MAX) { From patchwork Tue Sep 12 19:49:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813032 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 3xsFnK3bZ1z9s7M for ; Wed, 13 Sep 2017 05:52:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1F730AF7; Tue, 12 Sep 2017 19:50:06 +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 A09A27AA for ; Tue, 12 Sep 2017 19:50:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5B52A1DF for ; Tue, 12 Sep 2017 19:50:01 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id e1so20208296pfk.1 for ; Tue, 12 Sep 2017 12:50:01 -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=4PKCYQs9rJ6SDSlAzVyv3QjZbQz7L269jM7+FmDH13s=; b=B6V4QkFQgOUjbcVXXnqiqKrcUslIi8Yl2Sp096qOmjwNgIrcT6xIyLbJdk8ELNnNuJ kzZguBkOpCq1dt0iTPlCv2JYerLvqlr5EhWB8Ifly1vW1EznulwQIY/OktGpSWIOzhcW SiP1doUHK/wVBmGq9Tdj9yUydgNjf/SC5Ux3qmoCzDECcHi+QK3fAEXGLSF+irBQOIMj X6zLzt/8eSoGTgb5KWOxwxPMD+WzWHLgdSrAblEFe+El1lTz+u3KWEjw6+tmt+MFUMaa e6f/HRLm11mx1s/9LxaXvV/heFYj5jHzmK+PDoMribRpqvjgR6fiJPtakkRtFjCvfmDd EQrg== X-Gm-Message-State: AHPjjUj0P+IYZAcRTkujo+0SHNLje7bWgGf0XFegfbdOHCSmLcMqxBQw 4ONeG3cdznjcikPp X-Google-Smtp-Source: ADKCNb5mCJ86JB8/eNfr1R7WSY9ZM+Bsxe9sJz431jv36Erz1cvLMZ47m0mt09ROCv6Z3E3wx5exHQ== X-Received: by 10.84.199.170 with SMTP id r39mr18027319pld.375.1505245800703; Tue, 12 Sep 2017 12:50:00 -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.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:50:00 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:06 -0700 Message-Id: <1505245749-3402-4-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.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 4/7] ofproto-dpif-xlate: Keep track of the last action 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 When Openflow clone is last action of an action list, it does not make sense for xlated actions to generate datapath clone action. This patch attemps to Keep track of last clone action, but not necessarily for every case. Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- include/openvswitch/ofp-actions.h | 7 ++ ofproto/ofproto-dpif-xlate.c | 214 +++++++++++++++++++++++--------------- 2 files changed, 140 insertions(+), 81 deletions(-) diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index ad8e1bec06ba..03c1d11dc9a2 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -216,6 +216,13 @@ ofpact_end(const struct ofpact *ofpacts, size_t ofpacts_len) return ALIGNED_CAST(struct ofpact *, (uint8_t *) ofpacts + ofpacts_len); } +static inline bool +ofpact_last(const struct ofpact *a, const struct ofpact *ofpacts, + size_t ofpact_len) +{ + return ofpact_next(a) == ofpact_end(ofpacts, ofpact_len); +} + static inline const struct ofpact * ofpact_find_type_flattened(const struct ofpact *a, enum ofpact_type type, const struct ofpact * const end) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 223313d4ecba..9e39a4ff7f49 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -507,11 +507,12 @@ static struct xlate_cfg *new_xcfg = NULL; 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 *); + 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 honor_table_miss, bool with_ct_orig, + bool is_last_action); 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); @@ -536,7 +537,8 @@ struct xlate_bond_recirc { }; static void compose_output_action(struct xlate_ctx *, ofp_port_t ofp_port, - const struct xlate_bond_recirc *xr); + const struct xlate_bond_recirc *xr, + bool is_last_action); static struct xbridge *xbridge_lookup(struct xlate_cfg *, const struct ofproto_dpif *); @@ -2218,7 +2220,8 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, memcpy(&old_vlans, &ctx->xin->flow.vlans, sizeof(old_vlans)); xvlan_put(&ctx->xin->flow, &out_xvlan); - compose_output_action(ctx, xport->ofp_port, use_recirc ? &xr : NULL); + compose_output_action(ctx, xport->ofp_port, use_recirc ? &xr : NULL, + false); memcpy(&ctx->xin->flow.vlans, &old_vlans, sizeof(old_vlans)); } @@ -3557,7 +3560,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); + false, true); if (!ctx->freezing) { xlate_action_set(ctx); } @@ -3572,7 +3575,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); + false, true); ctx->mirrors = old_mirrors2; ctx->base_flow = old_base_flow; ctx->odp_actions->size = old_size; @@ -3716,7 +3719,8 @@ terminate_native_tunnel(struct xlate_ctx *ctx, ofp_port_t ofp_port, static void compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, - const struct xlate_bond_recirc *xr, bool check_stp) + const struct xlate_bond_recirc *xr, bool check_stp, + bool is_last_action OVS_UNUSED) { const struct xport *xport = get_ofp_port(ctx->xbridge, ofp_port); struct flow_wildcards *wc = ctx->wc; @@ -3882,13 +3886,15 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, static void compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port, - const struct xlate_bond_recirc *xr) + const struct xlate_bond_recirc *xr, + bool is_last_action) { - compose_output_action__(ctx, ofp_port, xr, true); + compose_output_action__(ctx, ofp_port, xr, true, is_last_action); } static void -xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule, bool deepens) +xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule, + bool deepens, bool is_last_action) { struct rule_dpif *old_rule = ctx->rule; ovs_be64 old_cookie = ctx->rule_cookie; @@ -3904,7 +3910,8 @@ xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule, bool deepens) 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); + do_xlate_actions(actions->ofpacts, actions->ofpacts_len, ctx, + is_last_action); ctx->rule_cookie = old_cookie; ctx->rule = old_rule; ctx->depth -= deepens; @@ -3979,7 +3986,7 @@ 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 with_ct_orig, bool is_last_action) { /* Check if we need to recirculate before matching in a table. */ if (ctx->was_mpls) { @@ -4030,7 +4037,8 @@ 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); + xlate_recursively(ctx, rule, table_id <= old_table_id, + is_last_action); ctx->xin->trace = old_trace; } @@ -4057,7 +4065,8 @@ xlate_group_stats(struct xlate_ctx *ctx, struct group_dpif *group, } static void -xlate_group_bucket(struct xlate_ctx *ctx, struct ofputil_bucket *bucket) +xlate_group_bucket(struct xlate_ctx *ctx, struct ofputil_bucket *bucket, + bool is_last_action) { uint64_t action_list_stub[1024 / 8]; struct ofpbuf action_list = OFPBUF_STUB_INITIALIZER(action_list_stub); @@ -4068,7 +4077,7 @@ xlate_group_bucket(struct xlate_ctx *ctx, struct ofputil_bucket *bucket) ofpacts_execute_action_set(&action_list, &action_set); ctx->depth++; - do_xlate_actions(action_list.data, action_list.size, ctx); + do_xlate_actions(action_list.data, action_list.size, ctx, is_last_action); ctx->depth--; ofpbuf_uninit(&action_list); @@ -4106,23 +4115,26 @@ xlate_group_bucket(struct xlate_ctx *ctx, struct ofputil_bucket *bucket) } static void -xlate_all_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_all_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { struct ofputil_bucket *bucket; LIST_FOR_EACH (bucket, list_node, &group->up.buckets) { - xlate_group_bucket(ctx, bucket); + bool last = is_last_action && !bucket->list_node.next; + xlate_group_bucket(ctx, bucket, last); } xlate_group_stats(ctx, group, NULL); } static void -xlate_ff_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_ff_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { struct ofputil_bucket *bucket; bucket = group_first_live_bucket(ctx, group, 0); if (bucket) { - xlate_group_bucket(ctx, bucket); + xlate_group_bucket(ctx, bucket, is_last_action); xlate_group_stats(ctx, group, bucket); } else if (ctx->xin->xcache) { ofproto_group_unref(&group->up); @@ -4130,7 +4142,8 @@ xlate_ff_group(struct xlate_ctx *ctx, struct group_dpif *group) } static void -xlate_default_select_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_default_select_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { struct flow_wildcards *wc = ctx->wc; struct ofputil_bucket *bucket; @@ -4140,7 +4153,7 @@ xlate_default_select_group(struct xlate_ctx *ctx, struct group_dpif *group) flow_mask_hash_fields(&ctx->xin->flow, wc, NX_HASH_FIELDS_SYMMETRIC_L4); bucket = group_best_live_bucket(ctx, group, basis); if (bucket) { - xlate_group_bucket(ctx, bucket); + xlate_group_bucket(ctx, bucket, is_last_action); xlate_group_stats(ctx, group, bucket); } else if (ctx->xin->xcache) { ofproto_group_unref(&group->up); @@ -4148,7 +4161,8 @@ xlate_default_select_group(struct xlate_ctx *ctx, struct group_dpif *group) } static void -xlate_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { const struct field_array *fields = &group->up.props.fields; const uint8_t *mask_values = fields->values; @@ -4186,7 +4200,7 @@ xlate_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group) struct ofputil_bucket *bucket = group_best_live_bucket(ctx, group, basis); if (bucket) { - xlate_group_bucket(ctx, bucket); + xlate_group_bucket(ctx, bucket, is_last_action); xlate_group_stats(ctx, group, bucket); } else if (ctx->xin->xcache) { ofproto_group_unref(&group->up); @@ -4194,7 +4208,8 @@ xlate_hash_fields_select_group(struct xlate_ctx *ctx, struct group_dpif *group) } static void -xlate_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { struct ofputil_bucket *bucket; @@ -4218,7 +4233,7 @@ xlate_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group) ctx->wc->masks.dp_hash |= mask; bucket = group_best_live_bucket(ctx, group, basis); if (bucket) { - xlate_group_bucket(ctx, bucket); + xlate_group_bucket(ctx, bucket, is_last_action); xlate_group_stats(ctx, group, bucket); } } @@ -4226,7 +4241,8 @@ xlate_dp_hash_select_group(struct xlate_ctx *ctx, struct group_dpif *group) } static void -xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { const char *selection_method = group->up.props.selection_method; @@ -4238,11 +4254,11 @@ xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group) } if (selection_method[0] == '\0') { - xlate_default_select_group(ctx, group); + xlate_default_select_group(ctx, group, is_last_action); } else if (!strcasecmp("hash", selection_method)) { - xlate_hash_fields_select_group(ctx, group); + xlate_hash_fields_select_group(ctx, group, is_last_action); } else if (!strcasecmp("dp_hash", selection_method)) { - xlate_dp_hash_select_group(ctx, group); + xlate_dp_hash_select_group(ctx, group, is_last_action); } else { /* Parsing of groups should ensure this never happens */ OVS_NOT_REACHED(); @@ -4250,7 +4266,8 @@ xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group) } static void -xlate_group_action__(struct xlate_ctx *ctx, struct group_dpif *group) +xlate_group_action__(struct xlate_ctx *ctx, struct group_dpif *group, + bool is_last_action) { bool was_in_group = ctx->in_group; ctx->in_group = true; @@ -4258,13 +4275,13 @@ xlate_group_action__(struct xlate_ctx *ctx, struct group_dpif *group) switch (group->up.type) { case OFPGT11_ALL: case OFPGT11_INDIRECT: - xlate_all_group(ctx, group); + xlate_all_group(ctx, group, is_last_action); break; case OFPGT11_SELECT: - xlate_select_group(ctx, group); + xlate_select_group(ctx, group, is_last_action); break; case OFPGT11_FF: - xlate_ff_group(ctx, group); + xlate_ff_group(ctx, group, is_last_action); break; default: OVS_NOT_REACHED(); @@ -4274,7 +4291,8 @@ xlate_group_action__(struct xlate_ctx *ctx, struct group_dpif *group) } static bool -xlate_group_action(struct xlate_ctx *ctx, uint32_t group_id) +xlate_group_action(struct xlate_ctx *ctx, uint32_t group_id, + bool is_last_action) { if (xlate_resubmit_resource_check(ctx)) { struct group_dpif *group; @@ -4288,7 +4306,7 @@ xlate_group_action(struct xlate_ctx *ctx, uint32_t group_id) group_id); return true; } - xlate_group_action__(ctx, group); + xlate_group_action__(ctx, group, is_last_action); } return false; @@ -4296,7 +4314,8 @@ xlate_group_action(struct xlate_ctx *ctx, uint32_t group_id) static void xlate_ofpact_resubmit(struct xlate_ctx *ctx, - const struct ofpact_resubmit *resubmit) + const struct ofpact_resubmit *resubmit, + bool is_last_action) { ofp_port_t in_port; uint8_t table_id; @@ -4321,26 +4340,47 @@ 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); + honor_table_miss, resubmit->with_ct_orig, + is_last_action); } static void -flood_packets(struct xlate_ctx *ctx, bool all) +flood_packet_to_port(struct xlate_ctx *ctx, const struct xport *xport, + bool all, bool is_last_action) { - const struct xport *xport; + if (!xport) { + return; + } + + if (all) { + compose_output_action__(ctx, xport->ofp_port, NULL, false, + is_last_action); + } else { + compose_output_action(ctx, xport->ofp_port, NULL, is_last_action); + } +} + +static void +flood_packets(struct xlate_ctx *ctx, bool all, bool is_last_action) +{ + const struct xport *xport, *last = NULL; + /* Use 'last' the keep track of the last output port. */ HMAP_FOR_EACH (xport, ofp_node, &ctx->xbridge->xports) { if (xport->ofp_port == ctx->xin->flow.in_port.ofp_port) { continue; } - if (all) { - compose_output_action__(ctx, xport->ofp_port, NULL, false); - } else if (!(xport->config & OFPUTIL_PC_NO_FLOOD)) { - compose_output_action(ctx, xport->ofp_port, NULL); + if (all || !(xport->config & OFPUTIL_PC_NO_FLOOD)) { + /* 'last' is not the last port, send a packet out, and + * update 'last'. */ + flood_packet_to_port(ctx, last, all, false); + last = xport; } } + /* Send the packet to the 'last' port. */ + flood_packet_to_port(ctx, last, all, is_last_action); ctx->nf_output_iface = NF_OUT_FLOOD; } @@ -4834,7 +4874,8 @@ compose_dec_mpls_ttl_action(struct xlate_ctx *ctx) static void xlate_output_action(struct xlate_ctx *ctx, - ofp_port_t port, uint16_t max_len, bool may_packet_in) + ofp_port_t port, uint16_t max_len, bool may_packet_in, + bool is_last_action) { ofp_port_t prev_nf_output_iface = ctx->nf_output_iface; @@ -4842,20 +4883,21 @@ xlate_output_action(struct xlate_ctx *ctx, switch (port) { case OFPP_IN_PORT: - compose_output_action(ctx, ctx->xin->flow.in_port.ofp_port, NULL); + compose_output_action(ctx, ctx->xin->flow.in_port.ofp_port, NULL, + is_last_action); break; case OFPP_TABLE: xlate_table_action(ctx, ctx->xin->flow.in_port.ofp_port, - 0, may_packet_in, true, false); + 0, may_packet_in, true, false, is_last_action); break; case OFPP_NORMAL: xlate_normal(ctx); break; case OFPP_FLOOD: - flood_packets(ctx, false); + flood_packets(ctx, false, is_last_action); break; case OFPP_ALL: - flood_packets(ctx, true); + flood_packets(ctx, true, is_last_action); break; case OFPP_CONTROLLER: execute_controller_action(ctx, max_len, @@ -4870,7 +4912,7 @@ xlate_output_action(struct xlate_ctx *ctx, case OFPP_LOCAL: default: if (port != ctx->xin->flow.in_port.ofp_port) { - compose_output_action(ctx, port, NULL); + compose_output_action(ctx, port, NULL, is_last_action); } else { xlate_report(ctx, OFT_WARN, "skipping output to input port"); } @@ -4889,7 +4931,8 @@ xlate_output_action(struct xlate_ctx *ctx, static void xlate_output_reg_action(struct xlate_ctx *ctx, - const struct ofpact_output_reg *or) + const struct ofpact_output_reg *or, + bool is_last_action) { uint64_t port = mf_get_subfield(&or->src, &ctx->xin->flow); if (port <= UINT16_MAX) { @@ -4899,7 +4942,8 @@ xlate_output_reg_action(struct xlate_ctx *ctx, memset(&value, 0xff, sizeof value); mf_write_subfield_flow(&or->src, &value, &ctx->wc->masks); - xlate_output_action(ctx, u16_to_ofp(port), or->max_len, false); + xlate_output_action(ctx, u16_to_ofp(port), or->max_len, false, + is_last_action); } else { xlate_report(ctx, OFT_WARN, "output port %"PRIu64" is out of range", port); @@ -4908,7 +4952,8 @@ xlate_output_reg_action(struct xlate_ctx *ctx, static void xlate_output_trunc_action(struct xlate_ctx *ctx, - ofp_port_t port, uint32_t max_len) + ofp_port_t port, uint32_t max_len, + bool is_last_action) { bool support_trunc = ctx->xbridge->support.trunc; struct ovs_action_trunc *trunc; @@ -4945,7 +4990,7 @@ xlate_output_trunc_action(struct xlate_ctx *ctx, OVS_ACTION_ATTR_TRUNC, sizeof *trunc); trunc->max_len = max_len; - xlate_output_action(ctx, port, max_len, false); + xlate_output_action(ctx, port, max_len, false, is_last_action); if (!support_trunc) { ctx->xout->slow |= SLOW_ACTION; } @@ -4958,7 +5003,8 @@ xlate_output_trunc_action(struct xlate_ctx *ctx, static void xlate_enqueue_action(struct xlate_ctx *ctx, - const struct ofpact_enqueue *enqueue) + const struct ofpact_enqueue *enqueue, + bool is_last_action) { ofp_port_t ofp_port = enqueue->port; uint32_t queue_id = enqueue->queue; @@ -4969,7 +5015,7 @@ xlate_enqueue_action(struct xlate_ctx *ctx, error = dpif_queue_to_priority(ctx->xbridge->dpif, queue_id, &priority); if (error) { /* Fall back to ordinary output action. */ - xlate_output_action(ctx, enqueue->port, 0, false); + xlate_output_action(ctx, enqueue->port, 0, false, is_last_action); return; } @@ -4983,7 +5029,7 @@ xlate_enqueue_action(struct xlate_ctx *ctx, /* Add datapath actions. */ flow_priority = ctx->xin->flow.skb_priority; ctx->xin->flow.skb_priority = priority; - compose_output_action(ctx, ofp_port, NULL); + compose_output_action(ctx, ofp_port, NULL, is_last_action); ctx->xin->flow.skb_priority = flow_priority; /* Update NetFlow output port. */ @@ -5031,7 +5077,8 @@ slave_enabled_cb(ofp_port_t ofp_port, void *xbridge_) static void xlate_bundle_action(struct xlate_ctx *ctx, - const struct ofpact_bundle *bundle) + const struct ofpact_bundle *bundle, + bool is_last_action) { ofp_port_t port; @@ -5041,7 +5088,7 @@ xlate_bundle_action(struct xlate_ctx *ctx, nxm_reg_load(&bundle->dst, ofp_to_u16(port), &ctx->xin->flow, ctx->wc); xlate_report_subfield(ctx, &bundle->dst); } else { - xlate_output_action(ctx, port, 0, false); + xlate_output_action(ctx, port, 0, false, is_last_action); } } @@ -5335,7 +5382,7 @@ reversible_actions(const struct ofpact *ofpacts, size_t ofpacts_len) static void clone_xlate_actions(const struct ofpact *actions, size_t actions_len, - struct xlate_ctx *ctx) + struct xlate_ctx *ctx, bool is_last_action) { struct ofpbuf old_stack = ctx->stack; union mf_subvalue new_stack[1024 / sizeof(union mf_subvalue)]; @@ -5350,9 +5397,9 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, size_t offset, ac_offset; struct flow old_flow = ctx->xin->flow; - if (reversible_actions(actions, actions_len)) { + if (reversible_actions(actions, actions_len) || is_last_action) { old_flow = ctx->xin->flow; - do_xlate_actions(actions, actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx, is_last_action); if (ctx->freezing) { finish_freezing(ctx); } @@ -5373,7 +5420,7 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, if (ctx->xbridge->support.clone) { /* Use clone action */ /* Use clone action as datapath clone. */ offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE); - do_xlate_actions(actions, actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx, true); if (ctx->freezing) { finish_freezing(ctx); } @@ -5386,7 +5433,7 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_SAMPLE); ac_offset = nl_msg_start_nested(ctx->odp_actions, OVS_SAMPLE_ATTR_ACTIONS); - do_xlate_actions(actions, actions_len, ctx); + do_xlate_actions(actions, actions_len, ctx, true); if (ctx->freezing) { finish_freezing(ctx); } @@ -5425,11 +5472,12 @@ xlate_done: } static void -compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc) +compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc, + bool is_last_action) { size_t oc_actions_len = ofpact_nest_get_action_len(oc); - clone_xlate_actions(oc->actions, oc_actions_len, ctx); + clone_xlate_actions(oc->actions, oc_actions_len, ctx, is_last_action); } static void @@ -5511,7 +5559,7 @@ xlate_action_set(struct xlate_ctx *ctx) struct ovs_list *old_trace = ctx->xin->trace; ctx->xin->trace = xlate_report(ctx, OFT_TABLE, "--. Executing action set:"); - do_xlate_actions(action_list.data, action_list.size, ctx); + do_xlate_actions(action_list.data, action_list.size, ctx, true); ctx->xin->trace = old_trace; ctx->in_action_set = false; @@ -5735,7 +5783,8 @@ put_ct_nat(struct xlate_ctx *ctx) } static void -compose_conntrack_action(struct xlate_ctx *ctx, struct ofpact_conntrack *ofc) +compose_conntrack_action(struct xlate_ctx *ctx, struct ofpact_conntrack *ofc, + bool is_last_action) { ovs_u128 old_ct_label_mask = ctx->wc->masks.ct_label; uint32_t old_ct_mark_mask = ctx->wc->masks.ct_mark; @@ -5750,7 +5799,8 @@ compose_conntrack_action(struct xlate_ctx *ctx, struct ofpact_conntrack *ofc) ctx->ct_nat_action = NULL; ctx->wc->masks.ct_mark = 0; ctx->wc->masks.ct_label = OVS_U128_ZERO; - do_xlate_actions(ofc->actions, ofpact_ct_get_action_len(ofc), ctx); + do_xlate_actions(ofc->actions, ofpact_ct_get_action_len(ofc), ctx, + is_last_action); if (ofc->zone_src.field) { zone = mf_get_subfield(&ofc->zone_src, &ctx->xin->flow); @@ -6146,7 +6196,7 @@ xlate_ofpact_unroll_xlate(struct xlate_ctx *ctx, static void do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, - struct xlate_ctx *ctx) + struct xlate_ctx *ctx, bool is_last_action) { struct flow_wildcards *wc = ctx->wc; struct flow *flow = &ctx->xin->flow; @@ -6167,6 +6217,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, const struct ofpact_metadata *metadata; const struct ofpact_set_field *set_field; const struct mf_field *mf; + bool last = is_last_action && ofpact_last(a, ofpacts, ofpacts_len) + && ctx->action_set.size; if (ctx->error) { break; @@ -6194,11 +6246,11 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, switch (a->type) { case OFPACT_OUTPUT: xlate_output_action(ctx, ofpact_get_OUTPUT(a)->port, - ofpact_get_OUTPUT(a)->max_len, true); + ofpact_get_OUTPUT(a)->max_len, true, last); break; case OFPACT_GROUP: - if (xlate_group_action(ctx, ofpact_get_GROUP(a)->group_id)) { + if (xlate_group_action(ctx, ofpact_get_GROUP(a)->group_id, last)) { /* Group could not be found. */ /* XXX: Terminates action list translation, but does not @@ -6227,7 +6279,7 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, case OFPACT_ENQUEUE: memset(&wc->masks.skb_priority, 0xff, sizeof wc->masks.skb_priority); - xlate_enqueue_action(ctx, ofpact_get_ENQUEUE(a)); + xlate_enqueue_action(ctx, ofpact_get_ENQUEUE(a), last); break; case OFPACT_SET_VLAN_VID: @@ -6339,7 +6391,7 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, * to avoid that, only adding any actions that follow the resubmit * to the frozen actions. */ - xlate_ofpact_resubmit(ctx, ofpact_get_RESUBMIT(a)); + xlate_ofpact_resubmit(ctx, ofpact_get_RESUBMIT(a), last); continue; case OFPACT_SET_TUNNEL: @@ -6437,16 +6489,16 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, break; case OFPACT_BUNDLE: - xlate_bundle_action(ctx, ofpact_get_BUNDLE(a)); + xlate_bundle_action(ctx, ofpact_get_BUNDLE(a), last); break; case OFPACT_OUTPUT_REG: - xlate_output_reg_action(ctx, ofpact_get_OUTPUT_REG(a)); + xlate_output_reg_action(ctx, ofpact_get_OUTPUT_REG(a), last); break; case OFPACT_OUTPUT_TRUNC: xlate_output_trunc_action(ctx, ofpact_get_OUTPUT_TRUNC(a)->port, - ofpact_get_OUTPUT_TRUNC(a)->max_len); + ofpact_get_OUTPUT_TRUNC(a)->max_len, last); break; case OFPACT_LEARN: @@ -6502,7 +6554,7 @@ 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); + ogt->table_id, true, true, false, last); break; } @@ -6511,7 +6563,7 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, break; case OFPACT_CLONE: - compose_clone(ctx, ofpact_get_CLONE(a)); + compose_clone(ctx, ofpact_get_CLONE(a), last); break; case OFPACT_ENCAP: @@ -6531,7 +6583,7 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, } case OFPACT_CT: - compose_conntrack_action(ctx, ofpact_get_CT(a)); + compose_conntrack_action(ctx, ofpact_get_CT(a), last); break; case OFPACT_CT_CLEAR: @@ -7099,7 +7151,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) } mirror_ingress_packet(&ctx); - do_xlate_actions(ofpacts, ofpacts_len, &ctx); + do_xlate_actions(ofpacts, ofpacts_len, &ctx, true); if (ctx.error) { goto exit; } @@ -7127,7 +7179,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) && xbridge->has_in_band && in_band_must_output_to_local_port(flow) && !actions_output_to_local_port(&ctx)) { - compose_output_action(&ctx, OFPP_LOCAL, NULL); + compose_output_action(&ctx, OFPP_LOCAL, NULL, false); } if (user_cookie_offset) { 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; } From patchwork Tue Sep 12 19:49:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813034 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 3xsFnw435cz9s7M for ; Wed, 13 Sep 2017 05:52:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 27631AD2; Tue, 12 Sep 2017 19:50:07 +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 81573A86 for ; Tue, 12 Sep 2017 19:50:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3DCAC159 for ; Tue, 12 Sep 2017 19:50:03 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id e69so4820705pfg.4 for ; Tue, 12 Sep 2017 12:50:03 -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=GvBrcK5q5TDVueqKlxng51raGAlBCRhJsiTkwcEzsAw=; b=MQ9SYkT2U1q93HD/7Ak++eqsOK0FpbjXPKWFmH+tjXd++ea5BSN6ZOxvbgxISvXV5k YLgDp3snfj7cknb5oFlYb0a/ahveJ7UHafiy0RukhpdYDdFpyJkYEMO9wL6iVkbE5JhO WiMpDNyDo1o6hdoyJe/E9Ufzn2H1iHVbscBiEDPyQ8qsNEXxDvXkd1B2TKvBoDJMMVWz kfQYN9csSXv0sdO4SrrNrg4sr747vRpq76zGXB8YL5kNWbmEtW9xwwVRQMaenJ70DPq7 WJHMj4kwE6aMTYU4cmKK1Cjp/koaaPU/vC/XEYA1k6gyZE5eGtkhkAT7gJxcR/hlEr0W 8Zaw== X-Gm-Message-State: AHPjjUiIz1AdB8cIwFkY9u94+UdsFxbrpemGv+EJj3HylMvhP6QhsvrF 8WJhmbYTu/QT02V+ X-Google-Smtp-Source: ADKCNb64AjH4I5KOOUJH7kmrN6R3ukK4dnW3DMO09juMrnB0vlvjxpCUUOEK00/qPZTgODU6PnhFxQ== X-Received: by 10.84.128.78 with SMTP id 72mr18708951pla.376.1505245802716; Tue, 12 Sep 2017 12:50:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:50:02 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:08 -0700 Message-Id: <1505245749-3402-6-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 6/7] ofproto-dpif-xlate: Rename apply_nested_clone_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 To patch_port_output(). The original function name does not make much sense. Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 81853c29afbf..94aa071a37cd 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -432,8 +432,8 @@ static void xlate_action_set(struct xlate_ctx *ctx); static void xlate_commit_actions(struct xlate_ctx *ctx); static void -apply_nested_clone_actions(struct xlate_ctx *ctx, const struct xport *in_dev, - struct xport *out_dev); +patch_port_output(struct xlate_ctx *ctx, const struct xport *in_dev, + struct xport *out_dev); static void ctx_trigger_freeze(struct xlate_ctx *ctx) @@ -3317,7 +3317,7 @@ validate_and_combine_post_tnl_actions(struct xlate_ctx *ctx, entry->tunnel_hdr.hdr_size = tnl_push_data.header_len; entry->tunnel_hdr.operation = ADD; - apply_nested_clone_actions(ctx, xport, out_dev); + patch_port_output(ctx, xport, out_dev); nested_act_flag = is_tunnel_actions_clone_ready(ctx); if (nested_act_flag) { @@ -3509,21 +3509,22 @@ xlate_flow_is_protected(const struct xlate_ctx *ctx, const struct flow *flow, co xport_in->xbundle->protected && xport_out->xbundle->protected); } -/* Function to combine actions from following device/port with the current - * device actions in openflow pipeline. Mainly used for the translation of - * patch/tunnel port output actions. It pushes the openflow state into a stack - * first, clear out to execute the packet through the device and finally pop - * the openflow state back from the stack. This is equivalent to cloning - * a packet in translation for the duration of execution. +/* Function handles when a packet is sent from one bridge to another bridge. * - * On output to a patch port, the output action will be replaced with set of - * nested actions on the peer patch port. - * Similarly on output to a tunnel port, the post nested actions on - * tunnel are chained up with the tunnel-push action. + * The bridges are internally connected, either with patch ports or with + * tunnel ports. + * + * The output action to another bridge causes translation to continue within + * the next bridge. This process can be recursive; the next bridge can + * output yet to another bridge. + * + * The translated actions from the second bridge onwards are enclosed within + * the clone action, so that any modification to the packet will not be visible + * to the remaining actions of the originating bridge. */ static void -apply_nested_clone_actions(struct xlate_ctx *ctx, const struct xport *in_dev, - struct xport *out_dev) +patch_port_output(struct xlate_ctx *ctx, const struct xport *in_dev, + struct xport *out_dev) { struct flow *flow = &ctx->xin->flow; struct flow old_flow = ctx->xin->flow; @@ -3760,7 +3761,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, } if (xport->peer) { - apply_nested_clone_actions(ctx, xport, xport->peer); + patch_port_output(ctx, xport, xport->peer); return; } From patchwork Tue Sep 12 19:49:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813035 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 3xsFpd5Lmyz9sNV for ; Wed, 13 Sep 2017 05:53:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 66659AE0; Tue, 12 Sep 2017 19:50:09 +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 470D2AEF for ; Tue, 12 Sep 2017 19:50:05 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8347F421 for ; Tue, 12 Sep 2017 19:50:04 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id i130so4623526pgc.0 for ; Tue, 12 Sep 2017 12:50:04 -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=WQL+BTB/PBcLqav8gM5xCCoDX4Ns06LPeVsgil6MwKI=; b=seDEoHDvKpIFCh1tAe/wvirsGoJ6tcp8+rvcVijF09lTMWN2VyREIOXYawGhengD+7 orLNvufX61Zgpa0zr79Q5+OMGDHorQz6exvYh+BJdiV8JCXdktHBzeJ3GzhUFGnt4EJZ CUYdCpSF2VHrSgxTEksGm5N+Rzz3PHHAePrnp2djNvHXpzTm0vHAV4Gj6jfFC6Uc8G6+ tq/x562Pe4r5FwuJN0g9IltXFbWc8n/hmzaCMCNgCMheZjbPyTgtMvUz8FV9+DQhVlMQ cEctNbYtQWkmDhmpimxPU+F10w6tc6R04RMac70f69Epqq6eTb5F8CXX1GE6Rh9BV50i uXDg== X-Gm-Message-State: AHPjjUgYW6zSkJhHbwZVBcOvLX9bZ6Ffw0rag3UkJARaSMLMc6mPvfwP IamvzCpZRSBUw33l X-Google-Smtp-Source: ADKCNb4TTI+IH/dLd3EHilWnHGxzoZGP9mmkZkBKdHxEPQZeyZIHAMArpXSeZPsk/nSk3HdCelmTSw== X-Received: by 10.99.113.88 with SMTP id b24mr16081002pgn.309.1505245803665; Tue, 12 Sep 2017 12:50:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 12:50:03 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Tue, 12 Sep 2017 12:49:09 -0700 Message-Id: <1505245749-3402-7-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.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 7/7] ofproto-dpif-xlate: Refactor native tunnel handling logic 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 Merge native tunnel handling with patch port handling as much as possible. Current native tunnel handling logic inspects the generated actions to determine if truncate has been applied to the packet. (since if it is then recirculation should be used). This logic can be simplified by passing the 'truncate' boolean argument into compose_output_action(). Signed-off-by: Andy Zhou Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-xlate.c | 243 +++++++++++++++++-------------------------- 1 file changed, 95 insertions(+), 148 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 94aa071a37cd..d320d570b304 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -544,7 +544,7 @@ struct xlate_bond_recirc { static void compose_output_action(struct xlate_ctx *, ofp_port_t ofp_port, const struct xlate_bond_recirc *xr, - bool is_last_action); + bool is_last_action, bool truncate); static struct xbridge *xbridge_lookup(struct xlate_cfg *, const struct ofproto_dpif *); @@ -2227,7 +2227,7 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, xvlan_put(&ctx->xin->flow, &out_xvlan); compose_output_action(ctx, xport->ofp_port, use_recirc ? &xr : NULL, - false); + false, false); memcpy(&ctx->xin->flow.vlans, &old_vlans, sizeof(old_vlans)); } @@ -3241,130 +3241,10 @@ propagate_tunnel_data_to_flow(struct xlate_ctx *ctx, struct eth_addr dmac, is_tnl_ipv6, nw_proto); } -/* Validate if the transalated combined actions are OK to proceed. - * If actions consist of TRUNC action, it is not allowed to do the - * tunnel_push combine as it cannot update stats correctly. - */ -static bool -is_tunnel_actions_clone_ready(struct xlate_ctx *ctx) -{ - struct nlattr *tnl_actions; - const struct nlattr *a; - unsigned int left; - size_t actions_len; - struct ofpbuf *actions = ctx->odp_actions; - - if (!actions) { - /* No actions, no harm in doing combine. */ - return true; - } - - /* Cannot perform tunnel push on slow path action CONTROLLER_OUTPUT. */ - if (ctx->xout->slow & SLOW_CONTROLLER) { - return false; - } - actions_len = actions->size; - - tnl_actions =(struct nlattr *)(actions->data); - NL_ATTR_FOR_EACH_UNSAFE (a, left, tnl_actions, actions_len) { - int type = nl_attr_type(a); - if (type == OVS_ACTION_ATTR_TRUNC) { - VLOG_DBG("Cannot do tunnel action-combine on trunc action"); - return false; - break; - } - } - return true; -} - -static bool -validate_and_combine_post_tnl_actions(struct xlate_ctx *ctx, - const struct xport *xport, - struct xport *out_dev, - struct ovs_action_push_tnl tnl_push_data) -{ - const struct dpif_flow_stats *backup_resubmit_stats; - struct xlate_cache *backup_xcache; - bool nested_act_flag = false; - struct flow_wildcards tmp_flow_wc; - struct flow_wildcards *backup_flow_wc_ptr; - bool backup_side_effects; - const struct dp_packet *backup_pkt; - - memset(&tmp_flow_wc, 0 , sizeof tmp_flow_wc); - backup_flow_wc_ptr = ctx->wc; - ctx->wc = &tmp_flow_wc; - ctx->xin->wc = NULL; - backup_resubmit_stats = ctx->xin->resubmit_stats; - backup_xcache = ctx->xin->xcache; - backup_side_effects = ctx->xin->allow_side_effects; - backup_pkt = ctx->xin->packet; - - size_t push_action_size = 0; - size_t clone_ofs = nl_msg_start_nested(ctx->odp_actions, - OVS_ACTION_ATTR_CLONE); - odp_put_tnl_push_action(ctx->odp_actions, &tnl_push_data); - push_action_size = ctx->odp_actions->size; - - ctx->xin->resubmit_stats = NULL; - ctx->xin->xcache = xlate_cache_new(); /* Use new temporary cache. */ - ctx->xin->allow_side_effects = false; - ctx->xin->packet = NULL; - - /* Push the cache entry for the tunnel first. */ - struct xc_entry *entry; - entry = xlate_cache_add_entry(ctx->xin->xcache, XC_TUNNEL_HEADER); - entry->tunnel_hdr.hdr_size = tnl_push_data.header_len; - entry->tunnel_hdr.operation = ADD; - - patch_port_output(ctx, xport, out_dev); - nested_act_flag = is_tunnel_actions_clone_ready(ctx); - - if (nested_act_flag) { - /* Similar to the stats update in revalidation, the x_cache entries - * are populated by the previous translation are used to update the - * stats correctly. - */ - if (backup_resubmit_stats) { - struct dpif_flow_stats tmp_resubmit_stats; - memcpy(&tmp_resubmit_stats, backup_resubmit_stats, - sizeof tmp_resubmit_stats); - xlate_push_stats(ctx->xin->xcache, &tmp_resubmit_stats); - } - xlate_cache_steal_entries(backup_xcache, ctx->xin->xcache); - } else { - /* Combine is not valid. */ - nl_msg_cancel_nested(ctx->odp_actions, clone_ofs); - goto out; - } - if (ctx->odp_actions->size > push_action_size) { - /* Update the CLONE action only when combined. */ - nl_msg_end_nested(ctx->odp_actions, clone_ofs); - } else { - nl_msg_cancel_nested(ctx->odp_actions, clone_ofs); - /* XXX : There is no real use-case for a tunnel push without - * any post actions. However keeping it now - * as is to make the 'make check' happy. Should remove when all the - * make check tunnel test case does something meaningful on a - * tunnel encap packets. - */ - odp_put_tnl_push_action(ctx->odp_actions, &tnl_push_data); - } - -out: - /* Restore context status. */ - ctx->xin->resubmit_stats = backup_resubmit_stats; - xlate_cache_delete(ctx->xin->xcache); - ctx->xin->xcache = backup_xcache; - ctx->xin->allow_side_effects = backup_side_effects; - ctx->xin->packet = backup_pkt; - ctx->wc = backup_flow_wc_ptr; - return nested_act_flag; -} - static int -build_tunnel_send(struct xlate_ctx *ctx, const struct xport *xport, - const struct flow *flow, odp_port_t tunnel_odp_port) +native_tunnel_output(struct xlate_ctx *ctx, const struct xport *xport, + const struct flow *flow, odp_port_t tunnel_odp_port, + bool truncate) { struct netdev_tnl_build_header_params tnl_params; struct ovs_action_push_tnl tnl_push_data; @@ -3449,24 +3329,83 @@ build_tunnel_send(struct xlate_ctx *ctx, const struct xport *xport, * base_flow need to be set properly, since there is not recirculation * any more when sending packet to tunnel. */ - propagate_tunnel_data_to_flow(ctx, dmac, smac, s_ip6, s_ip, - tnl_params.is_ipv6, tnl_push_data.tnl_type); + propagate_tunnel_data_to_flow(ctx, dmac, smac, s_ip6, + s_ip, tnl_params.is_ipv6, + tnl_push_data.tnl_type); + size_t clone_ofs = 0; + size_t push_action_size; - /* Try to see if its possible to apply nested clone actions on tunnel. - * Revert the combined actions on tunnel if its not valid. - */ - if (!validate_and_combine_post_tnl_actions(ctx, xport, out_dev, - tnl_push_data)) { - /* Datapath is not doing the recirculation now, so lets make it - * happen explicitly. + clone_ofs = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE); + odp_put_tnl_push_action(ctx->odp_actions, &tnl_push_data); + push_action_size = ctx->odp_actions->size; + + if (!truncate) { + const struct dpif_flow_stats *backup_resubmit_stats; + struct xlate_cache *backup_xcache; + struct flow_wildcards *backup_wc, wc; + bool backup_side_effects; + const struct dp_packet *backup_packet; + + memset(&wc, 0 , sizeof wc); + backup_wc = ctx->wc; + ctx->wc = &wc; + ctx->xin->wc = NULL; + backup_resubmit_stats = ctx->xin->resubmit_stats; + backup_xcache = ctx->xin->xcache; + backup_side_effects = ctx->xin->allow_side_effects; + backup_packet = ctx->xin->packet; + + ctx->xin->resubmit_stats = NULL; + ctx->xin->xcache = xlate_cache_new(); /* Use new temporary cache. */ + ctx->xin->allow_side_effects = false; + ctx->xin->packet = NULL; + + /* Push the cache entry for the tunnel first. */ + struct xc_entry *entry; + entry = xlate_cache_add_entry(ctx->xin->xcache, XC_TUNNEL_HEADER); + entry->tunnel_hdr.hdr_size = tnl_push_data.header_len; + entry->tunnel_hdr.operation = ADD; + + patch_port_output(ctx, xport, out_dev); + + /* Similar to the stats update in revalidation, the x_cache entries + * are populated by the previous translation are used to update the + * stats correctly. */ - size_t clone_ofs = nl_msg_start_nested(ctx->odp_actions, - OVS_ACTION_ATTR_CLONE); - odp_put_tnl_push_action(ctx->odp_actions, &tnl_push_data); + if (backup_resubmit_stats) { + struct dpif_flow_stats stats = *backup_resubmit_stats; + xlate_push_stats(ctx->xin->xcache, &stats); + } + xlate_cache_steal_entries(backup_xcache, ctx->xin->xcache); + + if (ctx->odp_actions->size > push_action_size) { + nl_msg_end_non_empty_nested(ctx->odp_actions, clone_ofs); + } else { + nl_msg_cancel_nested(ctx->odp_actions, clone_ofs); + /* XXX : There is no real use-case for a tunnel push without + * any post actions. However keeping it now + * as is to make the 'make check' happy. Should remove when all the + * make check tunnel test case does something meaningful on a + * tunnel encap packets. + */ + odp_put_tnl_push_action(ctx->odp_actions, &tnl_push_data); + } + + /* Restore context status. */ + ctx->xin->resubmit_stats = backup_resubmit_stats; + xlate_cache_delete(ctx->xin->xcache); + ctx->xin->xcache = backup_xcache; + ctx->xin->allow_side_effects = backup_side_effects; + ctx->xin->packet = backup_packet; + ctx->wc = backup_wc; + } else { + /* In order to maintain accurate stats, use recirc for + * natvie tunneling. */ nl_msg_put_u32(ctx->odp_actions, OVS_ACTION_ATTR_RECIRC, 0); nl_msg_end_nested(ctx->odp_actions, clone_ofs); } + /* Restore the flows after the translation. */ memcpy(&ctx->xin->flow, &old_flow, sizeof ctx->xin->flow); memcpy(&ctx->base_flow, &old_base_flow, sizeof ctx->base_flow); @@ -3727,7 +3666,7 @@ terminate_native_tunnel(struct xlate_ctx *ctx, ofp_port_t ofp_port, static void compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, const struct xlate_bond_recirc *xr, bool check_stp, - bool is_last_action OVS_UNUSED) + bool is_last_action OVS_UNUSED, bool truncate) { const struct xport *xport = get_ofp_port(ctx->xbridge, ofp_port); struct flow_wildcards *wc = ctx->wc; @@ -3761,6 +3700,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, } if (xport->peer) { + ovs_assert(!truncate) patch_port_output(ctx, xport, xport->peer); return; } @@ -3837,7 +3777,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, xr->recirc_id); } else if (is_native_tunnel) { /* Output to native tunnel port. */ - build_tunnel_send(ctx, xport, flow, odp_port); + native_tunnel_output(ctx, xport, flow, odp_port, truncate); flow->tunnel = flow_tnl; /* Restore tunnel metadata */ } else if (terminate_native_tunnel(ctx, ofp_port, flow, wc, @@ -3894,9 +3834,10 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port, static void compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port, const struct xlate_bond_recirc *xr, - bool is_last_action) + bool is_last_action, bool truncate) { - compose_output_action__(ctx, ofp_port, xr, true, is_last_action); + compose_output_action__(ctx, ofp_port, xr, true, + is_last_action, truncate); } static void @@ -4363,9 +4304,10 @@ flood_packet_to_port(struct xlate_ctx *ctx, const struct xport *xport, if (all) { compose_output_action__(ctx, xport->ofp_port, NULL, false, - is_last_action); + is_last_action, false); } else { - compose_output_action(ctx, xport->ofp_port, NULL, is_last_action); + compose_output_action(ctx, xport->ofp_port, NULL, is_last_action, + false); } } @@ -4887,26 +4829,31 @@ xlate_output_action(struct xlate_ctx *ctx, bool is_last_action) { ofp_port_t prev_nf_output_iface = ctx->nf_output_iface; + bool truncate = max_len != 0; ctx->nf_output_iface = NF_OUT_DROP; switch (port) { case OFPP_IN_PORT: compose_output_action(ctx, ctx->xin->flow.in_port.ofp_port, NULL, - is_last_action); + is_last_action, truncate); break; case OFPP_TABLE: + ovs_assert(!truncate); 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, false, do_xlate_actions); break; case OFPP_NORMAL: + ovs_assert(!truncate); xlate_normal(ctx); break; case OFPP_FLOOD: + ovs_assert(!truncate); flood_packets(ctx, false, is_last_action); break; case OFPP_ALL: + ovs_assert(!truncate); flood_packets(ctx, true, is_last_action); break; case OFPP_CONTROLLER: @@ -4922,7 +4869,7 @@ xlate_output_action(struct xlate_ctx *ctx, case OFPP_LOCAL: default: if (port != ctx->xin->flow.in_port.ofp_port) { - compose_output_action(ctx, port, NULL, is_last_action); + compose_output_action(ctx, port, NULL, is_last_action, truncate); } else { xlate_report(ctx, OFT_WARN, "skipping output to input port"); } @@ -5039,7 +4986,7 @@ xlate_enqueue_action(struct xlate_ctx *ctx, /* Add datapath actions. */ flow_priority = ctx->xin->flow.skb_priority; ctx->xin->flow.skb_priority = priority; - compose_output_action(ctx, ofp_port, NULL, is_last_action); + compose_output_action(ctx, ofp_port, NULL, is_last_action, false); ctx->xin->flow.skb_priority = flow_priority; /* Update NetFlow output port. */ @@ -7190,7 +7137,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) && xbridge->has_in_band && in_band_must_output_to_local_port(flow) && !actions_output_to_local_port(&ctx)) { - compose_output_action(&ctx, OFPP_LOCAL, NULL, false); + compose_output_action(&ctx, OFPP_LOCAL, NULL, false, false); } if (user_cookie_offset) {