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:10:12 +0200
commit37df323243de5481bc9aed52d6eac88af54e7d60 (patch)
treed9e3919e57d5ea0a693c4d67d299c2ecfadc2191
parent0429ac903af7694d009121b96c13686fd1118dd5 (diff)
downloadopenvswitch-37df323243de5481bc9aed52d6eac88af54e7d60.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 616648ab7..ceebba3c4 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -6419,15 +6419,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. */