[PATCH] mesh: Fixed log MIC usage in segmented messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jakub Witowski <jakub.witowski@xxxxxxxxxxx>

Contrary to the comment, implementation used a 8-byte MIC even if this
generated an additional segment.
---
 mesh/model.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mesh/model.c b/mesh/model.c
index a632d80e1..0b3ea4094 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -40,6 +40,8 @@
 #include "mesh/util.h"
 #include "mesh/model.h"
 
+#define CEILDIV(val, div) (((val) / (div)) + ((val) % (div) != 0))
+
 struct mesh_model {
 	const struct mesh_model_ops *cbs;
 	void *user_data;
@@ -451,7 +453,7 @@ static bool msg_send(struct mesh_node *node, bool credential, uint16_t src,
 
 	/* Use large MIC if it doesn't affect segmentation */
 	if (msg_len > 11 && msg_len <= 376) {
-		if ((out_len / 12) == ((out_len + 4) / 12)) {
+		if (CEILDIV(out_len, 12) == CEILDIV(out_len + 4, 12)) {
 			szmic = true;
 			out_len = msg_len + sizeof(uint64_t);
 		}
-- 
2.19.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux