2021-02-12 21:45:37

by Inga Stotland

[permalink] [raw]
Subject: [PATCH BlueZ v2 0/4] 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(-)

--
2.26.2


2021-02-12 21:45:53

by Inga Stotland

[permalink] [raw]
Subject: [PATCH BlueZ v2 3/4] test/test-mesh: Generate correct value for Device UUID

This 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(-)

diff --git a/test/test-mesh b/test/test-mesh
index 9e4783734..fbf2476bf 100755
--- a/test/test-mesh
+++ b/test/test-mesh
@@ -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)

--
2.26.2

2021-02-12 21:46:37

by Inga Stotland

[permalink] [raw]
Subject: [PATCH BlueZ v2 4/4] tools/mesh-cfg-client:

Make 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(-)

diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c
index 28465a679..1eeed2a1a 100644
--- a/tools/mesh-cfgclient.c
+++ b/tools/mesh-cfgclient.c
@@ -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;
}
diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c
index d86913006..46f0c6075 100644
--- a/tools/mesh/mesh-db.c
+++ b/tools/mesh/mesh-db.c
@@ -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;
--
2.26.2

2021-02-12 21:47:47

by Inga Stotland

[permalink] [raw]
Subject: [PATCH BlueZ 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(-)

diff --git a/doc/mesh-api.txt b/doc/mesh-api.txt
index 254ccbd7f..f2c6b9e5c 100644
--- a/doc/mesh-api.txt
+++ b/doc/mesh-api.txt
@@ -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.
--
2.26.2

2021-02-12 21:59:25

by bluez.test.bot

[permalink] [raw]
Subject: RE: Use compliant UUID for mesh

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

2021-02-16 19:58:21

by Brian Gix

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 0/4] Use compliant UUID for mesh

Patchset Applied

On Fri, 2021-02-12 at 13:42 -0800, Inga Stotland wrote:
> 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(-)
>