#include "openvswitch/ofpbuf.h"
#include "ovs-numa.h"
#include "packets.h"
-#include "shash.h"
+#include "openvswitch/shash.h"
#include "simap.h"
#include "smap.h"
#include "sset.h"
}
}
+/* qsort comparison function. */
+static int
+compare_port_nos(const void *a_, const void *b_)
+{
+ const odp_port_t *ap = a_;
+ const odp_port_t *bp = b_;
+ uint32_t a = odp_to_u32(*ap);
+ uint32_t b = odp_to_u32(*bp);
+
+ return a < b ? -1 : a > b;
+}
+
static void
show_dpif(struct dpif *dpif, struct dpctl_params *dpctl_p)
{
}
}
+ odp_port_t *port_nos = NULL;
+ size_t allocated_port_nos = 0, n_port_nos = 0;
DPIF_PORT_FOR_EACH (&dpif_port, &dump, dpif) {
+ if (n_port_nos >= allocated_port_nos) {
+ port_nos = x2nrealloc(port_nos, &allocated_port_nos,
+ sizeof *port_nos);
+ }
+
+ port_nos[n_port_nos] = dpif_port.port_no;
+ n_port_nos++;
+ }
+
+ qsort(port_nos, n_port_nos, sizeof *port_nos, compare_port_nos);
+
+ for (int i = 0; i < n_port_nos; i++) {
+ if (dpif_port_query_by_number(dpif, port_nos[i], &dpif_port)) {
+ continue;
+ }
+
dpctl_print(dpctl_p, "\tport %u: %s",
dpif_port.port_no, dpif_port.name);
smap_init(&config);
error = netdev_get_config(netdev, &config);
if (!error) {
- const struct smap_node **nodes;
- size_t i;
-
- nodes = smap_sort(&config);
- for (i = 0; i < smap_count(&config); i++) {
- const struct smap_node *node = nodes[i];
- dpctl_print(dpctl_p, "%c %s=%s", i ? ',' : ':',
+ const struct smap_node **nodes = smap_sort(&config);
+ for (size_t j = 0; j < smap_count(&config); j++) {
+ const struct smap_node *node = nodes[j];
+ dpctl_print(dpctl_p, "%c %s=%s", j ? ',' : ':',
node->key, node->value);
}
free(nodes);
if (error) {
dpctl_print(dpctl_p, ", open failed (%s)",
ovs_strerror(error));
+ dpif_port_destroy(&dpif_port);
continue;
}
error = netdev_get_stats(netdev, &s);
ovs_strerror(error));
}
}
+ dpif_port_destroy(&dpif_port);
}
+
+ free(port_nos);
}
typedef void (*dps_for_each_cb)(struct dpif *, struct dpctl_params *);
goto out;
}
- /* Does not work for DPDK, since do not know which 'pmd' to apply the
- * operation. So, just uses PMD_ID_NULL. */
+ /* In case of PMD will be returned flow from first PMD thread with match. */
error = dpif_flow_get(dpif, NULL, 0, &ufid, PMD_ID_NULL, &buf, &flow);
if (error) {
dpctl_error(dpctl_p, error, "getting flow");