summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Chaudron <echaudro@redhat.com>2022-03-31 16:41:02 +0200
committerIlya Maximets <i.maximets@ovn.org>2022-04-04 22:52:12 +0200
commit9a67d883dc16ecd2f5ccdd7ab90f198833494cff (patch)
tree80169ac03f498793bf064d541d991389bd7d50cd
parent853a89c4fd93394d81e2d2020d5d4a4dd9469ba4 (diff)
downloadopenvswitch-9a67d883dc16ecd2f5ccdd7ab90f198833494cff.tar.gz
dpif-netdev: Fix dp_netdev_get_pmd() function getting correct core_id.
The dp_netdev_get_pmd() function is using only the hash of the core_id to get the pmd structure. So in case of hash collisions, the wrong pmd is returned. This patch is fixing this by checking for the correct core_id using the CMAP_FOR_EACH_WITH_HASH macro. Fixes: 65f13b50c5aa ("dpif-netdev: Create multiple pmd threads by default.") Signed-off-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r--lib/dpif-netdev.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 57cb73e75..676434308 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -7367,15 +7367,15 @@ static struct dp_netdev_pmd_thread *
dp_netdev_get_pmd(struct dp_netdev *dp, unsigned core_id)
{
struct dp_netdev_pmd_thread *pmd;
- const struct cmap_node *pnode;
- pnode = cmap_find(&dp->poll_threads, hash_int(core_id, 0));
- if (!pnode) {
- return NULL;
+ CMAP_FOR_EACH_WITH_HASH (pmd, node, hash_int(core_id, 0),
+ &dp->poll_threads) {
+ if (pmd->core_id == core_id) {
+ return dp_netdev_pmd_try_ref(pmd) ? pmd : NULL;
+ }
}
- pmd = CONTAINER_OF(pnode, struct dp_netdev_pmd_thread, node);
- return dp_netdev_pmd_try_ref(pmd) ? pmd : NULL;
+ return NULL;
}
/* Sets the 'struct dp_netdev_pmd_thread' for non-pmd threads. */