Skip to content

Commit 4f1e326

Browse files
LingaoMcarlescufi
authored andcommitted
Bluetooth: Mesh: Remove msg_cache_next in rx ctx
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]>
1 parent aa0c52f commit 4f1e326

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

subsys/bluetooth/mesh/net.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ static bool msg_cache_match(struct net_buf_simple *pdu)
147147

148148
static void msg_cache_add(struct bt_mesh_net_rx *rx)
149149
{
150-
rx->msg_cache_idx = msg_cache_next++;
151-
msg_cache[rx->msg_cache_idx].src = rx->ctx.addr;
152-
msg_cache[rx->msg_cache_idx].seq = rx->seq;
153150
msg_cache_next %= ARRAY_SIZE(msg_cache);
151+
msg_cache[msg_cache_next].src = rx->ctx.addr;
152+
msg_cache[msg_cache_next].seq = rx->seq;
153+
msg_cache_next++;
154154
}
155155

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

856855
/* Relay if this was a group/virtual address, or if the destination

subsys/bluetooth/mesh/net.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ struct bt_mesh_net_rx {
236236
net_if:2, /* Network interface */
237237
local_match:1, /* Matched a local element */
238238
friend_match:1; /* Matched an LPN we're friends for */
239-
uint16_t msg_cache_idx; /* Index of entry in message cache */
240239
};
241240

242241
/* Encoding context for Network/Transport data */

0 commit comments

Comments
 (0)