diff options
| author | Simon Horman <horms@verge.net.au> | 2011-08-04 08:04:10 +0900 |
|---|---|---|
| committer | Jesse Gross <jesse@nicira.com> | 2011-08-03 21:38:03 -0700 |
| commit | f180c2e2ccdfc36801685dc487748b570652da68 (patch) | |
| tree | 3fa4fbabe71a75eb667c549277e5588c74b7e681 | |
| parent | 6da1e8091eb2e19de7ba5e0c73ac3e7dd437743d (diff) | |
| download | openvswitch-f180c2e2ccdfc36801685dc487748b570652da68.tar.gz | |
ovs-dpctl: Show number of flows
Expose the number of flows present in a datapath to user-space
and to users via ovs-dpctl show.
e.g.:
ovs-dpctl show br3
system@br3:
lookups: frags:0, hit:0, missed:0, lost:0
flows: 0
...
Signed-off-by: Simon Horman <horms@verge.net.au>
[Jesse: Add same logic to userspace datapath.]
Signed-off-by: Jesse Gross <jesse@nicira.com>
| -rw-r--r-- | datapath/datapath.c | 3 | ||||
| -rw-r--r-- | include/openvswitch/datapath-protocol.h | 1 | ||||
| -rw-r--r-- | lib/dpif-netdev.c | 1 | ||||
| -rw-r--r-- | utilities/ovs-dpctl.c | 1 |
4 files changed, 6 insertions, 0 deletions
diff --git a/datapath/datapath.c b/datapath/datapath.c index 3ec5be4e3..b19123975 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -747,6 +747,9 @@ static struct genl_ops dp_packet_genl_ops[] = { static void get_dp_stats(struct datapath *dp, struct odp_stats *stats) { int i; + struct tbl *table = get_table_protected(dp); + + stats->n_flows = tbl_count(table); stats->n_frags = stats->n_hit = stats->n_missed = stats->n_lost = 0; for_each_possible_cpu(i) { diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 0b755e8ff..426236cd5 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -133,6 +133,7 @@ struct odp_stats { uint64_t n_hit; /* Number of flow table matches. */ uint64_t n_missed; /* Number of flow table misses. */ uint64_t n_lost; /* Number of misses not sent to userspace. */ + uint64_t n_flows; /* Number of flows present */ }; /* Logical ports. */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index d48d7ae1f..14b919275 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -302,6 +302,7 @@ dpif_netdev_get_stats(const struct dpif *dpif, struct odp_stats *stats) { struct dp_netdev *dp = get_dp_netdev(dpif); memset(stats, 0, sizeof *stats); + stats->n_flows = hmap_count(&dp->flow_table); stats->n_frags = dp->n_frags; stats->n_hit = dp->n_hit; stats->n_missed = dp->n_missed; diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c index c7350e5c4..415d276ec 100644 --- a/utilities/ovs-dpctl.c +++ b/utilities/ovs-dpctl.c @@ -369,6 +369,7 @@ show_dpif(struct dpif *dpif) (unsigned long long int) stats.n_hit, (unsigned long long int) stats.n_missed, (unsigned long long int) stats.n_lost); + printf("\tflows: %llu\n", (unsigned long long int)stats.n_flows); } DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) { printf("\tport %u: %s", dpif_port.port_no, dpif_port.name); |
