diff options
author | Eelco Chaudron <echaudro@redhat.com> | 2022-03-31 16:41:02 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-04-04 22:10:10 +0200 |
commit | d05ccf288d1728323c2557ed0cffa91484f3a78f (patch) | |
tree | 4f9e6424dd4c2a4c63c8a8f8ee916c1cbba348e7 | |
parent | 79e291f9831aebf045202e47cdd6415bfe09ce0b (diff) | |
download | openvswitch-d05ccf288d1728323c2557ed0cffa91484f3a78f.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.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 8f0536605..51c276b1d 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -7369,15 +7369,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. */ |