mirror of
https://github.com/openvswitch/ovs
synced 2025-09-04 00:05:15 +00:00
ovs-dpctl: Use netdev_get_config() to print vport configurations.
This is cleaner than parsing "odp_port"s directly. It takes one step toward eliminating use of odp_port from any userspace code outside of lib/netdev-vport.c and lib/dpif-linux.c. Reviewed by Justin Pettit.
This commit is contained in:
@@ -201,35 +201,6 @@ format_odp_flow(struct ds *ds, const struct odp_flow *f)
|
|||||||
ds_put_cstr(ds, ", actions:");
|
ds_put_cstr(ds, ", actions:");
|
||||||
format_odp_actions(ds, f->actions, f->actions_len);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns the correct length of the payload for a flow key attribute of the
|
/* Returns the correct length of the payload for a flow key attribute of the
|
||||||
* specified 'type', or -1 if 'type' is unknown. */
|
* specified 'type', or -1 if 'type' is unknown. */
|
||||||
|
@@ -62,7 +62,6 @@ void format_odp_actions(struct ds *, const struct nlattr *odp_actions,
|
|||||||
size_t actions_len);
|
size_t actions_len);
|
||||||
void format_odp_flow_stats(struct ds *, const struct odp_flow_stats *);
|
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_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
|
/* By my calculations currently the longest valid nlattr-formatted flow key is
|
||||||
* 80 bytes long, so this leaves some safety margin.
|
* 80 bytes long, so this leaves some safety margin.
|
||||||
|
@@ -351,14 +351,41 @@ show_dpif(struct dpif *dpif)
|
|||||||
stats.max_miss_queue, stats.max_action_queue);
|
stats.max_miss_queue, stats.max_action_queue);
|
||||||
}
|
}
|
||||||
DPIF_PORT_FOR_EACH (&odp_port, &dump, dpif) {
|
DPIF_PORT_FOR_EACH (&odp_port, &dump, dpif) {
|
||||||
struct ds ds;
|
|
||||||
|
|
||||||
printf("\tport %u: %s", odp_port.port, odp_port.devname);
|
printf("\tport %u: %s", odp_port.port, odp_port.devname);
|
||||||
|
|
||||||
ds_init(&ds);
|
if (strcmp(odp_port.type, "system")) {
|
||||||
format_odp_port_type(&ds, &odp_port);
|
struct netdev_options netdev_options;
|
||||||
printf("%s\n", ds_cstr(&ds));
|
struct netdev *netdev;
|
||||||
ds_destroy(&ds);
|
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);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user