ds_put_cstr(ds, ", actions:");
format_odp_actions(ds, f->actions, f->actions_len);
}
-
-void
-format_odp_port_type(struct ds *ds, const struct odp_port *p)
-{
- if (!strcmp(p->type, "gre")
- || !strcmp(p->type, "ipsec_gre")
- || !strcmp(p->type, "capwap")) {
- const struct tnl_port_config *config;
-
- config = (struct tnl_port_config *)p->config;
-
- ds_put_format(ds, " (%s: remote_ip="IP_FMT,
- p->type, IP_ARGS(&config->daddr));
-
- if (config->saddr) {
- ds_put_format(ds, ", local_ip="IP_FMT, IP_ARGS(&config->saddr));
- }
-
- if (config->in_key) {
- ds_put_format(ds, ", in_key=%#"PRIx64, ntohll(config->in_key));
- }
-
- ds_put_cstr(ds, ")");
- } else if (!strcmp(p->type, "patch")) {
- ds_put_format(ds, " (%s: peer=%s)", p->type, (char *)p->config);
- } else if (strcmp(p->type, "system")) {
- ds_put_format(ds, " (%s)", p->type);
- }
-}
\f
/* Returns the correct length of the payload for a flow key attribute of the
* specified 'type', or -1 if 'type' is unknown. */
size_t actions_len);
void format_odp_flow_stats(struct ds *, const struct odp_flow_stats *);
void format_odp_flow(struct ds *, const struct odp_flow *);
-void format_odp_port_type(struct ds *, const struct odp_port *);
/* By my calculations currently the longest valid nlattr-formatted flow key is
* 80 bytes long, so this leaves some safety margin.
stats.max_miss_queue, stats.max_action_queue);
}
DPIF_PORT_FOR_EACH (&odp_port, &dump, dpif) {
- struct ds ds;
-
printf("\tport %u: %s", odp_port.port, odp_port.devname);
- ds_init(&ds);
- format_odp_port_type(&ds, &odp_port);
- printf("%s\n", ds_cstr(&ds));
- ds_destroy(&ds);
+ if (strcmp(odp_port.type, "system")) {
+ struct netdev_options netdev_options;
+ struct netdev *netdev;
+ int error;
+
+ printf (" (%s", odp_port.type);
+
+ netdev_options.name = odp_port.devname;
+ netdev_options.type = odp_port.type;
+ netdev_options.args = NULL;
+ netdev_options.ethertype = NETDEV_ETH_TYPE_NONE;
+ error = netdev_open(&netdev_options, &netdev);
+ if (!error) {
+ const struct shash_node **nodes;
+ const struct shash *config;
+ size_t i;
+
+ config = netdev_get_config(netdev);
+ nodes = shash_sort(config);
+ for (i = 0; i < shash_count(config); i++) {
+ const struct shash_node *node = nodes[i];
+ printf("%c %s=%s", i ? ',' : ':',
+ node->name, (char *) node->data);
+ }
+ free(nodes);
+
+ netdev_close(netdev);
+ } else {
+ printf(": open failed (%s)", strerror(error));
+ }
+ putchar(')');
+ }
+ putchar('\n');
}
dpif_close(dpif);
}