From a25ef6092c32d3c85aba2e395c5ad2bc6257b15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Wed, 30 Jan 2019 15:14:24 +0100 Subject: [PATCH] mesh: Fixes existing friend lookup in Friend Request handling Currently, when handling a Friend Request message with `prev_addr` set, we look up existing friend entry using `prev_addr` as the address. However, `prev_addr` is the address of the requesting node's previous friend, NOT the address of the requesting node itself. Therefore, we should always look up existing friend entry using `rx->ctx.addr` as the address. --- nimble/host/mesh/src/friend.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c index 18cb3c1f0..9291a8874 100644 --- a/nimble/host/mesh/src/friend.c +++ b/nimble/host/mesh/src/friend.c @@ -858,13 +858,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) } old_friend = sys_be16_to_cpu(msg->prev_addr); - if (BT_MESH_ADDR_IS_UNICAST(old_friend)) { - frnd = bt_mesh_friend_find(rx->sub->net_idx, old_friend, - true, false); - } else { - frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, - true, false); - } + frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false); if (frnd) { BT_WARN("Existing LPN re-requesting Friendship");