From patchwork Fri Feb 9 06:16:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 871570 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=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="k54qMQwV"; dkim-atps=neutral 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 3zdSmY6kzTz9s72 for ; Sat, 10 Feb 2018 08:26:21 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 79B298E2; Fri, 9 Feb 2018 21:26:17 +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 648B911BA for ; Fri, 9 Feb 2018 21:26:15 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 715252F6 for ; Fri, 9 Feb 2018 21:26:14 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id g2so4438493pgn.7 for ; Fri, 09 Feb 2018 13:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=J8pMyn8G/XGJLT+sGVAZDKFN7yhGCDO6H9/HCa0WGFU=; b=k54qMQwVo41pPAltM+Da3ie6mizObmMqsHacL33DCa4W/aRV61hEYDMTuMAAF4H9SW x1IJZVLAnY89oygS9DTCgYpKpy1ylnlO0UqhJ80b2p9zP81i3985mc2oDVPAbFPMAlHK A3cC5a/s0ZlkHeAg9OBBk82vfxX67P+myEcflh8C1W782VCPXY3sTGMKek0hWDjijZgH BI9TaSfAbXpAUFebp4R2fnHD9HS0DEuygWXQVOKk5TGcVmpgtXKIbnC6FmF+dzRb8oAc JLOMbma8KCFpclZN7EIPBpsFs914gaSLAkkXssujWWuOxKAMvXaRjMlNDKWZu5atAzLS HW+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=J8pMyn8G/XGJLT+sGVAZDKFN7yhGCDO6H9/HCa0WGFU=; b=huOhrZnd2OkYAstTfYofMPEU98L7P6qNsXaNzyUEDwnzWKjth36tGnyTbqMREJHcs9 iOOrFDUTlgb9cnLn1TtVrQbqQVZjBpDZG5SYnHd3QiyYc0gALb4kIBRcLdSOIULwilgm 7Fcz/vj7ceVW5l3r644xY933TyYmDjy8pL1v172BeCHs/bSe8Qp9fDxgTSiAMK9AM/ZB XR9KBfZHNrm4L7ALafBAlvGc3ekbTUmGp6Jd/l1qTW/wMolamNO1NTMoqzfb2emd4cho C7/b8wWI5Eei5zJbcqPvNd4Zd+z1YR2B6AzoWgo6fgpeW4tg7lOU8LvFstM8a/paezGk rT8Q== X-Gm-Message-State: APf1xPCtvqLHuLWQInyCy/fXkwnCnWR5/DW8HEgXPJy4YbiF+1OaYZba Ufo0UYGOnb8RVEX2VpNaJsvQWhls X-Google-Smtp-Source: AH8x226KEWlphr71szS5q2/q/WmUTE7APCGOihepT46aKL9chC2psw01Y2wF1oh02xsY7WvtE/fKbA== X-Received: by 10.99.177.4 with SMTP id r4mr3389527pgf.245.1518211573699; Fri, 09 Feb 2018 13:26:13 -0800 (PST) Received: from sc9-mailhost2.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id t22sm7860065pfi.118.2018.02.09.13.26.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 13:26:12 -0800 (PST) From: William Tu To: dev@openvswitch.org Date: Thu, 8 Feb 2018 22:16:20 -0800 Message-Id: <1518156980-70443-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DATE_IN_PAST_12_24, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] xlate: auto ofproto trace when recursion too deep 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 Usually ofproto/trace is used to debug the flow translation error. When translation error such as recursion too deep or too many resubmit, the issue might happen momentary; flows causing the recursion expire when users try to debug it. This patch enables the ofproto trace automatically when recursion is too deep or too many resubmit, by invoking the translation again, and log the ofproto trace as warnings. VMWare-BZ: #2054659 Signed-off-by: William Tu Tested-by: Greg Rose Reviewed-by: Greg Rose --- ofproto/ofproto-dpif-trace.c | 7 +------ ofproto/ofproto-dpif-trace.h | 6 ++++++ ofproto/ofproto-dpif-upcall.c | 19 ++++++++++++++++++- tests/ofproto-dpif.at | 22 ++++++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/ofproto/ofproto-dpif-trace.c b/ofproto/ofproto-dpif-trace.c index 3811e03b106d..25b018d48207 100644 --- a/ofproto/ofproto-dpif-trace.c +++ b/ofproto/ofproto-dpif-trace.c @@ -24,11 +24,6 @@ #include "openvswitch/ofp-parse.h" #include "unixctl.h" -static void ofproto_trace(struct ofproto_dpif *, const struct flow *, - const struct dp_packet *packet, - const struct ofpact[], size_t ofpacts_len, - struct ovs_list *next_ct_states, - struct ds *); static void oftrace_node_destroy(struct oftrace_node *); /* Creates a new oftrace_node, populates it with the given 'type' and a copy of @@ -662,7 +657,7 @@ ofproto_trace__(struct ofproto_dpif *ofproto, const struct flow *flow, * * If 'ofpacts' is nonnull then its 'ofpacts_len' bytes specify the actions to * trace, otherwise the actions are determined by a flow table lookup. */ -static void +void ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow, const struct dp_packet *packet, const struct ofpact ofpacts[], size_t ofpacts_len, diff --git a/ofproto/ofproto-dpif-trace.h b/ofproto/ofproto-dpif-trace.h index 5e51771b19b0..ea6cb3fc01ac 100644 --- a/ofproto/ofproto-dpif-trace.h +++ b/ofproto/ofproto-dpif-trace.h @@ -28,6 +28,8 @@ * each action (OFT_ACTION) executed in the table. */ +#include "openvswitch/dynamic-string.h" +#include "ofproto/ofproto-dpif.h" #include "openvswitch/compiler.h" #include "openvswitch/list.h" #include "flow.h" @@ -79,6 +81,10 @@ struct oftrace_next_ct_state { }; void ofproto_dpif_trace_init(void); +void ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow, + const struct dp_packet *packet, + const struct ofpact *, size_t ofpacts_len, + struct ovs_list *next_ct_states, struct ds *output); struct oftrace_node *oftrace_report(struct ovs_list *, enum oftrace_node_type, const char *text); diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 035233d5adc8..05064c8b85fa 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -34,6 +34,7 @@ #include "ofproto-dpif-sflow.h" #include "ofproto-dpif-xlate.h" #include "ofproto-dpif-xlate-cache.h" +#include "ofproto-dpif-trace.h" #include "ovs-rcu.h" #include "packets.h" #include "openvswitch/poll-loop.h" @@ -1128,7 +1129,9 @@ upcall_xlate(struct udpif *udpif, struct upcall *upcall, struct ofpbuf *odp_actions, struct flow_wildcards *wc) { struct dpif_flow_stats stats; + enum xlate_error xerr; struct xlate_in xin; + struct ds output; stats.n_packets = 1; stats.n_bytes = dp_packet_size(upcall->packet); @@ -1163,7 +1166,21 @@ upcall_xlate(struct udpif *udpif, struct upcall *upcall, upcall->dump_seq = seq_read(udpif->dump_seq); upcall->reval_seq = seq_read(udpif->reval_seq); - xlate_actions(&xin, &upcall->xout); + xerr = xlate_actions(&xin, &upcall->xout); + + /* Translate again and log the ofproto trace for + * these two error types. */ + if (xerr == XLATE_RECURSION_TOO_DEEP || + xerr == XLATE_TOO_MANY_RESUBMITS) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + + ds_init(&output); + ofproto_trace(upcall->ofproto, upcall->flow, + upcall->packet, NULL, 0, NULL, &output); + VLOG_WARN_RL(&rl, "%s", ds_cstr(&output)); + ds_destroy(&output); + } + if (wc) { /* Convert the input port wildcard from OFP to ODP format. There's no * real way to do this for arbitrary bitmasks since the numbering spaces diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 600afdda8528..776c5d34fae2 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -8473,6 +8473,28 @@ AT_CHECK([grep -c 'over max translation depth 64' stdout], OVS_VSWITCHD_STOP(["/resubmit actions recursed/d"]) AT_CLEANUP +dnl Without using ofproto/trace, make sure the +dnl ofproto trace is still logged +AT_SETUP([ofproto-dpif - backward resubmit without trace]) +OVS_VSWITCHD_START +(echo "table=0, actions=resubmit(,66)" + for i in `seq 2 66`; do + j=`expr $i - 1` + echo "table=$i, actions=resubmit(,$j)" + done + echo "table=1, actions=local") > flows +AT_CHECK([ovs-ofctl add-flows br0 flows]) + +AT_CHECK([ovs-appctl netdev-dummy/receive br0 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x1234)'], [0], [stdout]) + +AT_CHECK([grep -c "^ *resubmit" ovs-vswitchd.log], + [0], [66 +]) + +OVS_VSWITCHD_STOP(["/over max translation depth/d +/ofproto_dpif_upcall/d"]) +AT_CLEANUP + AT_SETUP([ofproto-dpif - exponential resubmit chain]) OVS_VSWITCHD_START add_of_ports br0 1