From patchwork Wed Jan 10 22:27:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 858595 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 3zH3d23rPbz9sNw for ; Thu, 11 Jan 2018 09:31:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DC2DC103F; Wed, 10 Jan 2018 22:28:23 +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 2CCC1100D for ; Wed, 10 Jan 2018 22:28:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7C90AE3 for ; Wed, 10 Jan 2018 22:28:19 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id EB446C5A51 for ; Wed, 10 Jan 2018 23:28:17 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 10 Jan 2018 14:27:23 -0800 Message-Id: <1515623246-3820-5-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515623246-3820-1-git-send-email-jpettit@ovn.org> References: <1515623246-3820-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [no-slow v2 5/8] ofp-actions: Add action "debug_slow" for testing slow-path. 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 It isn't otherwise useful and in fact hurts performance so it's disabled without --enable-dummy. An upcoming commit will make use of this. Signed-off-by: Justin Pettit Acked-by: Ben Pfaff --- v1->v2: Unchanged. --- include/openvswitch/ofp-actions.h | 1 + lib/ofp-actions.c | 48 ++++++++++++++++++++++++++++++++++++++- ofproto/ofproto-dpif-xlate.c | 7 ++++++ tests/ofproto-dpif.at | 19 ++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/include/openvswitch/ofp-actions.h b/include/openvswitch/ofp-actions.h index 3d9775582f6d..a7808eb4fa60 100644 --- a/include/openvswitch/ofp-actions.h +++ b/include/openvswitch/ofp-actions.h @@ -128,6 +128,7 @@ struct vl_mff_map; * These are intentionally undocumented, subject to change, and \ * only accepted if ovs-vswitchd is started with --enable-dummy. */ \ OFPACT(DEBUG_RECIRC, ofpact_null, ofpact, "debug_recirc") \ + OFPACT(DEBUG_SLOW, ofpact_null, ofpact, "debug_slow") \ \ /* Instructions. */ \ OFPACT(METER, ofpact_meter, ofpact, "meter") \ diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 4918498efb30..1d364f98bbd1 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -357,6 +357,9 @@ enum ofp_raw_action_type { /* These are intentionally undocumented, subject to change, and ovs-vswitchd */ /* accepts them only if started with --enable-dummy. */ + /* NX1.0+(254): void. */ + NXAST_RAW_DEBUG_SLOW, + /* NX1.0+(255): void. */ NXAST_RAW_DEBUG_RECIRC, }; @@ -475,6 +478,7 @@ ofpact_next_flattened(const struct ofpact *ofpact) case OFPACT_UNROLL_XLATE: case OFPACT_CT_CLEAR: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_METER: case OFPACT_CLEAR_ACTIONS: case OFPACT_WRITE_METADATA: @@ -5802,7 +5806,7 @@ format_SAMPLE(const struct ofpact_sample *a, ds_put_format(s, "%s)%s", colors.paren, colors.end); } -/* debug_recirc instruction. */ +/* debug instructions. */ static bool enable_debug; @@ -5849,6 +5853,43 @@ format_DEBUG_RECIRC(const struct ofpact_null *a OVS_UNUSED, ds_put_format(s, "%sdebug_recirc%s", colors.value, colors.end); } +static enum ofperr +decode_NXAST_RAW_DEBUG_SLOW(struct ofpbuf *out) +{ + if (!enable_debug) { + return OFPERR_OFPBAC_BAD_VENDOR_TYPE; + } + + ofpact_put_DEBUG_SLOW(out); + return 0; +} + +static void +encode_DEBUG_SLOW(const struct ofpact_null *n OVS_UNUSED, + enum ofp_version ofp_version OVS_UNUSED, + struct ofpbuf *out) +{ + put_NXAST_DEBUG_SLOW(out); +} + +static char * OVS_WARN_UNUSED_RESULT +parse_DEBUG_SLOW(char *arg OVS_UNUSED, + const struct ofputil_port_map *port_map OVS_UNUSED, + struct ofpbuf *ofpacts, + enum ofputil_protocol *usable_protocols OVS_UNUSED) +{ + ofpact_put_DEBUG_SLOW(ofpacts); + return NULL; +} + +static void +format_DEBUG_SLOW(const struct ofpact_null *a OVS_UNUSED, + const struct ofputil_port_map *port_map OVS_UNUSED, + struct ds *s) +{ + ds_put_format(s, "%sdebug_slow%s", colors.value, colors.end); +} + /* Action structure for NXAST_CT. * * Pass traffic to the connection tracker. @@ -7151,6 +7192,7 @@ ofpact_is_set_or_move_action(const struct ofpact *a) case OFPACT_WRITE_ACTIONS: case OFPACT_WRITE_METADATA: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: return false; default: OVS_NOT_REACHED(); @@ -7219,6 +7261,7 @@ ofpact_is_allowed_in_actions_set(const struct ofpact *a) case OFPACT_STACK_POP: case OFPACT_STACK_PUSH: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: /* The action set may only include actions and thus * may not include any instructions */ @@ -7441,6 +7484,7 @@ ovs_instruction_type_from_ofpact_type(enum ofpact_type type) case OFPACT_UNROLL_XLATE: case OFPACT_SAMPLE: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_CT: case OFPACT_CT_CLEAR: case OFPACT_NAT: @@ -8107,6 +8151,7 @@ ofpact_check__(enum ofputil_protocol *usable_protocols, struct ofpact *a, return OFPERR_OFPBAC_BAD_TYPE; case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: return 0; case OFPACT_ENCAP: @@ -8622,6 +8667,7 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, ofp_port_t port) case OFPACT_METER: case OFPACT_GROUP: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_CT: case OFPACT_CT_CLEAR: case OFPACT_NAT: diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 804b8b88681a..63d15e94331f 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -5302,6 +5302,7 @@ reversible_actions(const struct ofpact *ofpacts, size_t ofpacts_len) case OFPACT_CONTROLLER: case OFPACT_CT_CLEAR: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_DEC_MPLS_TTL: case OFPACT_DEC_TTL: case OFPACT_ENQUEUE: @@ -5635,6 +5636,7 @@ freeze_unroll_actions(const struct ofpact *a, const struct ofpact *end, case OFPACT_ENCAP: case OFPACT_DECAP: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_CT: case OFPACT_CT_CLEAR: case OFPACT_NAT: @@ -6130,6 +6132,7 @@ recirc_for_mpls(const struct ofpact *a, struct xlate_ctx *ctx) case OFPACT_CT_CLEAR: case OFPACT_NAT: case OFPACT_DEBUG_RECIRC: + case OFPACT_DEBUG_SLOW: case OFPACT_METER: case OFPACT_CLEAR_ACTIONS: case OFPACT_WRITE_ACTIONS: @@ -6578,6 +6581,10 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, ctx_trigger_freeze(ctx); a = ofpact_next(a); break; + + case OFPACT_DEBUG_SLOW: + ctx->xout->slow |= SLOW_ACTION; + break; } /* Check if need to store this and the remaining actions for later diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 9a51a1364157..d9dab9ba159a 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -4816,6 +4816,25 @@ AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: 2 OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([ofproto-dpif - debug_slow action]) +OVS_VSWITCHD_START +add_of_ports br0 1 2 3 + +AT_CHECK([ovs-ofctl add-flow br0 "in_port=1,actions=debug_slow,2"]) + +flow="in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)" + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow" -generate], [0], [stdout]) +AT_CHECK_UNQUOTED([tail -3 stdout], [0], [Datapath actions: 2 +This flow is handled by the userspace slow path because it: + - Uses action(s) not supported by datapath. +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + + dnl CHECK_CONTINUATION(TITLE, N_PORTS0, N_PORTS1, ACTIONS0, ACTIONS1, [EXTRA_SETUP]) dnl dnl Checks the implementation of the continuation mechanism that allows the