Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: Mesh: Remove msg_cache_next in rx ctx
Browse files Browse the repository at this point in the history
Since in bt_mesh_net_recv will call msg_cache_add
and if lpn reject this message, should remove this cache.

But this function sequentially and will not be interrupt
by any thread so, we no need a copy var to save this value.

Signed-off-by: Lingao Meng <[email protected]>
(cherry picked from commit 4f1e326)
  • Loading branch information
LingaoM authored and nordicjm committed Oct 31, 2022
1 parent 2c5d77f commit 15a5612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions subsys/bluetooth/mesh/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ static bool msg_cache_match(struct net_buf_simple *pdu)

static void msg_cache_add(struct bt_mesh_net_rx *rx)
{
rx->msg_cache_idx = msg_cache_next++;
msg_cache[rx->msg_cache_idx].src = rx->ctx.addr;
msg_cache[rx->msg_cache_idx].seq = rx->seq;
msg_cache_next %= ARRAY_SIZE(msg_cache);
msg_cache[msg_cache_next].src = rx->ctx.addr;
msg_cache[msg_cache_next].seq = rx->seq;
msg_cache_next++;
}

static void store_iv(bool only_duration)
Expand Down Expand Up @@ -848,9 +848,8 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi,
*/
if (bt_mesh_trans_recv(&buf, &rx) == -EAGAIN) {
BT_WARN("Removing rejected message from Network Message Cache");
msg_cache[rx.msg_cache_idx].src = BT_MESH_ADDR_UNASSIGNED;
/* Rewind the next index now that we're not using this entry */
msg_cache_next = rx.msg_cache_idx;
msg_cache[--msg_cache_next].src = BT_MESH_ADDR_UNASSIGNED;
}

/* Relay if this was a group/virtual address, or if the destination
Expand Down
1 change: 0 additions & 1 deletion subsys/bluetooth/mesh/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ struct bt_mesh_net_rx {
net_if:2, /* Network interface */
local_match:1, /* Matched a local element */
friend_match:1; /* Matched an LPN we're friends for */
uint16_t msg_cache_idx; /* Index of entry in message cache */
};

/* Encoding context for Network/Transport data */
Expand Down

0 comments on commit 15a5612

Please sign in to comment.