Skip to contentSkip to conversation

mesh: Refactor Secure Network Beaconing

PATCH Superseded Brian Gix 1 participant 1 message Dec 12, 2019 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 mesh: Refactor Secure Network Beaconing

The daemon handles multiple nodes, that may or may not be on the same mesh network. While each node my be seperately configured to beacon or not beacon, there is nothing gained (except redundent traffic) for each node to beacon seperately. Beaconing is therefore centralized with the Network Key the SNB represents, with each *received* beacon delivered to each node. But for SNBs generated, we keep a count of how many nodes want beacons sent for a specific key. If 1 or more, we beacon, if 0 nodes want the beacon sent, then we do not beacon.

---
 mesh/mesh-io.c  |   3 +
 mesh/net-keys.c | 177 ++++++++++++++++++++++-
 mesh/net-keys.h |   8 +
 mesh/net.c      | 377 +++++++++++++++---------------------------------
 mesh/net.h      |   5 +-
 5 files changed, 299 insertions(+), 271 deletions(-)
mesh/mesh-io.c +3 -0
index 95a99b6a5..1ab173d9c 100644
@@ -171,6 +171,9 @@ bool mesh_io_send(struct mesh_io *io, struct mesh_io_send_info *info,
 {
 	io = l_queue_find(io_list, match_by_io, io);
 
+	if (!io)
+		io = l_queue_peek_head(io_list);
+
 	if (io && io->api && io->api->send)
 		return io->api->send(io, info, data, len);
 
mesh/net-keys.c +170 -7

210 lines not on this page · raw message

mesh/net-keys.h +8 -0
index d54c52156..3c2c4d0da 100644
@@ -17,6 +17,10 @@
  *
  */
 
+#define BEACON_TYPE_SNB		0x01
+#define KEY_REFRESH		0x01
+#define IV_INDEX_UPDATE		0x02
+
 bool net_key_confirm(uint32_t id, const uint8_t master[16]);
 bool net_key_retrieve(uint32_t id, uint8_t *master);
 uint32_t net_key_add(const uint8_t master[16]);
@@ -31,3 +35,7 @@ bool net_key_snb_check(uint32_t id, uint32_t iv_index, bool kr, bool ivu,
 								uint64_t cmac);
 bool net_key_snb_compose(uint32_t id, uint32_t iv_index, bool kr, bool ivu,
 								uint8_t *snb);
+void net_key_beacon_seen(uint32_t id);
+void net_key_beacon_enable(uint32_t id);
+bool net_key_beacon_refresh(uint32_t id, uint32_t iv_index, bool kr, bool ivu);
+void net_key_beacon_disable(uint32_t id);
mesh/net.c +115 -262

562 lines not on this page · raw message

mesh/net.h +3 -2
index fe4e0b653..07b87830d 100644
@@ -117,6 +117,9 @@ struct mesh_node;
 #define FRND_OPCODE(x) \
 		((x) >= NET_OP_FRND_POLL && (x) <= NET_OP_FRND_CLEAR_CONFIRM)
 
+#define DEFAULT_MIN_DELAY		0
+#define DEFAULT_MAX_DELAY		25
+
 struct mesh_net_addr_range {
 	uint16_t low;
 	uint16_t high;
@@ -276,8 +279,6 @@ void mesh_net_set_frnd_seq(struct mesh_net *net, bool seq);
 uint16_t mesh_net_get_address(struct mesh_net *net);
 bool mesh_net_register_unicast(struct mesh_net *net,
 					uint16_t unicast, uint8_t num_ele);
-bool mesh_net_set_friend(struct mesh_net *net, uint16_t friend_addr);
-uint16_t mesh_net_get_friend(struct mesh_net *net);
 uint8_t mesh_net_get_num_ele(struct mesh_net *net);
 bool mesh_net_set_beacon_mode(struct mesh_net *net, bool enable);
 bool mesh_net_set_proxy_mode(struct mesh_net *net, bool enable);
Signature · 1 line
2.21.0