You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2021/05/27 08:20:54 UTC

[mynewt-nimble] 27/31: Revert "mesh: Verify network buffer max len"

This is an automated email from the ASF dual-hosted git repository.

naraj pushed a commit to branch revert-958-mesh_sync_march21
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit eac357252880c884b3fddff5aa376ea244abeed8
Author: MichaƂ Narajowski <mi...@codecoup.pl>
AuthorDate: Thu May 27 10:20:19 2021 +0200

    Revert "mesh: Verify network buffer max len"
    
    This reverts commit 68c409ab57b351e4161c33b2d2775a41f2289bb0.
---
 nimble/host/mesh/src/net.c   | 15 +++++++++------
 nimble/host/mesh/src/net.h   | 13 -------------
 nimble/host/mesh/src/proxy.c |  2 +-
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c
index 2e1d6dc..8b86935 100644
--- a/nimble/host/mesh/src/net.c
+++ b/nimble/host/mesh/src/net.c
@@ -34,6 +34,14 @@
 #include "mesh/glue.h"
 #include "mesh/slist.h"
 
+/* Minimum valid Mesh Network PDU length. The Network headers
+ * themselves take up 9 bytes. After that there is a minumum of 1 byte
+ * payload for both CTL=1 and CTL=0 PDUs (smallest OpCode is 1 byte). CTL=1
+ * PDUs must use a 64-bit (8 byte) NetMIC, whereas CTL=0 PDUs have at least
+ * a 32-bit (4 byte) NetMIC and AppMIC giving again a total of 8 bytes.
+ */
+#define BT_MESH_NET_MIN_PDU_LEN (BT_MESH_NET_HDR_LEN + 1 + 8)
+
 #define LOOPBACK_MAX_PDU_LEN (BT_MESH_NET_HDR_LEN + 16)
 #define LOOPBACK_USER_DATA_SIZE sizeof(struct bt_mesh_subnet *)
 #define LOOPBACK_BUF_SUB(buf) (*(struct bt_mesh_subnet **)net_buf_user_data(buf))
@@ -694,11 +702,6 @@ int bt_mesh_net_decode(struct os_mbuf *in, enum bt_mesh_net_if net_if,
 		return -EINVAL;
 	}
 
-	if (in->om_len > BT_MESH_NET_MAX_PDU_LEN) {
-		BT_WARN("Dropping too long mesh packet (len %u)", in->om_len);
-		return -EINVAL;
-	}
-
 	if (net_if == BT_MESH_NET_IF_ADV && check_dup(in)) {
 		BT_DBG("duplicate packet; dropping %u bytes: %s", in->om_len,
 			   bt_hex(in->om_data, in->om_len));
@@ -751,7 +754,7 @@ int bt_mesh_net_decode(struct os_mbuf *in, enum bt_mesh_net_if net_if,
 void bt_mesh_net_recv(struct os_mbuf *data, int8_t rssi,
 		      enum bt_mesh_net_if net_if)
 {
-	struct os_mbuf *buf = NET_BUF_SIMPLE(BT_MESH_NET_MAX_PDU_LEN);
+	struct os_mbuf *buf = NET_BUF_SIMPLE(29);
 	struct bt_mesh_net_rx rx = { .ctx.recv_rssi = rssi };
 	struct net_buf_simple_state state;
 
diff --git a/nimble/host/mesh/src/net.h b/nimble/host/mesh/src/net.h
index 8c50154..f4b1192 100644
--- a/nimble/host/mesh/src/net.h
+++ b/nimble/host/mesh/src/net.h
@@ -25,19 +25,6 @@
 				    CONFIG_BT_MESH_IVU_DIVIDER)
 #define BT_MESH_IVU_TIMEOUT        K_HOURS(BT_MESH_IVU_HOURS)
 
-/* Minimum valid Mesh Network PDU length. The Network headers
- * themselves take up 9 bytes. After that there is a minimum of 1 byte
- * payload for both CTL=1 and CTL=0 PDUs (smallest OpCode is 1 byte). CTL=1
- * PDUs must use a 64-bit (8 byte) NetMIC, whereas CTL=0 PDUs have at least
- * a 32-bit (4 byte) NetMIC and AppMIC giving again a total of 8 bytes.
- */
-#define BT_MESH_NET_MIN_PDU_LEN (BT_MESH_NET_HDR_LEN + 1 + 8)
-/* Maximum valid Mesh Network PDU length. The longest packet can either be a
- * transport control message (CTL=1) of 12 bytes + 8 bytes of NetMIC, or an
- * access message (CTL=0) of 16 bytes + 4 bytes of NetMIC.
- */
-#define BT_MESH_NET_MAX_PDU_LEN (BT_MESH_NET_HDR_LEN + 16 + 4)
-
 struct bt_mesh_net_cred;
 
 struct bt_mesh_node {
diff --git a/nimble/host/mesh/src/proxy.c b/nimble/host/mesh/src/proxy.c
index 9ed983d..6d631b7 100644
--- a/nimble/host/mesh/src/proxy.c
+++ b/nimble/host/mesh/src/proxy.c
@@ -328,7 +328,7 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
 
 static void proxy_cfg(struct bt_mesh_proxy_client *client)
 {
-	struct os_mbuf *buf = NET_BUF_SIMPLE(BT_MESH_NET_MAX_PDU_LEN);
+	struct os_mbuf *buf = NET_BUF_SIMPLE(29);
 	struct bt_mesh_net_rx rx;
 	uint8_t opcode;
 	int err;