From patchwork Thu Oct 15 03:33:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1382429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=N0tyZH9L; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CBZf44W12z9sT6 for ; Thu, 15 Oct 2020 14:34:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id DA54B88062; Thu, 15 Oct 2020 03:34:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IUDEvMpKLCgh; Thu, 15 Oct 2020 03:34:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id F282B87F35; Thu, 15 Oct 2020 03:34:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BE586C07FF; Thu, 15 Oct 2020 03:34:32 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id ED7AEC0051 for ; Thu, 15 Oct 2020 03:34:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E99C420469 for ; Thu, 15 Oct 2020 03:34:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2f4fNCKpa3-c for ; Thu, 15 Oct 2020 03:34:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by silver.osuosl.org (Postfix) with ESMTPS id C782720445 for ; Thu, 15 Oct 2020 03:34:30 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id p3so683938pjd.0 for ; Wed, 14 Oct 2020 20:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Bgh+T3xTNNHj6NXfufp7mpeqLyl0xB+UbBzqAZy7pIQ=; b=N0tyZH9LnHtl+TUHt+VkWj53EBrh/sa+8Bff9EOlXF01+kGNWHxDnJw1Hsp2kklkaV d5uH9rSL7Hl1IEZU3IyRqGazExewbVA+z8owtgj7A6voqqnCe50iFUneiGfrPbeZQk/4 2MWtSAWykH+f9q2brO2m5oGR3nvGJgRan5Bl0OSodadxNEOHpdsDm6XmApZ0mu8U+jcB 5TvODWkS0BitjxjmVzyW9t2w7YB2Q4qPXGkz6g1dtlJMwyD0ikLdS2heR5HscZj8H5RA YZKNrVhOvxPdi3UuKKYAxfaE0weJSbJSDpjOn+aFIw6BsoXH8qmr56G6jmMGpWV71o7y aEIQ== 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; bh=Bgh+T3xTNNHj6NXfufp7mpeqLyl0xB+UbBzqAZy7pIQ=; b=Ys5DtwTulNKhiGPY9XGE4zOCl0oldU+AjQZznSPyMc7Ofd8bhAQ3VNNN02vbR5F33j J/1pL347dueCmA5aPJQ2ROHqSnV5kgbZKR78xcpZTdwlMHqTQu5cLORWnBQjegjFWQCj ES2TkTdVvS8rSTJeVD2uj8j0DEVXh6Jm6gVBl+O4ju6K/Exj+r19Avrm6Do3rf82fwOq qDKUmLJEze63HPp1ZW4wfnYvNKNgD7+HS10hhKnmPChiUc5Y7jFtTm7IRCwiN4tcZuCF K7bgGAogA6MmhbX8spGLOARrVPQ7QpSY0N2SBPtramprcvaI6Mjl5gHmFe3UdqSa/Iah 9iJw== X-Gm-Message-State: AOAM531UT+R+j0qTakLKUczZViUR43l9vRKlb76BfxSwQ3VNGplSFyQW MRPYji6IlvS4FWI4KdfGuYs= X-Google-Smtp-Source: ABdhPJyYhiw+IPOg1NCie72zrtH2baWJpZJNpmRynL6drIbR0Pp3LiivJ2VuKsAOkXR+TwApQa37PA== X-Received: by 2002:a17:90b:4b08:: with SMTP id lx8mr2364236pjb.211.1602732870400; Wed, 14 Oct 2020 20:34:30 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id t15sm3594089pjq.3.2020.10.14.20.34.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 20:34:29 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: grive@u256.net, i.maximets@ovn.org, fbl@sysclose.org Date: Thu, 15 Oct 2020 11:33:59 +0800 Message-Id: <20201015033359.91427-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ovs v4] dpctl-netdev: Add the option 'pmd' for dump-flows 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang "ovs-appctl dpctl/dump-flows" added the option "pmd" which allow user to dump pmd specified. That option is useful to dump rules of pmd when we have a large number of rules in dp. Signed-off-by: Tonghao Zhang Acked-by: Gaetan Rivet --- NEWS | 3 +++ lib/dpctl.c | 20 ++++++++++++++++---- lib/dpctl.man | 6 +++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 4619e73bf83b..276a5e878b3f 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ Post-v2.14.0 status of the storage that's backing a database. - DPDK: * Removed support for vhost-user dequeue zero-copy. + - Userspace datapath: + * Add the 'pmd' option to "ovs-appctl dpctl/dump-flows", which + restricts a flow dump to a single PMD thread if set. - The environment variable OVS_UNBOUND_CONF, if set, is now used as the DNS resolver's (unbound) configuration file. diff --git a/lib/dpctl.c b/lib/dpctl.c index 2f859a7531c9..33202813b544 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -980,6 +980,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) struct dpif_flow_dump *flow_dump; struct dpif_flow f; int pmd_id = PMD_ID_NULL; + bool pmd_id_filter = false; int lastargc = 0; int error; @@ -996,6 +997,16 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) goto out_free; } types_list = xstrdup(argv[--argc] + 5); + } else if (!strncmp(argv[argc - 1], "pmd=", 4)) { + if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id)) { + error = EINVAL; + goto out_free; + } + + if (pmd_id == -1) { + pmd_id = NON_PMD_CORE_ID; + } + pmd_id_filter = true; } } @@ -1070,7 +1081,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) /* If 'pmd_id' is specified, overlapping flows could be dumped from * different pmd threads. So, separates dumps from different pmds * by printing a title line. */ - if (pmd_id != f.pmd_id) { + if (!pmd_id_filter && pmd_id != f.pmd_id) { if (f.pmd_id == NON_PMD_CORE_ID) { ds_put_format(&ds, "flow-dump from the main thread:\n"); } else { @@ -1079,7 +1090,8 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) } pmd_id = f.pmd_id; } - if (flow_passes_type_filter(&f, &dump_types)) { + if (pmd_id == f.pmd_id && + flow_passes_type_filter(&f, &dump_types)) { format_dpif_flow(&ds, &f, portno_names, dpctl_p); dpctl_print(dpctl_p, "%s\n", ds_cstr(&ds)); } @@ -2522,8 +2534,8 @@ static const struct dpctl_command all_commands[] = { { "set-if", "dp iface...", 2, INT_MAX, dpctl_set_if, DP_RW }, { "dump-dps", "", 0, 0, dpctl_dump_dps, DP_RO }, { "show", "[dp...]", 0, INT_MAX, dpctl_show, DP_RO }, - { "dump-flows", "[dp] [filter=..] [type=..]", - 0, 3, dpctl_dump_flows, DP_RO }, + { "dump-flows", "[dp] [filter=..] [type=..] [pmd=..]", + 0, 4, dpctl_dump_flows, DP_RO }, { "add-flow", "[dp] flow actions", 2, 3, dpctl_add_flow, DP_RW }, { "mod-flow", "[dp] flow actions", 2, 3, dpctl_mod_flow, DP_RW }, { "get-flow", "[dp] ufid", 1, 2, dpctl_get_flow, DP_RO }, diff --git a/lib/dpctl.man b/lib/dpctl.man index 727d1f7be8d4..0f63277861e5 100644 --- a/lib/dpctl.man +++ b/lib/dpctl.man @@ -104,7 +104,7 @@ default. When multiple datapaths exist, then a datapath name is required. . .TP -.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR]" +.DO "[\fB\-m \fR| \fB\-\-more\fR] [\fB\-\-names \fR| \fB\-\-no\-names\fR]" \*(DX\fBdump\-flows\fR "[\fIdp\fR] [\fBfilter=\fIfilter\fR] [\fBtype=\fItype\fR] [\fBpmd=\fIpmd\fR]" Prints to the console all flow entries in datapath \fIdp\fR's flow table. Without \fB\-m\fR or \fB\-\-more\fR, output omits match fields that a flow wildcards entirely; with \fB\-m\fR or \fB\-\-more\fR, @@ -118,6 +118,10 @@ The \fIfilter\fR is also useful to match wildcarded fields in the datapath flow. As an example, \fBfilter='tcp,tp_src=100'\fR will match the datapath flow containing '\fBtcp(src=80/0xff00,dst=8080/0xff)\fR'. .IP +If \fBpmd=\fIpmd\fR is specified, only displays flows of the specified pmd. +Using \fBpmd=\fI-1\fR will restrict the dump to flows from the main thread. +This option is only supported by the \fBuserspace datapath\fR. +.IP If \fBtype=\fItype\fR is specified, only displays flows of the specified types. This option supported only for \fBovs\-appctl dpctl/dump\-flows\fR. \fItype\fR is a comma separated list, which can contain any of the following: