Skip to content

Commit e4522c0

Browse files
tatyana-enrleon
authored andcommitted
RDMA/irdma: Add ipv4 check to irdma_find_listener()
Add ipv4 check to irdma_find_listener(). Otherwise the function incorrectly finds and returns a listener with a different addr family for the zero IP addr, if a listener with a zero IP addr and the same port as the one searched for has already been created. Fixes: 146b975 ("RDMA/irdma: Add connection manager") Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com> Link: https://lore.kernel.org/r/20230315145231.931-5-shiraz.saleem@intel.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 8385a87 commit e4522c0

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

  • drivers/infiniband/hw/irdma

drivers/infiniband/hw/irdma/cm.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,13 +1458,15 @@ static int irdma_send_fin(struct irdma_cm_node *cm_node)
14581458
* irdma_find_listener - find a cm node listening on this addr-port pair
14591459
* @cm_core: cm's core
14601460
* @dst_addr: listener ip addr
1461+
* @ipv4: flag indicating IPv4 when true
14611462
* @dst_port: listener tcp port num
14621463
* @vlan_id: virtual LAN ID
14631464
* @listener_state: state to match with listen node's
14641465
*/
14651466
static struct irdma_cm_listener *
1466-
irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port,
1467-
u16 vlan_id, enum irdma_cm_listener_state listener_state)
1467+
irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, bool ipv4,
1468+
u16 dst_port, u16 vlan_id,
1469+
enum irdma_cm_listener_state listener_state)
14681470
{
14691471
struct irdma_cm_listener *listen_node;
14701472
static const u32 ip_zero[4] = { 0, 0, 0, 0 };
@@ -1477,7 +1479,7 @@ irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, u16 dst_port,
14771479
list_for_each_entry (listen_node, &cm_core->listen_list, list) {
14781480
memcpy(listen_addr, listen_node->loc_addr, sizeof(listen_addr));
14791481
listen_port = listen_node->loc_port;
1480-
if (listen_port != dst_port ||
1482+
if (listen_node->ipv4 != ipv4 || listen_port != dst_port ||
14811483
!(listener_state & listen_node->listener_state))
14821484
continue;
14831485
/* compare node pair, return node handle if a match */
@@ -2902,9 +2904,10 @@ irdma_make_listen_node(struct irdma_cm_core *cm_core,
29022904
unsigned long flags;
29032905

29042906
/* cannot have multiple matching listeners */
2905-
listener = irdma_find_listener(cm_core, cm_info->loc_addr,
2906-
cm_info->loc_port, cm_info->vlan_id,
2907-
IRDMA_CM_LISTENER_EITHER_STATE);
2907+
listener =
2908+
irdma_find_listener(cm_core, cm_info->loc_addr, cm_info->ipv4,
2909+
cm_info->loc_port, cm_info->vlan_id,
2910+
IRDMA_CM_LISTENER_EITHER_STATE);
29082911
if (listener &&
29092912
listener->listener_state == IRDMA_CM_LISTENER_ACTIVE_STATE) {
29102913
refcount_dec(&listener->refcnt);
@@ -3153,6 +3156,7 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf)
31533156

31543157
listener = irdma_find_listener(cm_core,
31553158
cm_info.loc_addr,
3159+
cm_info.ipv4,
31563160
cm_info.loc_port,
31573161
cm_info.vlan_id,
31583162
IRDMA_CM_LISTENER_ACTIVE_STATE);

0 commit comments

Comments
 (0)