From patchwork Fri Oct 14 12:21:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1690022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i/0ZmUjM; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mplqj5tRJz23jc for ; Fri, 14 Oct 2022 23:21:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 973AE42233; Fri, 14 Oct 2022 12:21:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 973AE42233 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i/0ZmUjM X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oNsQULBhJH4A; Fri, 14 Oct 2022 12:21:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 46A844218F; Fri, 14 Oct 2022 12:21:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 46A844218F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 146E2C0032; Fri, 14 Oct 2022 12:21:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5EDBAC002D for ; Fri, 14 Oct 2022 12:21:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 46ABC41138 for ; Fri, 14 Oct 2022 12:21:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 46ABC41138 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i/0ZmUjM X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fpb8KkYhqq3N for ; Fri, 14 Oct 2022 12:21:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EDDDF402B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id EDDDF402B1 for ; Fri, 14 Oct 2022 12:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665750088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rDhvF0tRAHax7bmJCz5DfqDVbT1x1oW4wMh07HmVzQw=; b=i/0ZmUjMzlkM/jk2VvsPF67+xTCN8S3Se4XZmQVpYLw6Ij2Avz9P9KHSqKXRpipgLWN1LK sxpAbxHaaqXP5YVGNy4tL+UwAWb88sbWrsHHXx66k/TVJKU47p3luh7E96pyBRi/Kl4hgS S8XZ3touRt+twROJl0POqJpK9O3KpCw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-KwmQ4Le1NQCQdQwdFSreyg-1; Fri, 14 Oct 2022 08:21:27 -0400 X-MC-Unique: KwmQ4Le1NQCQdQwdFSreyg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7109887B2A4 for ; Fri, 14 Oct 2022 12:21:27 +0000 (UTC) Received: from amusil.redhat.com (ovpn-192-110.brq.redhat.com [10.40.192.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 791E9C15BB3; Fri, 14 Oct 2022 12:21:26 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 14 Oct 2022 14:21:24 +0200 Message-Id: <20221014122125.205013-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v6 1/2] ofproto-dpif-xlate: Extract the freezing processing into a function X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Through out the code there is the same pattern that occurs in regards to to finish_freezing when ctx->freezing=true or xlate_action_set when ctx->freezing=false. Extract it to common function that is called from those places instead. Signed-off-by: Ales Musil --- v6: Rebase on top of current master. Fix wrong if semantics. --- ofproto/ofproto-dpif-xlate.c | 53 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 3b9b26da1..6ea71eb52 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -3883,6 +3883,17 @@ xlate_flow_is_protected(const struct xlate_ctx *ctx, const struct flow *flow, co xport_in->xbundle->protected && xport_out->xbundle->protected); } +static void +xlate_ctx_process_freezing(struct xlate_ctx *ctx) +{ + if (!ctx->freezing) { + xlate_action_set(ctx); + } + if (ctx->freezing) { + finish_freezing(ctx); + } +} + /* Function handles when a packet is sent from one bridge to another bridge. * * The bridges are internally connected, either with patch ports or with @@ -3943,12 +3954,7 @@ patch_port_output(struct xlate_ctx *ctx, const struct xport *in_dev, xlate_table_action(ctx, flow->in_port.ofp_port, 0, true, true, false, is_last_action, clone_xlate_actions); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); } else { /* Forwarding is disabled by STP and RSTP. Let OFPP_NORMAL and * the learning action look at the packet, then drop it. */ @@ -5866,12 +5872,7 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, if (reversible_actions(actions, actions_len) || is_last_action) { old_flow = ctx->xin->flow; do_xlate_actions(actions, actions_len, ctx, is_last_action, false); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); goto xlate_done; } @@ -5890,12 +5891,7 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, /* 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, true, false); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); nl_msg_end_non_empty_nested(ctx->odp_actions, offset); goto dp_clone_done; } @@ -5906,12 +5902,7 @@ clone_xlate_actions(const struct ofpact *actions, size_t actions_len, ac_offset = nl_msg_start_nested(ctx->odp_actions, OVS_SAMPLE_ATTR_ACTIONS); do_xlate_actions(actions, actions_len, ctx, true, false); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); if (nl_msg_end_non_empty_nested(ctx->odp_actions, ac_offset)) { nl_msg_cancel_nested(ctx->odp_actions, offset); } else { @@ -6472,12 +6463,7 @@ xlate_check_pkt_larger(struct xlate_ctx *ctx, value.u8_val = 1; mf_write_subfield_flow(&check_pkt_larger->dst, &value, &ctx->xin->flow); do_xlate_actions(remaining_acts, remaining_acts_len, ctx, true, false); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); nl_msg_end_nested(ctx->odp_actions, offset_attr); ctx->base_flow = old_base; @@ -6497,12 +6483,7 @@ xlate_check_pkt_larger(struct xlate_ctx *ctx, value.u8_val = 0; mf_write_subfield_flow(&check_pkt_larger->dst, &value, &ctx->xin->flow); do_xlate_actions(remaining_acts, remaining_acts_len, ctx, true, false); - if (!ctx->freezing) { - xlate_action_set(ctx); - } - if (ctx->freezing) { - finish_freezing(ctx); - } + xlate_ctx_process_freezing(ctx); nl_msg_end_nested(ctx->odp_actions, offset_attr); nl_msg_end_nested(ctx->odp_actions, offset);