mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
netdev-dpdk: Fix race condition in mempool information dump.
Currently it is possible to call netdev-dpdk/get-mempool-info before a mempool as been created. This can happen because a device is added to the netdev_shash before a mempool is allocated for it, which results in a segmentation fault. Now we check for a NULL value before attempting to dereference it. Fixes: be4817331071 ("netdev-dpdk: Add debug appctl to get mempool information.") Signed-off-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
parent
a5023d597c
commit
9f0c6e16e3
@ -4637,10 +4637,11 @@ netdev_dpdk_get_mempool_info(struct unixctl_conn *conn,
|
|||||||
int argc, const char *argv[],
|
int argc, const char *argv[],
|
||||||
void *aux OVS_UNUSED)
|
void *aux OVS_UNUSED)
|
||||||
{
|
{
|
||||||
size_t size;
|
|
||||||
FILE *stream;
|
|
||||||
char *response = NULL;
|
|
||||||
struct netdev *netdev = NULL;
|
struct netdev *netdev = NULL;
|
||||||
|
const char *error = NULL;
|
||||||
|
char *response = NULL;
|
||||||
|
FILE *stream;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
netdev = netdev_from_name(argv[1]);
|
netdev = netdev_from_name(argv[1]);
|
||||||
@ -4664,10 +4665,14 @@ netdev_dpdk_get_mempool_info(struct unixctl_conn *conn,
|
|||||||
ovs_mutex_lock(&dev->mutex);
|
ovs_mutex_lock(&dev->mutex);
|
||||||
ovs_mutex_lock(&dpdk_mp_mutex);
|
ovs_mutex_lock(&dpdk_mp_mutex);
|
||||||
|
|
||||||
rte_mempool_dump(stream, dev->dpdk_mp->mp);
|
if (dev->dpdk_mp) {
|
||||||
fprintf(stream, " count: avail (%u), in use (%u)\n",
|
rte_mempool_dump(stream, dev->dpdk_mp->mp);
|
||||||
rte_mempool_avail_count(dev->dpdk_mp->mp),
|
fprintf(stream, " count: avail (%u), in use (%u)\n",
|
||||||
rte_mempool_in_use_count(dev->dpdk_mp->mp));
|
rte_mempool_avail_count(dev->dpdk_mp->mp),
|
||||||
|
rte_mempool_in_use_count(dev->dpdk_mp->mp));
|
||||||
|
} else {
|
||||||
|
error = "Not allocated";
|
||||||
|
}
|
||||||
|
|
||||||
ovs_mutex_unlock(&dpdk_mp_mutex);
|
ovs_mutex_unlock(&dpdk_mp_mutex);
|
||||||
ovs_mutex_unlock(&dev->mutex);
|
ovs_mutex_unlock(&dev->mutex);
|
||||||
@ -4679,7 +4684,11 @@ netdev_dpdk_get_mempool_info(struct unixctl_conn *conn,
|
|||||||
|
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
|
|
||||||
unixctl_command_reply(conn, response);
|
if (error) {
|
||||||
|
unixctl_command_reply_error(conn, error);
|
||||||
|
} else {
|
||||||
|
unixctl_command_reply(conn, response);
|
||||||
|
}
|
||||||
out:
|
out:
|
||||||
free(response);
|
free(response);
|
||||||
netdev_close(netdev);
|
netdev_close(netdev);
|
||||||
|
@ -88,6 +88,12 @@ ADD_VHOST_USER_CLIENT_PORT([br10], [dpdkvhostuserclient0], [$OVS_RUNDIR/dpdkvhos
|
|||||||
AT_CHECK([ovs-vsctl show], [], [stdout])
|
AT_CHECK([ovs-vsctl show], [], [stdout])
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
dnl Check that no mempool was allocated.
|
||||||
|
AT_CHECK([ovs-appctl netdev-dpdk/get-mempool-info dpdkvhostuserclient0], [2], [], [dnl
|
||||||
|
Not allocated
|
||||||
|
ovs-appctl: ovs-vswitchd: server returned an error
|
||||||
|
])
|
||||||
|
|
||||||
dnl Clean up
|
dnl Clean up
|
||||||
AT_CHECK([ovs-vsctl del-port br10 dpdkvhostuserclient0], [], [stdout], [stderr])
|
AT_CHECK([ovs-vsctl del-port br10 dpdkvhostuserclient0], [], [stdout], [stderr])
|
||||||
OVS_DPDK_STOP_VSWITCHD(["dnl
|
OVS_DPDK_STOP_VSWITCHD(["dnl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user