From patchwork Mon Sep 28 09:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1372461 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.137; helo=fraxinus.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=WYhW8Ifs; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0H5k3wCZz9sPB for ; Mon, 28 Sep 2020 19:19:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1D3B784EA3; Mon, 28 Sep 2020 09:19:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id utrdhk5Hs73k; Mon, 28 Sep 2020 09:19:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5303A844C7; Mon, 28 Sep 2020 09:19:18 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2AB72C016F; Mon, 28 Sep 2020 09:19:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 06D56C0051 for ; Mon, 28 Sep 2020 09:19:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id F00FF85B8D for ; Mon, 28 Sep 2020 09:19:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CXfn5ugRkow6 for ; Mon, 28 Sep 2020 09:19:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vs1-f65.google.com (mail-vs1-f65.google.com [209.85.217.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 1009C846AD for ; Mon, 28 Sep 2020 09:19:16 +0000 (UTC) Received: by mail-vs1-f65.google.com with SMTP id y190so339244vsy.1 for ; Mon, 28 Sep 2020 02:19:16 -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=HKxwhfdbM46LAw9o1zXIoMN0dhVHeoNKNcTCXAHSME4=; b=WYhW8IfsdxEfj9LSSgdmiQAgQNOE5XFD1b8w+qB3rtICvRyZrNhOpj1Ad5oIH677I8 qv2xAPlWzgxbDD7F0556UN7aptBNzCOBQapiL1xLv9Uy7wNQgyLgw4L/rNSntE/04bw/ SH61FycOSh9hsH6wsagg5chKMzxHa4vOtRa9Muyw763isedf7IzTQfNEgE5MfrXbLuUH ns7qV6qWWfeICjfkLfTf67xN3fHXFaS6ZGfXaZXzZgLK6Suu7ENpGcgsSBW15Z+mBo1L +tA0UaLGGdBU2eLQumJ+0fKlzutGn+hYCZo9hEyJMwiUbNYwyloozK3JxojGEDs0kLJM 0+5Q== 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=HKxwhfdbM46LAw9o1zXIoMN0dhVHeoNKNcTCXAHSME4=; b=V/YjLeIZcG0woxuoV5ZuIGqnAsdMtAAjkYuyOxa10PrvvgHxyYMWbFvHi/1aNmcQZv Gs4bkteklgUPC4whsVoJNMAkHFQtIHXQvdAfCUzSn6QNOn5t5QmVtALRdHHIGWs8EuiQ WgogtSKWFe2SpN8Ao99UKqnatDHUtILg9JBNjJfpnFjx/ocqaYZ55WApoJz8GtqO5Rj+ 8sqLdeLIvpqfs614Xoaaq3Ijien6MyJIMTS5I8kvoB2Io0QlMUU/6uPKtr1abjSZD7dn ivuW3figJYPRsytUrysuQlBqWc03sxj/pdd4IGe/+IIZsyctw8o+frUWrm/JZ4TS3bNp KjIg== X-Gm-Message-State: AOAM533A62LIvqoaqYe8i6YyLhoCTmOq6MZYNBdgKOcas0/RnuMmSCUJ hgqKi+cIQKDvvr8+LIYyh6I= X-Google-Smtp-Source: ABdhPJzPpihg/a7IgobOVVZFnnqcX6Ss/1t/B0+titiO9TZ1slRzzs2zlfg8tSeuw5a1+NbKxY8/4g== X-Received: by 2002:a67:e2c2:: with SMTP id i2mr4940849vsm.27.1601284755052; Mon, 28 Sep 2020 02:19:15 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id j21sm1080040vkn.26.2020.09.28.02.19.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2020 02:19:14 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: fbl@sysclose.org, i.maximets@ovn.org Date: Mon, 28 Sep 2020 17:17:22 +0800 Message-Id: <20200928091722.2830-1-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH v3] 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 from pmd when we have a large number of rules in dp. Signed-off-by: Tonghao Zhang --- v3: * remove unnecessary check * as filter to reduce the size of a printed data. --- NEWS | 2 ++ lib/dpctl.c | 16 ++++++++++++---- lib/dpctl.man | 6 +++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index a9c50add2da0..ae68f5fca4e3 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ Post-v2.14.0 - OVSDB: * New unixctl command 'ovsdb-server/get-db-storage-status' to show the status of the storage that's backing a database. + * Command "ovs-appctl dpctl/dump-flows" added option "pmd" which allow + user to dump pmd specified. v2.14.0 - 17 Aug 2020 diff --git a/lib/dpctl.c b/lib/dpctl.c index 09ae97f25cf3..cbf989ce6650 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,12 @@ 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=%"SCNu32, &pmd_id)) { + error = EINVAL; + goto out_free; + } + pmd_id_filter = true; } } @@ -1070,7 +1077,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 +1086,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)); } @@ -2503,8 +2511,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..192bee489de7 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. +The \fBpmd=\fI-1\fR means that dump only the flows on the main pthread. +This option supported only for \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: