2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00

dpif-linux: fix the size of n_masks

The command ovs-dpctl can wrongly output the masks even if the
datapath does not implement mega flows. In this case the output
will be similar to the following:

system@ovs-system:
	lookups: hit:14 missed:41 lost:0
	flows: 0
	masks: hit:18446744073709551615 total:4294967295
		hit/pkt:335395346794719104.00
	port 0: ovs-system (internal)
	port 1: gre_system (gre: df_default=false, ttl=0)
	port 2: ots-br0 (internal)
	port 3: int0 (internal)
	port 4: vnet0
	port 5: vnet1

The problem depends on the fact that n_masks stats is stored as a
uint32 in the struct ovs_dp_megaflow_stats and as a uint64 in the
struct dpif_dp_stats. UINT32_MAX instead of UINT64_MAX should be
used to detect if the datapath supports megaflows or not.

Signed-off-by: Francesco Fusco <ffusco@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Francesco Fusco
2013-12-17 20:18:18 +01:00
committed by Ben Pfaff
parent 428b2eddc9
commit 1ce3fa06fc
4 changed files with 5 additions and 4 deletions

View File

@@ -39,6 +39,7 @@ Edouard Bourguignon madko@linuxed.net
Edward Tomasz Napierała trasz@freebsd.org Edward Tomasz Napierała trasz@freebsd.org
Ethan Jackson ethan@nicira.com Ethan Jackson ethan@nicira.com
Flavio Leitner fbl@redhat.com Flavio Leitner fbl@redhat.com
Francesco Fusco ffusco@redhat.com
FUJITA Tomonori fujita.tomonori@lab.ntt.co.jp FUJITA Tomonori fujita.tomonori@lab.ntt.co.jp
Gaetano Catalli gaetano.catalli@gmail.com Gaetano Catalli gaetano.catalli@gmail.com
Geoffrey Wossum gwossum@acm.org Geoffrey Wossum gwossum@acm.org

View File

@@ -407,7 +407,7 @@ dpif_netdev_get_stats(const struct dpif *dpif, struct dpif_dp_stats *stats)
stats->n_hit = dp->n_hit; stats->n_hit = dp->n_hit;
stats->n_missed = dp->n_missed; stats->n_missed = dp->n_missed;
stats->n_lost = dp->n_lost; stats->n_lost = dp->n_lost;
stats->n_masks = UINT64_MAX; stats->n_masks = UINT32_MAX;
stats->n_mask_hit = UINT64_MAX; stats->n_mask_hit = UINT64_MAX;
ovs_mutex_unlock(&dp_netdev_mutex); ovs_mutex_unlock(&dp_netdev_mutex);

View File

@@ -413,9 +413,9 @@ struct dpif_dp_stats {
uint64_t n_missed; /* Number of flow table misses. */ uint64_t n_missed; /* Number of flow table misses. */
uint64_t n_lost; /* Number of misses not sent to userspace. */ uint64_t n_lost; /* Number of misses not sent to userspace. */
uint64_t n_flows; /* Number of flows present. */ uint64_t n_flows; /* Number of flows present. */
uint64_t n_masks; /* Number of mega flow masks. */
uint64_t n_mask_hit; /* Number of mega flow masks visited for uint64_t n_mask_hit; /* Number of mega flow masks visited for
flow table matches. */ flow table matches. */
uint32_t n_masks; /* Number of mega flow masks. */
}; };
int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *); int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *);

View File

@@ -561,11 +561,11 @@ show_dpif(struct dpif *dpif)
printf("\tlookups: hit:%"PRIu64" missed:%"PRIu64" lost:%"PRIu64"\n" printf("\tlookups: hit:%"PRIu64" missed:%"PRIu64" lost:%"PRIu64"\n"
"\tflows: %"PRIu64"\n", "\tflows: %"PRIu64"\n",
stats.n_hit, stats.n_missed, stats.n_lost, stats.n_flows); stats.n_hit, stats.n_missed, stats.n_lost, stats.n_flows);
if (stats.n_masks != UINT64_MAX) { if (stats.n_masks != UINT32_MAX) {
uint64_t n_pkts = stats.n_hit + stats.n_missed; uint64_t n_pkts = stats.n_hit + stats.n_missed;
double avg = n_pkts ? (double) stats.n_mask_hit / n_pkts : 0.0; double avg = n_pkts ? (double) stats.n_mask_hit / n_pkts : 0.0;
printf("\tmasks: hit:%"PRIu64" total:%"PRIu64" hit/pkt:%.2f\n", printf("\tmasks: hit:%"PRIu64" total:%"PRIu32" hit/pkt:%.2f\n",
stats.n_mask_hit, stats.n_masks, avg); stats.n_mask_hit, stats.n_masks, avg);
} }
} }