Use compliant UUID for mesh
Subsystems (2)
v2 cover Use compliant UUID for mesh
v2: Incorporate Michał's suggestion to use Python's uuid module functions.
************
Mesh profile spec states that the values use for Device UUIDs folow format and generation procedures outlined in RFC 4122. This patch set addresses this requirement.
Inga Stotland (4):
doc/mesh-api: Add notion of Device UUID compliance
mesh: Add validation of Device UUID value test/test-mesh: Generate correct value for Device UUID tools/mesh-cfg-client:
Makefile.am | 6 ++++-- doc/mesh-api.txt | 9 ++++++--- mesh/mesh.c | 18 +++++++++--------- test/test-mesh | 7 +++---- tools/mesh-cfgclient.c | 6 +++--- tools/mesh/mesh-db.c | 2 +- 6 files changed, 26 insertions(+), 22 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/4 doc/mesh-api: Add notion of Device UUID compliance
Add requirement that the value of Device UUID supplied in CreateNetwork/Join/Import methods should be compliant with RFC 4122.
--- doc/mesh-api.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
doc/mesh-api.txt +6 -3
@@ -27,7 +27,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. When provisioning finishes, the daemon will call either JoinComplete or JoinFailed method on object implementing
@@ -149,7 +150,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. The other information the bluetooth-meshd daemon will preserve about the initial node, is to give it the initial primary
@@ -179,7 +181,8 @@ Methods: The uuid parameter is a 16-byte array that contains Device UUID. This UUID must be unique (at least from the daemon perspective), therefore attempting to call this function using already - registered UUID results in an error. + registered UUID results in an error. The composition of the UUID + octets must be in compliance with RFC 4122. The dev_key parameter is the 16-byte value of the dev key of the imported mesh node.
Signature · 1 line
2.26.2
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=433001
---Test result---
##############################
Test: CheckPatch - PASS
##############################
Test: CheckGitLint - FAIL
Output:tools/mesh-cfg-client:
1: T3 Title has trailing punctuation (:): "tools/mesh-cfg-client:"
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
PATCH v2 2/4 mesh: Add validation of Device UUID value
In reply to Inga StotlandValidate that the value of Device UUID supplied in CreateNetwork/Join/Import methods is compliant with RFC 4122.
--- Makefile.am | 6 ++++-- mesh/mesh.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-)
Makefile.am +4 -2
@@ -134,7 +134,8 @@ ell_headers = ell/util.h \ ell/base64.h \ ell/asn1-private.h \ ell/cert-private.h \ - ell/pem-private.h + ell/pem-private.h \ + ell/uuid.h ell_sources = ell/private.h ell/missing.h \ ell/util.c \
@@ -169,7 +170,8 @@ ell_sources = ell/private.h ell/missing.h \ ell/gvariant-private.h \ ell/gvariant-util.c \ ell/siphash-private.h \ - ell/siphash.c + ell/siphash.c \ + ell/uuid.c ell_libell_internal_la_SOURCES = $(ell_headers) $(ell_sources) endif
mesh/mesh.c +9 -9
@@ -533,7 +533,7 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, void *user_data) {const char *app_path, *sender; -struct l_dbus_message_iter iter_uuid; +struct l_dbus_message_iter iter;uint32_t n;l_debug ("Join network request" );
@@ -543,14 +543,13 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, "Provisioning in progress");if (!l_dbus_message_get_arguments (msg,"oay" , &app_path, - &iter_uuid)) + &iter))return dbus_error (msg,MESH_ERROR_INVALID_ARGS ,NULL ); join_pending = l_new(struct join_data, 1); -if (!l_dbus_message_iter_get_fixed_array (&iter_uuid, - &join_pending->uuid, &n) - || n !=16 ) { +if (!l_dbus_message_iter_get_fixed_array (&iter, &join_pending->uuid, &n) + || n !=16 || !l_uuid_is_valid (join_pending->uuid)) {l_free (join_pending); join_pending =NULL ; return dbus_error(msg, MESH_ERROR_INVALID_ARGS,
@@ -785,8 +784,8 @@ static struct l_dbus_message *create_network_call(struct l_dbus *dbus, &iter_uuid))return dbus_error (msg,MESH_ERROR_INVALID_ARGS ,NULL ); -if (!l_dbus_message_iter_get_fixed_array (&iter_uuid, &uuid, &n) - || n !=16 ) +if (!l_dbus_message_iter_get_fixed_array (&iter_uuid, &uuid, &n) || + n !=16 || !l_uuid_is_valid (uuid))return dbus_error (msg,MESH_ERROR_INVALID_ARGS ,"Bad device UUID" );
@@ -835,8 +834,9 @@ static struct l_dbus_message *import_call(struct l_dbus *dbus,return dbus_error (msg,MESH_ERROR_INVALID_ARGS ,NULL );if (!l_dbus_message_iter_get_fixed_array (&iter_uuid, &uuid, &n) || - n !=16 ) -return dbus_error (msg,MESH_ERROR_INVALID_ARGS ,"Bad dev UUID" ); + n !=16 || !l_uuid_is_valid (uuid)) +return dbus_error (msg,MESH_ERROR_INVALID_ARGS , +"Bad device UUID" );if (node_find_by_uuid (uuid)) return dbus_error(msg, MESH_ERROR_ALREADY_EXISTS,
Signature · 1 line
2.26.2
PATCH v2 3/4 test/test-mesh: Generate correct value for Device UUID
In reply to Inga StotlandThis ensures that the value of Device UUID when invoking Join method is compliant with RFC 4122.
--- test/test-mesh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
test/test-mesh +3 -4
@@ -887,12 +887,11 @@ class MainMenu(Menu): print(set_error('Provisioning agent not found')) return - uuid = bytearray.fromhex("0a0102030405060708090A0B0C0D0E0F") - random.shuffle(uuid) - uuid_str = array_to_string(uuid) + uuid_bytes = uuid.uuid4().bytes + uuid_str = array_to_string(uuid_bytes) print(set_yellow('Joining with UUID ') + set_green(uuid_str)) - mesh_net.Join(app.get_path(), uuid, + mesh_net.Join(app.get_path(), uuid_bytes, reply_handler=join_cb, error_handler=join_error_cb)
Signature · 1 line
2.26.2
PATCH v2 4/4 tools/mesh-cfg-client:
In reply to Inga StotlandMake sure that the values of Device UUID supplied in CreateNetwork and AddRemoteNode methods are compliant with RFC 4122.
Also, use a compliant value for Mesh UUID.
--- tools/mesh-cfgclient.c | 6 +++--- tools/mesh/mesh-db.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/mesh-cfgclient.c +3 -3
@@ -731,7 +731,7 @@ static void create_net_setup(struct l_dbus_message *msg, void *user_data)struct l_dbus_message_builder *builder;/* Generate random UUID */ -l_getrandom (app.uuid,sizeof (app.uuid)); +l_uuid_v4 (app.uuid); builder =l_dbus_message_builder_new (msg);
@@ -899,7 +899,7 @@ static void cmd_import_node(int argc, char *argv[])/* Device UUID */ req->data1 =l_util_from_hexstring (argv[1 ], &sz); -if (!req->data1 || sz !=16 ) { +if (!req->data1 || sz !=16 || !l_uuid_is_valid (req->data1)) {l_error ("Failed to generate UUID array from %s" , argv[1 ]); goto fail; }
@@ -1298,7 +1298,7 @@ static void add_node_setup(struct l_dbus_message *msg, void *user_data)struct l_dbus_message_builder *builder; uuid =l_util_from_hexstring (str, &sz); -if (!uuid || sz !=16 ) { +if (!uuid || sz !=16 || !l_uuid_is_valid (uuid)) {l_error ("Failed to generate UUID array from %s" , str);return ; }
tools/mesh/mesh-db.c +1 -1
@@ -1407,7 +1407,7 @@ bool mesh_db_create(const char *fname, const uint8_t token[8],if (!add_u8_8 (jcfg,"token" , token)) goto fail; -l_getrandom (uuid,16 ); +l_uuid_v4 (uuid);if (!add_u8_16 (jcfg,"uuid" , uuid)) goto fail;
Signature · 1 line
2.26.2
Patchset Applied
Quoted 23 lines · Inga Stotland
v2: Incorporate Michał's suggestion to use Python's uuid module functions.
************
Mesh profile spec states that the values use for Device UUIDs folow format and generation procedures outlined in RFC 4122. This patch set addresses this requirement.Inga Stotland (4):
doc/mesh-api: Add notion of Device UUID compliance
mesh: Add validation of Device UUID value test/test-mesh: Generate correct value for Device UUIDtools/mesh-cfg-client:Makefile.am | 6 ++++-- doc/mesh-api.txt | 9 ++++++--- mesh/mesh.c | 18 +++++++++--------- test/test-mesh | 7 +++---- tools/mesh-cfgclient.c | 6 +++--- tools/mesh/mesh-db.c | 2 +- 6 files changed, 26 insertions(+), 22 deletions(-)