From patchwork Mon Jun 25 10:57:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 934172 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41DmNQ6hgwz9s01 for ; Mon, 25 Jun 2018 20:57:42 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 135DEBC1; Mon, 25 Jun 2018 10:57:33 +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 10E5EBBD for ; Mon, 25 Jun 2018 10:57:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7FEB0766 for ; Mon, 25 Jun 2018 10:57:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE1894023351 for ; Mon, 25 Jun 2018 10:57:29 +0000 (UTC) Received: from rhvm.imac (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 547DF2026D5B for ; Mon, 25 Jun 2018 10:57:29 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 25 Jun 2018 12:57:26 +0200 Message-Id: <152992424137.10837.8018927845969393798.stgit@rhvm.imac> In-Reply-To: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> References: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 25 Jun 2018 10:57:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 25 Jun 2018 10:57:29 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'echaudro@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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] [PATCH 1/5] mac-learning: Add additional mac-learning coverage counters 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch adds two additional mac-learning coverage counters: - mac_learning_evicted, entries deleted due to mac table being full - mac_learning_moved, entries where the port has changed. Signed-off-by: Eelco Chaudron --- lib/mac-learning.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mac-learning.c b/lib/mac-learning.c index 215caf0ba..8b7981dbb 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -32,6 +32,8 @@ COVERAGE_DEFINE(mac_learning_learned); COVERAGE_DEFINE(mac_learning_expired); +COVERAGE_DEFINE(mac_learning_evicted); +COVERAGE_DEFINE(mac_learning_moved); /* Returns the number of seconds since 'e' (within 'ml') was last learned. */ int @@ -150,6 +152,7 @@ evict_mac_entry_fairly(struct mac_learning *ml) struct mac_learning_port, heap_node); e = CONTAINER_OF(ovs_list_front(&mlport->port_lrus), struct mac_entry, port_lru_node); + COVERAGE_INC(mac_learning_evicted); mac_learning_expire(ml, e); } @@ -421,6 +424,9 @@ update_learning_table__(struct mac_learning *ml, struct eth_addr src, } if (mac_entry_get_port(ml, mac) != in_port) { + if (mac_entry_get_port(ml, mac) != NULL) { + COVERAGE_INC(mac_learning_moved); + } mac_entry_set_port(ml, mac, in_port); return true; } From patchwork Mon Jun 25 10:57:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 934173 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41DmNy50RRz9ry1 for ; Mon, 25 Jun 2018 20:58:10 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C7B9ABE6; Mon, 25 Jun 2018 10:57:44 +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 B934CBAE for ; Mon, 25 Jun 2018 10:57:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4023E764 for ; Mon, 25 Jun 2018 10:57:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6635E7C6A9 for ; Mon, 25 Jun 2018 10:57:42 +0000 (UTC) Received: from rhvm.imac (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09CCC111DCF3 for ; Mon, 25 Jun 2018 10:57:41 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 25 Jun 2018 12:57:40 +0200 Message-Id: <152992425486.10837.13570529371799807573.stgit@rhvm.imac> In-Reply-To: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> References: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 25 Jun 2018 10:57:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 25 Jun 2018 10:57:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'echaudro@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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] [PATCH 2/5] mac-learning: Add per mac learning instance counters 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch adds counters per mac_learning instance. The following counters are added: total_learned: Total number of learned MAC entries total_expired: Total number of expired MAC entries total_evicted: Total number of evicted MAC entries, i.e. entries moved out due to the table being full. total_moved : Total number of port moved MAC entries, i.e. entries where the MAC address moved to a different port. Signed-off-by: Eelco Chaudron --- lib/mac-learning.c | 17 +++++++++++++++++ lib/mac-learning.h | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/lib/mac-learning.c b/lib/mac-learning.c index 8b7981dbb..c13a5fac8 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -153,6 +153,7 @@ evict_mac_entry_fairly(struct mac_learning *ml) e = CONTAINER_OF(ovs_list_front(&mlport->port_lrus), struct mac_entry, port_lru_node); COVERAGE_INC(mac_learning_evicted); + ml->total_evicted++; mac_learning_expire(ml, e); } @@ -180,6 +181,18 @@ normalize_idle_time(unsigned int idle_time) : idle_time); } +/* Clear all the mac_learning statistics */ +static void +mac_learning_clear_statistics(struct mac_learning *ml) +{ + if (ml != NULL) { + ml->total_learned = 0; + ml->total_expired = 0; + ml->total_evicted = 0; + ml->total_moved = 0; + } +} + /* Creates and returns a new MAC learning table with an initial MAC aging * timeout of 'idle_time' seconds and an initial maximum of MAC_DEFAULT_MAX * entries. */ @@ -200,6 +213,7 @@ mac_learning_create(unsigned int idle_time) heap_init(&ml->ports_by_usage); ovs_refcount_init(&ml->ref_cnt); ovs_rwlock_init(&ml->rwlock); + mac_learning_clear_statistics(ml); return ml; } @@ -323,6 +337,7 @@ mac_learning_insert(struct mac_learning *ml, e->grat_arp_lock = TIME_MIN; e->mlport = NULL; COVERAGE_INC(mac_learning_learned); + ml->total_learned++; } else { ovs_list_remove(&e->lru_node); } @@ -426,6 +441,7 @@ update_learning_table__(struct mac_learning *ml, struct eth_addr src, if (mac_entry_get_port(ml, mac) != in_port) { if (mac_entry_get_port(ml, mac) != NULL) { COVERAGE_INC(mac_learning_moved); + ml->total_moved++; } mac_entry_set_port(ml, mac, in_port); return true; @@ -524,6 +540,7 @@ mac_learning_run(struct mac_learning *ml) && (hmap_count(&ml->table) > ml->max_entries || time_now() >= e->expires)) { COVERAGE_INC(mac_learning_expired); + ml->total_expired++; mac_learning_expire(ml, e); } diff --git a/lib/mac-learning.h b/lib/mac-learning.h index ee14185d9..29c4bc448 100644 --- a/lib/mac-learning.h +++ b/lib/mac-learning.h @@ -160,6 +160,12 @@ struct mac_learning { struct ovs_rwlock rwlock; bool need_revalidate; + /* Statistics */ + uint64_t total_learned; + uint64_t total_expired; + uint64_t total_evicted; + uint64_t total_moved; + /* Fairness. * * Both of these data structures include the same "struct From patchwork Mon Jun 25 10:57:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 934174 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41DmPW68Q0z9ry1 for ; Mon, 25 Jun 2018 20:58:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8195FC0C; Mon, 25 Jun 2018 10:57:57 +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 D82D0C3C for ; Mon, 25 Jun 2018 10:57:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8B321766 for ; Mon, 25 Jun 2018 10:57:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D237A7C6A9 for ; Mon, 25 Jun 2018 10:57:54 +0000 (UTC) Received: from rhvm.imac (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75D032026D5B for ; Mon, 25 Jun 2018 10:57:54 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 25 Jun 2018 12:57:52 +0200 Message-Id: <152992426757.10837.17933191572380743954.stgit@rhvm.imac> In-Reply-To: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> References: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 25 Jun 2018 10:57:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 25 Jun 2018 10:57:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'echaudro@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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] [PATCH 3/5] utilities: Update gdb script to include mac_learning counters 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch updates the GDB script "ovs_show_fdb" command to include the new per mac_learning instance counters. Signed-off-by: Eelco Chaudron --- utilities/gdb/ovs_gdb.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py index 65f9216d9..4e9dac040 100644 --- a/utilities/gdb/ovs_gdb.py +++ b/utilities/gdb/ovs_gdb.py @@ -797,6 +797,10 @@ class CmdShowFDB(gdb.Command): print("{}ports_by_ptr.n : {}".format(indent, ml['ports_by_ptr']['n'])) print("{}ports_by_usage.n: {}".format(indent, ml['ports_by_usage']['n'])) + print("{}total_learned : {}".format(indent, ml['total_learned'])) + print("{}total_expired : {}".format(indent, ml['total_expired'])) + print("{}total_evicted : {}".format(indent, ml['total_evicted'])) + print("{}total_moved : {}".format(indent, ml['total_moved'])) @staticmethod def display_mac_entry(mac_entry, indent=0, dbg=False): From patchwork Mon Jun 25 10:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 934175 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41DmQ63SlQz9ryk for ; Mon, 25 Jun 2018 20:59:10 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 576B7C34; Mon, 25 Jun 2018 10:58:09 +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 786A5BE1 for ; Mon, 25 Jun 2018 10:58:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DFEA0E2 for ; Mon, 25 Jun 2018 10:58:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1976640711A9 for ; Mon, 25 Jun 2018 10:58:07 +0000 (UTC) Received: from rhvm.imac (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE8782166B5D for ; Mon, 25 Jun 2018 10:58:06 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 25 Jun 2018 12:58:05 +0200 Message-Id: <152992427999.10837.18363551973359552852.stgit@rhvm.imac> In-Reply-To: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> References: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 25 Jun 2018 10:58:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 25 Jun 2018 10:58:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'echaudro@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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] [PATCH 4/5] ofproto: Add CLI commands to show and clear mac_learning statistics 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Add two new commands, fdb/stats-show and fdb/stats-clear, to ovs-appctl to show and clear the new mac_learning statistics. $ ovs-appctl fdb/stats-show ovs_pvp_br0 Statistics for bridge "ovs_pvp_br0": Current/maximum MAC entries in the table: 4/2048 Total number of learned MAC entries : 4 Total number of expired MAC entries : 1 Total number of evicted MAC entries : 0 Total number of port moved MAC entries : 32 $ ovs-appctl fdb/stats-clear ovs_pvp_br0 statistics successfully cleared Signed-off-by: Eelco Chaudron --- lib/mac-learning.c | 2 + lib/mac-learning.h | 1 + ofproto/ofproto-dpif.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/lib/mac-learning.c b/lib/mac-learning.c index c13a5fac8..f6183480d 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -182,7 +182,7 @@ normalize_idle_time(unsigned int idle_time) } /* Clear all the mac_learning statistics */ -static void +void mac_learning_clear_statistics(struct mac_learning *ml) { if (ml != NULL) { diff --git a/lib/mac-learning.h b/lib/mac-learning.h index 29c4bc448..1f7c42335 100644 --- a/lib/mac-learning.h +++ b/lib/mac-learning.h @@ -189,6 +189,7 @@ int mac_entry_age(const struct mac_learning *ml, const struct mac_entry *e) struct mac_learning *mac_learning_create(unsigned int idle_time); struct mac_learning *mac_learning_ref(const struct mac_learning *); void mac_learning_unref(struct mac_learning *); +void mac_learning_clear_statistics(struct mac_learning *ml); bool mac_learning_run(struct mac_learning *ml) OVS_REQ_WRLOCK(ml->rwlock); void mac_learning_wait(struct mac_learning *ml) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index ca4582cd5..514d51e6d 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5247,6 +5247,69 @@ ofproto_unixctl_fdb_show(struct unixctl_conn *conn, int argc OVS_UNUSED, ds_destroy(&ds); } +static void +ofproto_unixctl_fdb_stats_clear(struct unixctl_conn *conn, int argc, + const char *argv[], void *aux OVS_UNUSED) +{ + struct ofproto_dpif *ofproto; + + if (argc > 1) { + ofproto = ofproto_dpif_lookup_by_name(argv[1]); + if (!ofproto) { + unixctl_command_reply_error(conn, "no such bridge"); + return; + } + ovs_rwlock_wrlock(&ofproto->ml->rwlock); + mac_learning_clear_statistics(ofproto->ml); + ovs_rwlock_unlock(&ofproto->ml->rwlock); + } else { + HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node, + &all_ofproto_dpifs_by_name) { + ovs_rwlock_wrlock(&ofproto->ml->rwlock); + mac_learning_clear_statistics(ofproto->ml); + ovs_rwlock_unlock(&ofproto->ml->rwlock); + } + } + + unixctl_command_reply(conn, "statistics successfully cleared"); +} + +static void +ofproto_unixctl_fdb_stats_show(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[], void *aux OVS_UNUSED) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + const struct ofproto_dpif *ofproto; + ofproto = ofproto_dpif_lookup_by_name(argv[1]); + if (!ofproto) { + unixctl_command_reply_error(conn, "no such bridge"); + return; + } + + ds_put_format(&ds, "Statistics for bridge \"%s\":\n", argv[1]); + ovs_rwlock_rdlock(&ofproto->ml->rwlock); + + ds_put_format(&ds, " Current/maximum MAC entries in the table: %" + PRIuSIZE"/%"PRIuSIZE"\n", + hmap_count(&ofproto->ml->table), ofproto->ml->max_entries); + ds_put_format(&ds, + " Total number of learned MAC entries : %"PRIu64"\n", + ofproto->ml->total_learned); + ds_put_format(&ds, + " Total number of expired MAC entries : %"PRIu64"\n", + ofproto->ml->total_expired); + ds_put_format(&ds, + " Total number of evicted MAC entries : %"PRIu64"\n", + ofproto->ml->total_evicted); + ds_put_format(&ds, + " Total number of port moved MAC entries : %"PRIu64"\n", + ofproto->ml->total_moved); + + ovs_rwlock_unlock(&ofproto->ml->rwlock); + unixctl_command_reply(conn, ds_cstr(&ds)); + ds_destroy(&ds); +} + static void ofproto_unixctl_mcast_snooping_show(struct unixctl_conn *conn, int argc OVS_UNUSED, @@ -5737,6 +5800,10 @@ ofproto_unixctl_init(void) ofproto_unixctl_fdb_flush, NULL); unixctl_command_register("fdb/show", "bridge", 1, 1, ofproto_unixctl_fdb_show, NULL); + unixctl_command_register("fdb/stats-clear", "[bridge]", 0, 1, + ofproto_unixctl_fdb_stats_clear, NULL); + unixctl_command_register("fdb/stats-show", "bridge", 1, 1, + ofproto_unixctl_fdb_stats_show, NULL); unixctl_command_register("mdb/flush", "[bridge]", 0, 1, ofproto_unixctl_mcast_snooping_flush, NULL); unixctl_command_register("mdb/show", "bridge", 1, 1, From patchwork Mon Jun 25 10:58:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 934176 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41DmQq3FSJz9ry1 for ; Mon, 25 Jun 2018 20:59:47 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4B034C8A; Mon, 25 Jun 2018 10:58:26 +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 01DF1BA9 for ; Mon, 25 Jun 2018 10:58:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B0CD8E2 for ; Mon, 25 Jun 2018 10:58:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0336181A4EAA for ; Mon, 25 Jun 2018 10:58:24 +0000 (UTC) Received: from rhvm.imac (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D3CA2166B5D for ; Mon, 25 Jun 2018 10:58:23 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 25 Jun 2018 12:58:17 +0200 Message-Id: <152992429226.10837.8692862059530640018.stgit@rhvm.imac> In-Reply-To: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> References: <152992422304.10837.6128066538561533468.stgit@rhvm.imac> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 25 Jun 2018 10:58:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 25 Jun 2018 10:58:24 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'echaudro@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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] [PATCH 5/5] vswitchd: Document new fdb statistics commands 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Document the new fdb/stats-clear and fdb/stats-show commands Signed-off-by: Eelco Chaudron --- vswitchd/ovs-vswitchd.8.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vswitchd/ovs-vswitchd.8.in b/vswitchd/ovs-vswitchd.8.in index 55b997b60..e39d158d5 100644 --- a/vswitchd/ovs-vswitchd.8.in +++ b/vswitchd/ovs-vswitchd.8.in @@ -166,6 +166,11 @@ if no \fIbridge\fR is given. Lists each MAC address/VLAN pair learned by the specified \fIbridge\fR, along with the port on which it was learned and the age of the entry, in seconds. +.IP "\fBfdb/stats-clear\fR [\fIbridge\fR]" +Clear \fIbridge\fR MAC address learning table statistics, or all +statistics if no \fIbridge\fR is given. +.IP "\fBfdb/stats-show\fR \fIbridge\fR" +Show MAC address learning table statistics for the specified \fIbridge\fR. .IP "\fBmdb/flush\fR [\fIbridge\fR]" Flushes \fIbridge\fR multicast snooping table, or all snooping tables if no \fIbridge\fR is given.