em_cmp.c (55fa518867978e1f5fd8353098f80d125ac734d7) em_cmp.c (cc7ec456f82da7f89a5b376e613b3ac4311b3e9a)
1/*
2 * net/sched/em_cmp.c Simple packet data comparison ematch
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *

--- 19 unchanged lines hidden (view full) ---

28 struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
29 unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
30 u32 val = 0;
31
32 if (!tcf_valid_offset(skb, ptr, cmp->align))
33 return 0;
34
35 switch (cmp->align) {
1/*
2 * net/sched/em_cmp.c Simple packet data comparison ematch
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *

--- 19 unchanged lines hidden (view full) ---

28 struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
29 unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
30 u32 val = 0;
31
32 if (!tcf_valid_offset(skb, ptr, cmp->align))
33 return 0;
34
35 switch (cmp->align) {
36 case TCF_EM_ALIGN_U8:
37 val = *ptr;
38 break;
36 case TCF_EM_ALIGN_U8:
37 val = *ptr;
38 break;
39
39
40 case TCF_EM_ALIGN_U16:
41 val = get_unaligned_be16(ptr);
40 case TCF_EM_ALIGN_U16:
41 val = get_unaligned_be16(ptr);
42
42
43 if (cmp_needs_transformation(cmp))
44 val = be16_to_cpu(val);
45 break;
43 if (cmp_needs_transformation(cmp))
44 val = be16_to_cpu(val);
45 break;
46
46
47 case TCF_EM_ALIGN_U32:
48 /* Worth checking boundries? The branching seems
49 * to get worse. Visit again. */
50 val = get_unaligned_be32(ptr);
47 case TCF_EM_ALIGN_U32:
48 /* Worth checking boundries? The branching seems
49 * to get worse. Visit again.
50 */
51 val = get_unaligned_be32(ptr);
51
52
52 if (cmp_needs_transformation(cmp))
53 val = be32_to_cpu(val);
54 break;
53 if (cmp_needs_transformation(cmp))
54 val = be32_to_cpu(val);
55 break;
55
56
56 default:
57 return 0;
57 default:
58 return 0;
58 }
59
60 if (cmp->mask)
61 val &= cmp->mask;
62
63 switch (cmp->opnd) {
59 }
60
61 if (cmp->mask)
62 val &= cmp->mask;
63
64 switch (cmp->opnd) {
64 case TCF_EM_OPND_EQ:
65 return val == cmp->val;
66 case TCF_EM_OPND_LT:
67 return val < cmp->val;
68 case TCF_EM_OPND_GT:
69 return val > cmp->val;
65 case TCF_EM_OPND_EQ:
66 return val == cmp->val;
67 case TCF_EM_OPND_LT:
68 return val < cmp->val;
69 case TCF_EM_OPND_GT:
70 return val > cmp->val;
70 }
71
72 return 0;
73}
74
75static struct tcf_ematch_ops em_cmp_ops = {
76 .kind = TCF_EM_CMP,
77 .datalen = sizeof(struct tcf_em_cmp),

--- 21 unchanged lines hidden ---
71 }
72
73 return 0;
74}
75
76static struct tcf_ematch_ops em_cmp_ops = {
77 .kind = TCF_EM_CMP,
78 .datalen = sizeof(struct tcf_em_cmp),

--- 21 unchanged lines hidden ---