static bool
get_port_number(struct dpif *dpif, const char *name, uint16_t *port)
{
- struct odp_port *ports;
- size_t n_ports;
- size_t i;
+ struct odp_port odp_port;
- query_ports(dpif, &ports, &n_ports);
- for (i = 0; i < n_ports; i++) {
- if (!strcmp(name, ports[i].devname)) {
- *port = ports[i].port;
- free(ports);
- return true;
- }
+ if (!dpif_port_query_by_name(dpif, name, &odp_port)) {
+ *port = odp_port.port;
+ return true;
+ } else {
+ ovs_error(0, "no port named %s", name);
+ return false;
}
- free(ports);
- ovs_error(0, "no port named %s", name);
- return false;
}
static void
query_ports(dpif, &ports, &n_ports);
for (i = 0; i < n_ports; i++) {
const struct odp_port *p = &ports[i];
+ struct ds ds;
printf("\tport %u: %s", p->port, p->devname);
- if (strcmp(p->type, "system")) {
- printf(" (%s)", p->type);
- }
- printf("\n");
+
+ ds_init(&ds);
+ format_odp_port_type(&ds, p);
+ printf("%s\n", ds_cstr(&ds));
+ ds_destroy(&ds);
}
free(ports);
dpif_close(dpif);
ds_init(&ds);
for (i = 0; i < n_flows; i++) {
struct odp_flow *f = &flows[i];
- enum { MAX_ACTIONS = 4096 / sizeof(union odp_action) };
- union odp_action actions[MAX_ACTIONS];
+ enum { MAX_ACTIONS = 4096 }; /* An arbitrary but large number. */
+ struct nlattr actions[MAX_ACTIONS];
f->actions = actions;
- f->n_actions = MAX_ACTIONS;
+ f->actions_len = sizeof actions;
if (!dpif_flow_get(dpif, f)) {
ds_clear(&ds);
format_odp_flow(&ds, f);