Skip to contentSkip to conversation

Blacklist addresses of deleted nodes

PATCH In review Inga Stotland 2 participants 5 messages Jun 19, 2020 – Jun 22, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

cover Blacklist addresses of deleted nodes

This patch set adds a notion of blacklisted addresses for nodes that have been removed from mesh network.
The addresses of nodes that have been removed should not be added back into available unicast addresses pool (for assigning to newly provisioned nodes) until mesh-wide IV Index is changed at least twice

Inga Stotland (3):
mesh: Emit PropertiesChanged when IV Index changes tools/mesh-cfgclient: get/set IV index tools/mesh-cfgclient: add list of blacklisted addresses

 mesh/net.c             |   2 +
 mesh/node.c            |   9 +++
 mesh/node.h            |   1 +
 tools/mesh-cfgclient.c |  41 +++++++++-
 tools/mesh/mesh-db.c   | 170 +++++++++++++++++++++++++++++++++++++++++
 tools/mesh/mesh-db.h   |   5 +-
 tools/mesh/remote.c    | 110 +++++++++++++++++++++++---
 tools/mesh/remote.h    |   3 +
 8 files changed, 329 insertions(+), 12 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/3 mesh: Emit PropertiesChanged when IV Index changes

This adds emitting of PropertiesChanged signal whenever the mesh IV index is updated to indicate that the vlaues of "IvIndex" property has been modified.

---
 mesh/net.c  | 2 ++
 mesh/node.c | 9 +++++++++
 mesh/node.h | 1 +
 3 files changed, 12 insertions(+)
mesh/net.c +2 -0
index 3ab948be5..b54c647cb 100644
@@ -2566,6 +2566,8 @@ static void update_iv_ivu_state(struct mesh_net *net, uint32_t iv_index,
 		rpl_init(net->node, iv_index);
 	}
 
+	node_property_changed(net->node, "IVIndex");
+
 	net->iv_index = iv_index;
 	net->iv_update = ivu;
 }
mesh/node.c +9 -0
index cf4d93aec..ee6d1833f 100644
@@ -2280,6 +2280,15 @@ static void setup_node_interface(struct l_dbus_interface *iface)
 									NULL);
 }
 
+void node_property_changed(struct mesh_node *node, const char *property)
+{
+	struct l_dbus *bus = dbus_get_bus();
+
+	if (bus)
+		l_dbus_property_changed(dbus_get_bus(), node->obj_path,
+						MESH_NODE_INTERFACE, property);
+}
+
 bool node_dbus_init(struct l_dbus *bus)
 {
 	if (!l_dbus_register_interface(bus, MESH_NODE_INTERFACE,
mesh/node.h +1 -0
index b8b2b1b49..6c4542a78 100644
@@ -99,3 +99,4 @@ struct mesh_agent *node_get_agent(struct mesh_node *node);
 const char *node_get_storage_dir(struct mesh_node *node);
 bool node_load_from_storage(const char *storage_dir);
 void node_finalize_new_node(struct mesh_node *node, struct mesh_io *io);
+void node_property_changed(struct mesh_node *node, const char *property);
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/3 tools/mesh-cfgclient: get/set IV index

In reply to Inga Stotland

This adds keeping track of IV index changes.
The updates are detected by observing PropertiesChanged signal on local node's object path and reading "IvIndex" property

---
 tools/mesh-cfgclient.c | 39 ++++++++++++++++++++++++++++++++++++++-
 tools/mesh/mesh-db.c   | 25 +++++++++++++++++++++++++
 tools/mesh/mesh-db.h   |  3 ++-
 3 files changed, 65 insertions(+), 2 deletions(-)
tools/mesh-cfgclient.c +38 -1
index fe82a8bbe..da9f83c29 100644
@@ -144,6 +144,7 @@ static const char *range_opt;
 static const char *net_idx_opt;
 static const char *config_opt;
 
+static uint32_t iv_index;
 static uint16_t low_addr;
 static uint16_t high_addr;
 static uint16_t prov_net_idx;
@@ -664,6 +665,7 @@ static void attach_node_reply(struct l_dbus_proxy *proxy,
 {
 	struct meshcfg_node *node = user_data;
 	struct l_dbus_message_iter iter_cfg;
+	uint32_t ivi;
 
 	if (l_dbus_message_is_error(msg)) {
 		const char *name;
@@ -693,6 +695,12 @@ static void attach_node_reply(struct l_dbus_proxy *proxy,
 	/* Inititalize config client model */
 	client_init();
 
+	if (l_dbus_proxy_get_property(local->proxy, "IvIndex", "u", &ivi) &&
+							ivi != iv_index) {
+		iv_index = ivi;
+		mesh_db_set_iv_index(ivi);
+	}
+
 	return;
 
 fail:
@@ -1792,6 +1800,33 @@ static struct l_dbus_message *join_complete(struct l_dbus *dbus,
 	return l_dbus_message_new_method_return(message);
 }
 
+static void property_changed(struct l_dbus_proxy *proxy, const char *name,
+				struct l_dbus_message *msg, void *user_data)
+{
+	const char *interface = l_dbus_proxy_get_interface(proxy);
+	const char *path = l_dbus_proxy_get_path(proxy);
+
+	if (strcmp(path, local->path))
+		return;
+
+	bt_shell_printf("Property changed: %s %s %s\n", name, path, interface);
+
+	if (!strcmp(interface, "org.bluez.mesh.Node1")) {
+
+		if (!strcmp(name, "IvIndex")) {
+			uint32_t ivi;
+
+			if (!l_dbus_message_get_arguments(msg, "u", &ivi))
+				return;
+
+			bt_shell_printf("New IV Index: %u\n", ivi);
+
+			iv_index = ivi;
+			mesh_db_set_iv_index(ivi);
+		}
+	}
+}
+
 static void setup_app_iface(struct l_dbus_interface *iface)
 {
 	l_dbus_interface_property(iface, "CompanyID", 0, "q", cid_getter,
@@ -1974,6 +2009,8 @@ static bool read_mesh_config(void)
 		high_addr = range_h;
 	}
 
+	iv_index = mesh_db_get_iv_index();
+
 	return true;
 }
 
@@ -2040,7 +2077,7 @@ int main(int argc, char *argv[])
 	l_dbus_client_set_disconnect_handler(client, client_disconnected, NULL,
 									NULL);
 	l_dbus_client_set_proxy_handlers(client, proxy_added, proxy_removed,
-							NULL, NULL, NULL);
+						property_changed, NULL, NULL);
 	l_dbus_client_set_ready_handler(client, client_ready, NULL, NULL);
 
 	node_proxies = l_queue_new();
tools/mesh/mesh-db.c +25 -0
index b789c3933..dbeed0214 100644
@@ -1232,6 +1232,29 @@ bool mesh_db_set_addr_range(uint16_t low, uint16_t high)
 	return save_config();
 }
 
+uint32_t mesh_db_get_iv_index(void)
+{
+	int ivi;
+
+	if (!cfg || !cfg->jcfg)
+		return 0;
+
+	if (!get_int(cfg->jcfg, "ivIndex", &ivi))
+		return 0;
+
+	return (uint32_t) ivi;
+}
+
+bool mesh_db_set_iv_index(uint32_t ivi)
+{
+	if (!cfg || !cfg->jcfg)
+		return false;
+
+	write_int(cfg->jcfg, "ivIndex", ivi);
+
+	return save_config();
+}
+
 bool mesh_db_create(const char *fname, const uint8_t token[8],
 							const char *mesh_name)
 {
@@ -1282,6 +1305,8 @@ bool mesh_db_create(const char *fname, const uint8_t token[8],
 
 	json_object_object_add(jcfg, "appKeys", jarray);
 
+	write_int(jcfg, "ivIndex", 0);
+
 	if (!save_config())
 		goto fail;
 
tools/mesh/mesh-db.h +2 -1
index 89c644400..83fcfbee7 100644
@@ -26,7 +26,8 @@ bool mesh_db_create(const char *fname, const uint8_t token[8],
 bool mesh_db_load(const char *fname);
 
 bool mesh_db_get_token(uint8_t token[8]);
-
+bool mesh_db_set_iv_index(uint32_t ivi);
+uint32_t mesh_db_get_iv_index(void);
 bool mesh_db_net_key_add(uint16_t idx);
 bool mesh_db_net_key_del(uint16_t idx);
 bool mesh_db_net_key_phase_set(uint16_t net_idx, uint8_t phase);
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/3 tools/mesh-cfgclient: add list of blacklisted addresses

In reply to Inga Stotland

This adds a concept of "blacklisted" addresses. that a provisioner is not allowed to assign to newly added mesh nodes.
An address may be "blacklisted" is a node has been removed from the network (e.g., after node reset procedure). This ensures that the addresses are not reused for provisioning new nodes to prevent a potential communication problem due to saved RPL entries associated with these addresses in the rest of the mesh network. The address is "cleared", when IV index updates at least twice.

---
 tools/mesh-cfgclient.c |   2 +
 tools/mesh/mesh-db.c   | 145 +++++++++++++++++++++++++++++++++++++++++
 tools/mesh/mesh-db.h   |   2 +
 tools/mesh/remote.c    | 110 ++++++++++++++++++++++++++++---
 tools/mesh/remote.h    |   3 +
 5 files changed, 252 insertions(+), 10 deletions(-)
tools/mesh-cfgclient.c +2 -0
index da9f83c29..0dd02fad8 100644
@@ -699,6 +699,7 @@ static void attach_node_reply(struct l_dbus_proxy *proxy,
 							ivi != iv_index) {
 		iv_index = ivi;
 		mesh_db_set_iv_index(ivi);
+		remote_clear_blacklisted_addresses(ivi);
 	}
 
 	return;
@@ -1823,6 +1824,7 @@ static void property_changed(struct l_dbus_proxy *proxy, const char *name,
 
 			iv_index = ivi;
 			mesh_db_set_iv_index(ivi);
+			remote_clear_blacklisted_addresses(ivi);
 		}
 	}
 }
tools/mesh/mesh-db.c +145 -0

163 lines not on this page · raw message

tools/mesh/mesh-db.h +2 -0
index 83fcfbee7..49af33e87 100644
@@ -58,3 +58,5 @@ bool mesh_db_node_model_binding_del(uint16_t unicast, uint8_t ele, bool vendor,
 					uint32_t mod_id, uint16_t app_idx);
 struct l_queue *mesh_db_load_groups(void);
 bool mesh_db_add_group(struct mesh_group *grp);
+bool mesh_db_add_blacklisted_addr(uint16_t unicast, uint32_t iv_index);
+bool mesh_db_clear_blacklisted(uint32_t iv_index);
tools/mesh/remote.c +100 -10

150 lines not on this page · raw message

tools/mesh/remote.h +3 -0
index 33398c8bd..482817c5a 100644
@@ -22,6 +22,9 @@ bool remote_add_node(const uint8_t uuid[16], uint16_t unicast,
 uint8_t remote_del_node(uint16_t unicast);
 bool remote_set_model(uint16_t unicast, uint8_t ele_idx, uint32_t mod_id,
 								bool vendor);
+void remote_add_blacklisted_address(uint16_t addr, uint32_t iv_index,
+								bool save);
+void remote_clear_blacklisted_addresses(uint32_t iv_index);
 uint16_t remote_get_next_unicast(uint16_t low, uint16_t high, uint8_t ele_cnt);
 bool remote_add_net_key(uint16_t addr, uint16_t net_idx);
 bool remote_del_net_key(uint16_t addr, uint16_t net_idx);
Signature · 1 line
2.26.2
#4 lore raw
In reply to Inga Stotland

Patchset Applied

Quoted 21 lines · Inga Stotland

This patch set adds a notion of blacklisted addresses for nodes that have been removed from mesh network.
The addresses of nodes that have been removed should not be added back into available unicast addresses pool (for assigning to newly provisioned nodes) until mesh-wide IV Index is changed at least twice

Inga Stotland (3):
mesh: Emit PropertiesChanged when IV Index changes tools/mesh-cfgclient: get/set IV index tools/mesh-cfgclient: add list of blacklisted addresses

 mesh/net.c             |   2 +
 mesh/node.c            |   9 +++
 mesh/node.h            |   1 +
 tools/mesh-cfgclient.c |  41 +++++++++-
 tools/mesh/mesh-db.c   | 170 +++++++++++++++++++++++++++++++++++++++++
 tools/mesh/mesh-db.h   |   5 +-
 tools/mesh/remote.c    | 110 +++++++++++++++++++++++---
 tools/mesh/remote.h    |   3 +
 8 files changed, 329 insertions(+), 12 deletions(-)