From patchwork Thu Jan 16 11:44:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emma Finn X-Patchwork-Id: 1224161 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=intel.com 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 47z2S33pdgz9sPW for ; Thu, 16 Jan 2020 22:45:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3EDC987B18; Thu, 16 Jan 2020 11:45:05 +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 7UqXipsKEUuL; Thu, 16 Jan 2020 11:45:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id B8D1D87D7B; Thu, 16 Jan 2020 11:45:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 991C5C1D82; Thu, 16 Jan 2020 11:45:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id DCC96C077D for ; Thu, 16 Jan 2020 11:44:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C6E7786148 for ; Thu, 16 Jan 2020 11:44:59 +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 zDsQehEIl79p for ; Thu, 16 Jan 2020 11:44:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 7BD0785A7D for ; Thu, 16 Jan 2020 11:44:54 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 03:44:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,326,1574150400"; d="scan'208";a="425502714" Received: from silpixa00397517.ir.intel.com ([10.237.222.176]) by fmsmga006.fm.intel.com with ESMTP; 16 Jan 2020 03:44:52 -0800 From: Emma Finn To: dev@openvswitch.org Date: Thu, 16 Jan 2020 11:44:48 +0000 Message-Id: <1579175088-45449-1-git-send-email-emma.finn@intel.com> X-Mailer: git-send-email 2.7.4 Cc: ian.stokes@intel.org, Emma Finn , i.maximets@ovn.org Subject: [ovs-dev] [v4] dpif-netdev: Modified ovs-appctl dpctl/dump-flows command 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" Modified ovs-appctl dpctl/dump-flows command to output the miniflow bits for a given flow when -m option is passed. $ ovs-appctl dpctl/dump-flows -m Signed-off-by: Emma Finn --- RFC -> v1 * Changed revision from RFC to v1 * Reformatted based on comments * Fixed same classifier being dumped multiple times flagged by Ilya * Fixed print of subtables flagged by William * Updated print count of bits as well as bits themselves --- v1 -> v2 * Reformatted based on comments * Refactored code to make output part of ovs-appctl dpctl/dump-flows -m command. --- v2 -> v3 * Added attribute dp_extra_info to dpif_flow_attrs struct to store miniflow bits as a string --- v3 -> v4 * Fixed string leak * Refactored to code to make it independent from the flowmap size --- NEWS | 2 ++ lib/dpctl.c | 5 +++++ lib/dpif-netdev.c | 14 ++++++++++++++ lib/dpif.h | 1 + 4 files changed, 22 insertions(+) diff --git a/NEWS b/NEWS index 965faca..1c9d2db 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ Post-v2.12.0 * Add option to enable, disable and query TCP sequence checking in conntrack. * Add support for conntrack zone limits. + * Command "ovs-appctl dpctl/dump-flows" refactored to show subtable + miniflow bits for userspace datapath. - AF_XDP: * New option 'use-need-wakeup' for netdev-afxdp to control enabling of corresponding 'need_wakeup' flag in AF_XDP rings. Enabled by default diff --git a/lib/dpctl.c b/lib/dpctl.c index a1ea25b..1b0a2bf 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -825,6 +825,11 @@ format_dpif_flow(struct ds *ds, const struct dpif_flow *f, struct hmap *ports, } ds_put_cstr(ds, ", actions:"); format_odp_actions(ds, f->actions, f->actions_len, ports); + if (dpctl_p->verbosity && f->attrs.dp_extra_info) { + ds_put_format(ds, ", dp-extra-info:%s", + f->attrs.dp_extra_info); + } + free(f->attrs.dp_extra_info); } struct dump_types { diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 079bd1b..a640b49 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3101,6 +3101,20 @@ dp_netdev_flow_to_dpif_flow(const struct dp_netdev_flow *netdev_flow, flow->attrs.offloaded = false; flow->attrs.dp_layer = "ovs"; + + struct ds extra_info = DS_EMPTY_INITIALIZER; + size_t unit; + + ds_put_cstr(&extra_info, "miniflow_bits("); FLOWMAP_FOR_EACH_UNIT (unit) { + if (unit) { + ds_put_char(&extra_info, ','); + } + ds_put_format(&extra_info, "%d", + count_1bits(netdev_flow->cr.mask->mf.map.bits[unit])); + } + ds_put_char(&extra_info, ')'); + flow->attrs.dp_extra_info = ds_steal_cstr(&extra_info); + ds_destroy(&extra_info); } static int diff --git a/lib/dpif.h b/lib/dpif.h index c21e897..59d82dc 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -513,6 +513,7 @@ struct dpif_flow_detailed_stats { struct dpif_flow_attrs { bool offloaded; /* True if flow is offloaded to HW. */ const char *dp_layer; /* DP layer the flow is handled in. */ + char *dp_extra_info; /* Extra information provided by DP. */ }; struct dpif_flow_dump_types {