Skip to contentSkip to conversation

ieee802154: small cleanups

PATCH In review Alexander Aring 2 participants 5 messages Feb 11, 2015 – Feb 12, 2015

Subsystems (2)
lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

v2 cover ieee802154: small cleanups

Hi,

this patch series contains some small cleanups. THe first patch do a more correct checking on valid psdu len, this is necessary e.g. in at86rf230 promiscous mode frame length checking to avoid an access out of mpdu buffer. The last two patches simple remove some unnecessary temporary variable.

- Alex

changes since v2:

- use __put_unaligned_memmove64 for handle unaligned pointer access in Patch 2/3 and 3/3.

Alexander Aring (3):
ieee802154: correct ieee802154_is_valid_psdu_len
ieee802154: cleanup ieee802154_be64_to_le64
ieee802154: cleanup ieee802154_le64_to_be64

 include/linux/ieee802154.h | 12 ++++++++++--
 include/net/mac802154.h    |  9 +++------
 2 files changed, 13 insertions(+), 8 deletions(-)
Signature · 1 line
2.3.0
author maintainer
#1 lore raw

PATCH v2 1/3 ieee802154: correct ieee802154_is_valid_psdu_len

This patch corrects the ieee802154_is_valid_psdu_len function that this function also checks on reserved values 6-8 for validation the psdu length.

---
 include/linux/ieee802154.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/ieee802154.h +10 -2
index 6e82d88..40b0ab9 100644
@@ -28,7 +28,8 @@
 #include <asm/byteorder.h>
 
 #define IEEE802154_MTU			127
-#define IEEE802154_MIN_PSDU_LEN		5
+#define IEEE802154_ACK_PSDU_LEN		5
+#define IEEE802154_MIN_PSDU_LEN		9
 
 #define IEEE802154_PAN_ID_BROADCAST	0xffff
 #define IEEE802154_ADDR_SHORT_BROADCAST	0xffff
@@ -204,11 +205,18 @@ enum {
 
 /**
  * ieee802154_is_valid_psdu_len - check if psdu len is valid
+ * available lengths:
+ *	0-4	Reserved
+ *	5	MPDU (Acknowledgment)
+ *	6-8	Reserved
+ *	9-127	MPDU
+ *
  * @len: psdu len with (MHR + payload + MFR)
  */
 static inline bool ieee802154_is_valid_psdu_len(const u8 len)
 {
-	return (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU);
+	return (len == IEEE802154_ACK_PSDU_LEN ||
+		(len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU));
 }
 
 /**
Signature · 1 line
2.3.0
author maintainer
#2 lore raw

PATCH v2 2/3 ieee802154: cleanup ieee802154_be64_to_le64

In reply to Alexander Aring

This patch cleanups the ieee802154_be64_to_le64 function. This patch removes an unnecessary temporary variable.

---
 include/net/mac802154.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/net/mac802154.h +2 -3
index 8506478..c5c6445 100644
@@ -19,6 +19,7 @@
 #include <net/af_ieee802154.h>
 #include <linux/ieee802154.h>
 #include <linux/skbuff.h>
+#include <linux/unaligned/memmove.h>
 
 #include <net/cfg802154.h>
 
@@ -233,9 +234,7 @@ struct ieee802154_ops {
  */
 static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src)
 {
-	__le64 tmp = (__force __le64)swab64p(be64_src);
-
-	memcpy(le64_dst, &tmp, IEEE802154_EXTENDED_ADDR_LEN);
+	__put_unaligned_memmove64(swab64p(be64_src), le64_dst);
 }
 
 /**
Signature · 1 line
2.3.0
author maintainer
#3 lore raw

PATCH v2 3/3 ieee802154: cleanup ieee802154_le64_to_be64

In reply to Alexander Aring

This patch cleanups the ieee802154_le64_to_be64 function. This patch removes an unnecessary temporary variable.

---
 include/net/mac802154.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/net/mac802154.h +1 -3
index c5c6445..fb4e8a3d 100644
@@ -244,9 +244,7 @@ static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src)
  */
 static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src)
 {
-	__be64 tmp = (__force __be64)swab64p(le64_src);
-
-	memcpy(be64_dst, &tmp, IEEE802154_EXTENDED_ADDR_LEN);
+	__put_unaligned_memmove64(swab64p(le64_src), be64_dst);
 }
 
 /* Basic interface to register ieee802154 hwice */
Signature · 1 line
2.3.0
#4 lore raw
In reply to Alexander Aring

Hi Alex,

Quoted 12 lines

this patch series contains some small cleanups. THe first patch do a more correct checking on valid psdu len, this is necessary e.g. in at86rf230 promiscous mode frame length checking to avoid an access out of mpdu buffer. The last two patches simple remove some unnecessary temporary variable.

- Alex

changes since v2:

- use __put_unaligned_memmove64 for handle unaligned pointer access in Patch 2/3 and 3/3.

Quoted 8 lines

Alexander Aring (3):
ieee802154: correct ieee802154_is_valid_psdu_len
ieee802154: cleanup ieee802154_be64_to_le64
ieee802154: cleanup ieee802154_le64_to_be64

include/linux/ieee802154.h | 12 ++++++++++--
include/net/mac802154.h | 9 +++------

2 files changed, 13 insertions(+), 8 deletions(-)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel