#include "bitmap.h"
#include "dpif-provider.h"
#include "netdev.h"
+#include "netdev-linux.h"
#include "netdev-vport.h"
#include "netlink-socket.h"
#include "netlink.h"
dpif_port->name = xstrdup(reply.name);
dpif_port->type = xstrdup(netdev_vport_get_netdev_type(&reply));
dpif_port->port_no = reply.port_no;
+ if (reply.stats) {
+ netdev_stats_from_rtnl_link_stats64(&dpif_port->stats,
+ reply.stats);
+ } else {
+ memset(&dpif_port->stats, 0xff, sizeof dpif_port->stats);
+ }
ofpbuf_delete(buf);
}
return error;
dpif_port->name = (char *) vport.name;
dpif_port->type = (char *) netdev_vport_get_netdev_type(&vport);
dpif_port->port_no = vport.port_no;
+ if (vport.stats) {
+ netdev_stats_from_rtnl_link_stats64(&dpif_port->stats, vport.stats);
+ } else {
+ memset(&dpif_port->stats, 0xff, sizeof dpif_port->stats);
+ }
return 0;
}
Prints the name of each configured datapath on a separate line.
.
.TP
-\fBshow \fR[\fIdp\fR...]
+[\fB\-s\fR | \fB\-\-statistics\fR] \fBshow \fR[\fIdp\fR...]
Prints a summary of configured datapaths, including their datapath
numbers and a list of ports connected to each datapath. (The local
-port is identified as port 0.)
+port is identified as port 0.) If \fB\-s\fR or \fB\-\-statistics\fR
+is specified, then packet and byte counters are also printed for each
+port.
.IP
If one or more datapaths are specified, information on only those
datapaths are displayed. Otherwise, \fBovs\-dpctl\fR displays information
up may be confused about their disappearance.
.
.SH OPTIONS
+.IP "\fB\-s\fR, \fB\-\-statistics\fR"
+Causes the \fBshow\fR command to print packet and byte counters for
+each port within the datapaths that it shows.
.TP
\fB\-t\fR, \fB\-\-timeout=\fIsecs\fR
Limits \fBovs\-dpctl\fR runtime to approximately \fIsecs\fR seconds. If
VLOG_DEFINE_THIS_MODULE(dpctl);
+/* -s, --statistics: Print port statistics? */
+bool print_statistics;
+
static const struct command all_commands[];
static void usage(void) NO_RETURN;
VLOG_OPTION_ENUMS
};
static struct option long_options[] = {
+ {"statistics", no_argument, 0, 's'},
{"timeout", required_argument, 0, 't'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
}
switch (c) {
+ case 's':
+ print_statistics = true;
+ break;
+
case 't':
timeout = strtoul(optarg, NULL, 10);
if (timeout <= 0) {
}
}
+static void
+print_stat(const char *leader, uint64_t value)
+{
+ fputs(leader, stdout);
+ if (value != UINT64_MAX) {
+ printf("%"PRIu64, value);
+ } else {
+ putchar('?');
+ }
+}
+
+static void
+print_human_size(uint64_t value)
+{
+ if (value == UINT64_MAX) {
+ /* Nothing to do. */
+ } else if (value >= 1024ULL * 1024 * 1024 * 1024) {
+ printf(" (%.1f TiB)", value / (1024.0 * 1024 * 1024 * 1024));
+ } else if (value >= 1024ULL * 1024 * 1024) {
+ printf(" (%.1f GiB)", value / (1024.0 * 1024 * 1024));
+ } else if (value >= 1024ULL * 1024) {
+ printf(" (%.1f MiB)", value / (1024.0 * 1024));
+ } else if (value >= 1024) {
+ printf(" (%.1f KiB)", value / 1024.0);
+ }
+}
+
static void
show_dpif(struct dpif *dpif)
{
putchar(')');
}
putchar('\n');
+
+ if (print_statistics) {
+ const struct netdev_stats *s = &dpif_port.stats;
+
+ print_stat("\t\tRX packets:", s->rx_packets);
+ print_stat(" errors:", s->rx_errors);
+ print_stat(" dropped:", s->rx_dropped);
+ print_stat(" overruns:", s->rx_over_errors);
+ print_stat(" frame:", s->rx_frame_errors);
+ printf("\n");
+
+ print_stat("\t\tTX packets:", s->tx_packets);
+ print_stat(" errors:", s->tx_errors);
+ print_stat(" dropped:", s->tx_dropped);
+ print_stat(" aborted:", s->tx_aborted_errors);
+ print_stat(" carrier:", s->tx_carrier_errors);
+ printf("\n");
+
+ print_stat("\t\tcollisions:", s->collisions);
+ printf("\n");
+
+ print_stat("\t\tRX bytes:", s->rx_bytes);
+ print_human_size(s->rx_bytes);
+ print_stat(" TX bytes:", s->tx_bytes);
+ print_human_size(s->tx_bytes);
+ printf("\n");
+ }
}
dpif_close(dpif);
}