2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev-vport: Don't return static data in netdev_vport_get_dpif_port().

Returning a static data buffer makes code more brittle and definitely
not thread-safe, so this commit switches to using a caller-provided
buffer instead.

Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2013-05-01 11:05:28 -07:00
parent 3efb60637b
commit 3aa30359b1
5 changed files with 42 additions and 13 deletions

View File

@@ -440,8 +440,11 @@ dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev,
uint32_t *port_nop)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
char namebuf[NETDEV_VPORT_NAME_BUFSIZE];
const char *dpif_port;
int port_no;
dpif_port = netdev_vport_get_dpif_port(netdev, namebuf, sizeof namebuf);
if (*port_nop != UINT32_MAX) {
if (*port_nop >= MAX_PORTS) {
return EFBIG;
@@ -450,12 +453,11 @@ dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev,
}
port_no = *port_nop;
} else {
port_no = choose_port(dp, netdev_vport_get_dpif_port(netdev));
port_no = choose_port(dp, dpif_port);
}
if (port_no >= 0) {
*port_nop = port_no;
return do_add_port(dp, netdev_vport_get_dpif_port(netdev),
netdev_get_type(netdev), port_no);
return do_add_port(dp, dpif_port, netdev_get_type(netdev), port_no);
}
return EFBIG;
}
@@ -1079,6 +1081,7 @@ dpif_netdev_run(struct dpif *dpif)
dp_netdev_port_input(dp, port, &packet, 0, 0, NULL);
} else if (error != EAGAIN && error != EOPNOTSUPP) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
netdev_get_name(port->netdev), strerror(error));
}