if (ioctl(dpif->fd, ODP_GET_LISTEN_MASK, &listen_mask)) {
error = errno;
if (error != ENODEV) {
- VLOG_WARN("dp%u: probe returned unexpected error: %s",
- dpif->minor, strerror(error));
+ VLOG_WARN("%s: probe returned unexpected error: %s",
+ dpif_name(dpif), strerror(error));
}
dpif_close(dpif);
return error;
dpif_close(struct dpif *dpif)
{
if (dpif) {
+ free(dpif->name);
+ dpif->name = NULL;
close(dpif->fd);
dpif->fd = -1;
}
int error = ioctl(dpif->fd, cmd, arg) ? errno : 0;
if (cmd_name) {
if (error) {
- VLOG_WARN_RL(&error_rl, "dp%u: ioctl(%s) failed (%s)",
- dpif->minor, cmd_name, strerror(error));
+ VLOG_WARN_RL(&error_rl, "%s: ioctl(%s) failed (%s)",
+ dpif_name(dpif), cmd_name, strerror(error));
} else {
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: ioctl(%s): success",
- dpif->minor, cmd_name);
+ VLOG_DBG_RL(&dpmsg_rl, "%s: ioctl(%s): success",
+ dpif_name(dpif), cmd_name);
}
}
return error;
}
}
+const char *
+dpif_name(const struct dpif *dpif)
+{
+ return dpif->name;
+}
+
int
dpif_delete(struct dpif *dpif)
{
port.port = port_no;
port.flags = flags;
if (!ioctl(dpif->fd, ODP_PORT_ADD, &port)) {
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: added %s as port %"PRIu16,
- dpif->minor, devname, port_no);
+ VLOG_DBG_RL(&dpmsg_rl, "%s: added %s as port %"PRIu16,
+ dpif_name(dpif), devname, port_no);
return 0;
} else {
- VLOG_WARN_RL(&error_rl, "dp%u: failed to add %s as port "
- "%"PRIu16": %s", dpif->minor, devname, port_no,
- strerror(errno));
+ VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port %"PRIu16": %s",
+ dpif_name(dpif), devname, port_no, strerror(errno));
return errno;
}
}
memset(port, 0, sizeof *port);
port->port = port_no;
if (!ioctl(dpif->fd, ODP_PORT_QUERY, port)) {
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: port %"PRIu16" is device %s",
- dpif->minor, port_no, port->devname);
+ VLOG_DBG_RL(&dpmsg_rl, "%s: port %"PRIu16" is device %s",
+ dpif_name(dpif), port_no, port->devname);
return 0;
} else {
- VLOG_WARN_RL(&error_rl, "dp%u: failed to query port %"PRIu16": %s",
- dpif->minor, port_no, strerror(errno));
+ VLOG_WARN_RL(&error_rl, "%s: failed to query port %"PRIu16": %s",
+ dpif_name(dpif), port_no, strerror(errno));
return errno;
}
}
memset(port, 0, sizeof *port);
strncpy(port->devname, devname, sizeof port->devname);
if (!ioctl(dpif->fd, ODP_PORT_QUERY, port)) {
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: device %s is on port %"PRIu16,
- dpif->minor, devname, port->port);
+ VLOG_DBG_RL(&dpmsg_rl, "%s: device %s is on port %"PRIu16,
+ dpif_name(dpif), devname, port->port);
return 0;
} else {
- VLOG_WARN_RL(&error_rl, "dp%u: failed to query port %s: %s",
- dpif->minor, devname, strerror(errno));
+ VLOG_WARN_RL(&error_rl, "%s: failed to query port %s: %s",
+ dpif_name(dpif), devname, strerror(errno));
return errno;
}
}
const union odp_action *actions, size_t n_actions)
{
struct ds ds = DS_EMPTY_INITIALIZER;
- ds_put_format(&ds, "dp%u: ", dpif->minor);
+ ds_put_format(&ds, "%s: ", dpif_name(dpif));
if (error) {
ds_put_cstr(&ds, "failed to ");
}
error = do_ioctl(dpif, ODP_FLOW_LIST, NULL, &fv);
if (error) {
*n_out = 0;
- VLOG_WARN_RL(&error_rl, "dp%u: flow list failed (%s)",
- dpif->minor, strerror(error));
+ VLOG_WARN_RL(&error_rl, "%s: flow list failed (%s)",
+ dpif_name(dpif), strerror(error));
} else {
COVERAGE_ADD(dpif_flow_query_list_n, fv.n_flows);
*n_out = fv.n_flows;
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: listed %zu flows", dpif->minor, *n_out);
+ VLOG_DBG_RL(&dpmsg_rl, "%s: listed %zu flows",
+ dpif_name(dpif), *n_out);
}
return error;
}
}
if (stats.n_flows != n_flows) {
- VLOG_WARN_RL(&error_rl, "dp%u: datapath stats reported %"PRIu32" "
+ VLOG_WARN_RL(&error_rl, "%s: datapath stats reported %"PRIu32" "
"flows but flow listing reported %zu",
- dpif->minor, stats.n_flows, n_flows);
+ dpif_name(dpif), stats.n_flows, n_flows);
}
*flowsp = flows;
*np = n_flows;
if (!(error ? VLOG_DROP_WARN(&error_rl) : VLOG_DROP_DBG(&dpmsg_rl))) {
struct ds ds = DS_EMPTY_INITIALIZER;
char *packet = ofp_packet_to_string(buf->data, buf->size, buf->size);
- ds_put_format(&ds, "dp%u: execute ", dpif->minor);
+ ds_put_format(&ds, "%s: execute ", dpif_name(dpif));
format_odp_actions(&ds, actions, n_actions);
if (error) {
ds_put_format(&ds, " failed (%s)", strerror(error));
if (retval < 0) {
error = errno;
if (error != EAGAIN) {
- VLOG_WARN_RL(&error_rl, "dp%u: read failed: %s",
- dpif->minor, strerror(error));
+ VLOG_WARN_RL(&error_rl, "%s: read failed: %s",
+ dpif_name(dpif), strerror(error));
}
} else if (retval >= sizeof(struct odp_msg)) {
struct odp_msg *msg = buf->data;
void *payload = msg + 1;
size_t length = buf->size - sizeof *msg;
char *s = ofp_packet_to_string(payload, length, length);
- VLOG_DBG_RL(&dpmsg_rl, "dp%u: received %s message of length "
- "%zu on port %"PRIu16": %s", dpif->minor,
+ VLOG_DBG_RL(&dpmsg_rl, "%s: received %s message of length "
+ "%zu on port %"PRIu16": %s", dpif_name(dpif),
(msg->type == _ODPL_MISS_NR ? "miss"
: msg->type == _ODPL_ACTION_NR ? "action"
: "<unknown>"),
COVERAGE_INC(dpif_recv);
return 0;
} else {
- VLOG_WARN_RL(&error_rl, "dp%u: discarding message truncated "
+ VLOG_WARN_RL(&error_rl, "%s: discarding message truncated "
"from %zu bytes to %d",
- dpif->minor, msg->length, retval);
+ dpif_name(dpif), msg->length, retval);
error = ERANGE;
}
} else if (!retval) {
- VLOG_WARN_RL(&error_rl, "dp%u: unexpected end of file", dpif->minor);
+ VLOG_WARN_RL(&error_rl, "%s: unexpected end of file", dpif_name(dpif));
error = EPROTO;
} else {
VLOG_WARN_RL(&error_rl,
- "dp%u: discarding too-short message (%d bytes)",
- dpif->minor, retval);
+ "%s: discarding too-short message (%d bytes)",
+ dpif_name(dpif), retval);
error = ERANGE;
}
}
free(fn);
+ dpif->name = xasprintf("dp%u", dpif->minor);
dpif->minor = minor;
dpif->fd = fd;
return 0;
for (j = 0; j < port->n_ifaces; j++) {
struct iface *iface = port->ifaces[j];
if (iface->dp_ifidx < 0) {
- VLOG_ERR("%s interface not in dp%u, ignoring",
- iface->name, dpif_id(&br->dpif));
+ VLOG_ERR("%s interface not in datapath %s, ignoring",
+ iface->name, dpif_name(&br->dpif));
} else {
if (iface->dp_ifidx != ODPP_LOCAL) {
svec_add(svec, iface->name);
&& strcmp(p->devname, br->name)) {
int retval = dpif_port_del(&br->dpif, p->port);
if (retval) {
- VLOG_ERR("failed to remove %s interface from dp%u: %s",
- p->devname, dpif_id(&br->dpif), strerror(retval));
+ VLOG_ERR("failed to remove %s interface from %s: %s",
+ p->devname, dpif_name(&br->dpif),
+ strerror(retval));
}
}
}
internal ? ODP_PORT_INTERNAL : 0);
if (error != EEXIST) {
if (next_port_no >= 256) {
- VLOG_ERR("ran out of valid port numbers on dp%u",
- dpif_id(&br->dpif));
+ VLOG_ERR("ran out of valid port numbers on %s",
+ dpif_name(&br->dpif));
goto out;
}
if (error) {
- VLOG_ERR("failed to add %s interface to dp%u: %s",
- if_name, dpif_id(&br->dpif), strerror(error));
+ VLOG_ERR("failed to add %s interface to %s: %s",
+ if_name, dpif_name(&br->dpif),
+ strerror(error));
}
break;
}
for (j = 0; j < port->n_ifaces; ) {
struct iface *iface = port->ifaces[j];
if (iface->dp_ifidx < 0) {
- VLOG_ERR("%s interface not in dp%u, dropping",
- iface->name, dpif_id(&br->dpif));
+ VLOG_ERR("%s interface not in %s, dropping",
+ iface->name, dpif_name(&br->dpif));
iface_destroy(iface);
} else {
if (iface->dp_ifidx == ODPP_LOCAL) {
local_iface = iface;
}
- VLOG_DBG("dp%u has interface %s on port %d",
- dpif_id(&br->dpif), iface->name, iface->dp_ifidx);
+ VLOG_DBG("%s has interface %s on port %d",
+ dpif_name(&br->dpif),
+ iface->name, iface->dp_ifidx);
j++;
}
}
list_push_back(&all_bridges, &br->node);
- VLOG_INFO("created bridge %s on dp%u", br->name, dpif_id(&br->dpif));
+ VLOG_INFO("created bridge %s on %s", br->name, dpif_name(&br->dpif));
return br;
}
list_remove(&br->node);
error = dpif_delete(&br->dpif);
if (error && error != ENOENT) {
- VLOG_ERR("failed to delete dp%u: %s",
- dpif_id(&br->dpif), strerror(error));
+ VLOG_ERR("failed to delete %s: %s",
+ dpif_name(&br->dpif), strerror(error));
}
dpif_close(&br->dpif);
ofproto_destroy(br->ofproto);
struct iface *iface = iface_lookup(br, p->devname);
if (iface) {
if (iface->dp_ifidx >= 0) {
- VLOG_WARN("dp%u reported interface %s twice",
- dpif_id(&br->dpif), p->devname);
+ VLOG_WARN("%s reported interface %s twice",
+ dpif_name(&br->dpif), p->devname);
} else if (iface_from_dp_ifidx(br, p->port)) {
- VLOG_WARN("dp%u reported interface %"PRIu16" twice",
- dpif_id(&br->dpif), p->port);
+ VLOG_WARN("%s reported interface %"PRIu16" twice",
+ dpif_name(&br->dpif), p->port);
} else {
port_array_set(&br->ifaces, p->port, iface);
iface->dp_ifidx = p->port;