mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
net: em_cmp.c use unaligned access helpers
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
978e9aec26
commit
d48abfecea
1 changed files with 3 additions and 6 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/tc_ematch/tc_em_cmp.h>
|
#include <linux/tc_ematch/tc_em_cmp.h>
|
||||||
|
#include <asm/unaligned.h>
|
||||||
#include <net/pkt_cls.h>
|
#include <net/pkt_cls.h>
|
||||||
|
|
||||||
static inline int cmp_needs_transformation(struct tcf_em_cmp *cmp)
|
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;
|
break;
|
||||||
|
|
||||||
case TCF_EM_ALIGN_U16:
|
case TCF_EM_ALIGN_U16:
|
||||||
val = *ptr << 8;
|
val = get_unaligned_be16(ptr);
|
||||||
val |= *(ptr+1);
|
|
||||||
|
|
||||||
if (cmp_needs_transformation(cmp))
|
if (cmp_needs_transformation(cmp))
|
||||||
val = be16_to_cpu(val);
|
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:
|
case TCF_EM_ALIGN_U32:
|
||||||
/* Worth checking boundries? The branching seems
|
/* Worth checking boundries? The branching seems
|
||||||
* to get worse. Visit again. */
|
* to get worse. Visit again. */
|
||||||
val = *ptr << 24;
|
val = get_unaligned_be32(ptr);
|
||||||
val |= *(ptr+1) << 16;
|
|
||||||
val |= *(ptr+2) << 8;
|
|
||||||
val |= *(ptr+3);
|
|
||||||
|
|
||||||
if (cmp_needs_transformation(cmp))
|
if (cmp_needs_transformation(cmp))
|
||||||
val = be32_to_cpu(val);
|
val = be32_to_cpu(val);
|
||||||
|
|
Loading…
Reference in a new issue