diff options
author | Brian Gix <brian.gix@intel.com> | 2020-01-30 10:59:23 -0800 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2020-01-30 11:03:47 -0800 |
commit | 8457e6a3ad147c1167862f148cbbf281d879e874 (patch) | |
tree | 2cb7ae100b8b77089b0503527deb4629e82675fb /mesh/net.c | |
parent | 17e97efc3fc48116509e97670288af5827b81747 (diff) | |
download | bluez-8457e6a3ad147c1167862f148cbbf281d879e874.tar.gz |
mesh: Add NVM storage of Replay Protection
Mesh specification requires that Replay Protection be preserved
across node restarts. This adds that storage in
<node_uuid>/rpl/<iv_index>/<src>
Realtime access remains in an l_queue structure, and stored as
messages are processed.
Diffstat (limited to 'mesh/net.c')
-rw-r--r-- | mesh/net.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/mesh/net.c b/mesh/net.c index 9567d947e..19f3b87b7 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -36,6 +36,7 @@ #include "mesh/mesh-config.h" #include "mesh/model.h" #include "mesh/appkey.h" +#include "mesh/rpl.h" #define abs_diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a)) @@ -256,12 +257,6 @@ struct net_beacon_data { bool processed; }; -struct mesh_rpl { - uint32_t iv_index; - uint32_t seq; - uint16_t src; -}; - #define FAST_CACHE_SIZE 8 static struct l_queue *fast_cache; static struct l_queue *nets; @@ -2714,6 +2709,9 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index, struct mesh_config *cfg = node_config_get(net->node); mesh_config_write_iv_index(cfg, iv_index, ivu); + + /* Cleanup Replay Protection List NVM */ + rpl_init(net->node, iv_index); } net->iv_index = iv_index; @@ -3771,8 +3769,11 @@ bool net_msg_in_replay_cache(struct mesh_net *net, uint16_t idx, if (!net || !net->node) return true; - if (!net->replay_cache) + if (!net->replay_cache) { net->replay_cache = l_queue_new(); + rpl_init(net->node, net->iv_index); + rpl_get_list(net->node, net->replay_cache); + } l_debug("Test Replay src: %4.4x seq: %6.6x iv: %8.8x", src, seq, iv_index); @@ -3784,6 +3785,7 @@ bool net_msg_in_replay_cache(struct mesh_net *net, uint16_t idx, if (iv_index > rpe->iv_index) { rpe->seq = seq; rpe->iv_index = iv_index; + rpl_put_entry(net->node, src, iv_index, seq); return false; } @@ -3799,6 +3801,8 @@ bool net_msg_in_replay_cache(struct mesh_net *net, uint16_t idx, rpe->seq = seq; + rpl_put_entry(net->node, src, iv_index, seq); + return false; } @@ -3813,6 +3817,9 @@ bool net_msg_in_replay_cache(struct mesh_net *net, uint16_t idx, return true; } + if (!rpl_put_entry(net->node, src, iv_index, seq)) + return true; + rpe = l_new(struct mesh_rpl, 1); rpe->src = src; rpe->seq = seq; |