netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: em_cmp.c use unaligned access helpers
@ 2008-09-18  0:00 Harvey Harrison
  0 siblings, 0 replies; 10+ messages in thread
From: Harvey Harrison @ 2008-09-18  0:00 UTC (permalink / raw)
  To: Thomas Graf; +Cc: Andrew Morton, linux-netdev

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 net/sched/em_cmp.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c
index cc49c93..bc45039 100644
--- a/net/sched/em_cmp.c
+++ b/net/sched/em_cmp.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/tc_ematch/tc_em_cmp.h>
+#include <asm/unaligned.h>
 #include <net/pkt_cls.h>
 
 static inline int cmp_needs_transformation(struct tcf_em_cmp *cmp)
@@ -37,8 +38,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 			break;
 
 		case TCF_EM_ALIGN_U16:
-			val = *ptr << 8;
-			val |= *(ptr+1);
+			val = get_unaligned_be16(ptr);
 
 			if (cmp_needs_transformation(cmp))
 				val = be16_to_cpu(val);
@@ -47,10 +47,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 		case TCF_EM_ALIGN_U32:
 			/* Worth checking boundries? The branching seems
 			 * to get worse. Visit again. */
-			val = *ptr << 24;
-			val |= *(ptr+1) << 16;
-			val |= *(ptr+2) << 8;
-			val |= *(ptr+3);
+			val = get_unaligned_be32(ptr);
 
 			if (cmp_needs_transformation(cmp))
 				val = be32_to_cpu(val);
-- 
1.6.0.2.405.g3cc38




^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] net: em_cmp.c use unaligned access helpers
@ 2008-06-25 21:14 Harvey Harrison
  2008-06-28  3:16 ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Harvey Harrison @ 2008-06-25 21:14 UTC (permalink / raw)
  To: David Miller; +Cc: linux-netdev

Both locations are loading a big-endian value in cpu-endianness.  The
be32/be16_to_cpu immediately afterwards seems suspect.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 net/sched/em_cmp.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c
index cc49c93..56f1eae 100644
--- a/net/sched/em_cmp.c
+++ b/net/sched/em_cmp.c
@@ -15,6 +15,7 @@
 #include <linux/skbuff.h>
 #include <linux/tc_ematch/tc_em_cmp.h>
 #include <net/pkt_cls.h>
+#include <asm/unaligned.h>
 
 static inline int cmp_needs_transformation(struct tcf_em_cmp *cmp)
 {
@@ -37,9 +38,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 			break;
 
 		case TCF_EM_ALIGN_U16:
-			val = *ptr << 8;
-			val |= *(ptr+1);
-
+			val = get_unaligned_be16(ptr);
 			if (cmp_needs_transformation(cmp))
 				val = be16_to_cpu(val);
 			break;
@@ -47,11 +46,7 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 		case TCF_EM_ALIGN_U32:
 			/* Worth checking boundries? The branching seems
 			 * to get worse. Visit again. */
-			val = *ptr << 24;
-			val |= *(ptr+1) << 16;
-			val |= *(ptr+2) << 8;
-			val |= *(ptr+3);
-
+			val = get_unaligned_be32(ptr);
 			if (cmp_needs_transformation(cmp))
 				val = be32_to_cpu(val);
 			break;
-- 
1.5.6.290.gc4e15




^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-09-18  0:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18  0:00 [PATCH] net: em_cmp.c use unaligned access helpers Harvey Harrison
  -- strict thread matches above, loose matches on Subject: below --
2008-06-25 21:14 Harvey Harrison
2008-06-28  3:16 ` David Miller
2008-06-29  9:54   ` Thomas Graf
2008-06-29  9:55     ` Thomas Graf
2008-06-29 23:20       ` Harvey Harrison
2008-06-29 18:01     ` Harvey Harrison
2008-06-29 23:26       ` Thomas Graf
2008-07-05  2:10         ` Harvey Harrison
2008-07-10 11:13           ` Thomas Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).