diff options
author | Stefan Sørensen <stefan.sorensen@spectralink.com> | 2015-11-03 03:34:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-11-03 11:08:22 -0500 |
commit | 5f94c943d5dd4b51f3248193e622dd5fcdbb8b11 (patch) | |
tree | c773bfd331b79873c5f3ed9f1a44e00152ecb06f | |
parent | ccf6ee9a6980eff9ec0eeaa8f63c65bff34d9697 (diff) |
ptp: Change ptp_class to a proper bitmask
Change the definition of PTP_CLASS_L2 to not have any bits overlapping with
the other defined protocol values, allowing the PTP_CLASS_* definitions to
be for simple filtering on packet type.
Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/ptp_classify.h | 7 | ||||
-rw-r--r-- | net/core/ptp_classifier.c | 16 |
2 files changed, 12 insertions, 11 deletions
diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h index 159c987b1853..a079656b614c 100644 --- a/include/linux/ptp_classify.h +++ b/include/linux/ptp_classify.h | |||
@@ -32,9 +32,9 @@ | |||
32 | #define PTP_CLASS_VMASK 0x0f /* max protocol version is 15 */ | 32 | #define PTP_CLASS_VMASK 0x0f /* max protocol version is 15 */ |
33 | #define PTP_CLASS_IPV4 0x10 /* event in an IPV4 UDP packet */ | 33 | #define PTP_CLASS_IPV4 0x10 /* event in an IPV4 UDP packet */ |
34 | #define PTP_CLASS_IPV6 0x20 /* event in an IPV6 UDP packet */ | 34 | #define PTP_CLASS_IPV6 0x20 /* event in an IPV6 UDP packet */ |
35 | #define PTP_CLASS_L2 0x30 /* event in a L2 packet */ | 35 | #define PTP_CLASS_L2 0x40 /* event in a L2 packet */ |
36 | #define PTP_CLASS_PMASK 0x30 /* mask for the packet type field */ | 36 | #define PTP_CLASS_PMASK 0x70 /* mask for the packet type field */ |
37 | #define PTP_CLASS_VLAN 0x40 /* event in a VLAN tagged packet */ | 37 | #define PTP_CLASS_VLAN 0x80 /* event in a VLAN tagged packet */ |
38 | 38 | ||
39 | #define PTP_CLASS_V1_IPV4 (PTP_CLASS_V1 | PTP_CLASS_IPV4) | 39 | #define PTP_CLASS_V1_IPV4 (PTP_CLASS_V1 | PTP_CLASS_IPV4) |
40 | #define PTP_CLASS_V1_IPV6 (PTP_CLASS_V1 | PTP_CLASS_IPV6) /* probably DNE */ | 40 | #define PTP_CLASS_V1_IPV6 (PTP_CLASS_V1 | PTP_CLASS_IPV6) /* probably DNE */ |
@@ -42,6 +42,7 @@ | |||
42 | #define PTP_CLASS_V2_IPV6 (PTP_CLASS_V2 | PTP_CLASS_IPV6) | 42 | #define PTP_CLASS_V2_IPV6 (PTP_CLASS_V2 | PTP_CLASS_IPV6) |
43 | #define PTP_CLASS_V2_L2 (PTP_CLASS_V2 | PTP_CLASS_L2) | 43 | #define PTP_CLASS_V2_L2 (PTP_CLASS_V2 | PTP_CLASS_L2) |
44 | #define PTP_CLASS_V2_VLAN (PTP_CLASS_V2 | PTP_CLASS_VLAN) | 44 | #define PTP_CLASS_V2_VLAN (PTP_CLASS_V2 | PTP_CLASS_VLAN) |
45 | #define PTP_CLASS_L4 (PTP_CLASS_IPV4 | PTP_CLASS_IPV6) | ||
45 | 46 | ||
46 | #define PTP_EV_PORT 319 | 47 | #define PTP_EV_PORT 319 |
47 | #define PTP_GEN_BIT 0x08 /* indicates general message, if set in message type */ | 48 | #define PTP_GEN_BIT 0x08 /* indicates general message, if set in message type */ |
diff --git a/net/core/ptp_classifier.c b/net/core/ptp_classifier.c index 4eab4a94a59d..703cf76aa7c2 100644 --- a/net/core/ptp_classifier.c +++ b/net/core/ptp_classifier.c | |||
@@ -58,7 +58,7 @@ | |||
58 | * jneq #0x0, drop_ieee1588 ; for PTP_GEN_BIT and drop these | 58 | * jneq #0x0, drop_ieee1588 ; for PTP_GEN_BIT and drop these |
59 | * ldh [18] ; reload payload | 59 | * ldh [18] ; reload payload |
60 | * and #0xf ; mask PTP_CLASS_VMASK | 60 | * and #0xf ; mask PTP_CLASS_VMASK |
61 | * or #0x70 ; PTP_CLASS_VLAN|PTP_CLASS_L2 | 61 | * or #0xc0 ; PTP_CLASS_VLAN|PTP_CLASS_L2 |
62 | * ret a ; return PTP class | 62 | * ret a ; return PTP class |
63 | * | 63 | * |
64 | * ; PTP over UDP over IPv4 over 802.1Q over Ethernet | 64 | * ; PTP over UDP over IPv4 over 802.1Q over Ethernet |
@@ -73,7 +73,7 @@ | |||
73 | * jneq #319, drop_8021q_ipv4 ; is port PTP_EV_PORT ? | 73 | * jneq #319, drop_8021q_ipv4 ; is port PTP_EV_PORT ? |
74 | * ldh [x + 26] ; load payload | 74 | * ldh [x + 26] ; load payload |
75 | * and #0xf ; mask PTP_CLASS_VMASK | 75 | * and #0xf ; mask PTP_CLASS_VMASK |
76 | * or #0x50 ; PTP_CLASS_VLAN|PTP_CLASS_IPV4 | 76 | * or #0x90 ; PTP_CLASS_VLAN|PTP_CLASS_IPV4 |
77 | * ret a ; return PTP class | 77 | * ret a ; return PTP class |
78 | * drop_8021q_ipv4: ret #0x0 ; PTP_CLASS_NONE | 78 | * drop_8021q_ipv4: ret #0x0 ; PTP_CLASS_NONE |
79 | * | 79 | * |
@@ -86,7 +86,7 @@ | |||
86 | * jneq #319, drop_8021q_ipv6 ; is port PTP_EV_PORT ? | 86 | * jneq #319, drop_8021q_ipv6 ; is port PTP_EV_PORT ? |
87 | * ldh [66] ; load payload | 87 | * ldh [66] ; load payload |
88 | * and #0xf ; mask PTP_CLASS_VMASK | 88 | * and #0xf ; mask PTP_CLASS_VMASK |
89 | * or #0x60 ; PTP_CLASS_VLAN|PTP_CLASS_IPV6 | 89 | * or #0xa0 ; PTP_CLASS_VLAN|PTP_CLASS_IPV6 |
90 | * ret a ; return PTP class | 90 | * ret a ; return PTP class |
91 | * drop_8021q_ipv6: ret #0x0 ; PTP_CLASS_NONE | 91 | * drop_8021q_ipv6: ret #0x0 ; PTP_CLASS_NONE |
92 | * | 92 | * |
@@ -98,7 +98,7 @@ | |||
98 | * jneq #0x0, drop_ieee1588 ; for PTP_GEN_BIT and drop these | 98 | * jneq #0x0, drop_ieee1588 ; for PTP_GEN_BIT and drop these |
99 | * ldh [14] ; reload payload | 99 | * ldh [14] ; reload payload |
100 | * and #0xf ; mask PTP_CLASS_VMASK | 100 | * and #0xf ; mask PTP_CLASS_VMASK |
101 | * or #0x30 ; PTP_CLASS_L2 | 101 | * or #0x40 ; PTP_CLASS_L2 |
102 | * ret a ; return PTP class | 102 | * ret a ; return PTP class |
103 | * drop_ieee1588: ret #0x0 ; PTP_CLASS_NONE | 103 | * drop_ieee1588: ret #0x0 ; PTP_CLASS_NONE |
104 | */ | 104 | */ |
@@ -150,7 +150,7 @@ void __init ptp_classifier_init(void) | |||
150 | { 0x15, 0, 35, 0x00000000 }, | 150 | { 0x15, 0, 35, 0x00000000 }, |
151 | { 0x28, 0, 0, 0x00000012 }, | 151 | { 0x28, 0, 0, 0x00000012 }, |
152 | { 0x54, 0, 0, 0x0000000f }, | 152 | { 0x54, 0, 0, 0x0000000f }, |
153 | { 0x44, 0, 0, 0x00000070 }, | 153 | { 0x44, 0, 0, 0x000000c0 }, |
154 | { 0x16, 0, 0, 0x00000000 }, | 154 | { 0x16, 0, 0, 0x00000000 }, |
155 | { 0x15, 0, 12, 0x00000800 }, | 155 | { 0x15, 0, 12, 0x00000800 }, |
156 | { 0x30, 0, 0, 0x0000001b }, | 156 | { 0x30, 0, 0, 0x0000001b }, |
@@ -162,7 +162,7 @@ void __init ptp_classifier_init(void) | |||
162 | { 0x15, 0, 4, 0x0000013f }, | 162 | { 0x15, 0, 4, 0x0000013f }, |
163 | { 0x48, 0, 0, 0x0000001a }, | 163 | { 0x48, 0, 0, 0x0000001a }, |
164 | { 0x54, 0, 0, 0x0000000f }, | 164 | { 0x54, 0, 0, 0x0000000f }, |
165 | { 0x44, 0, 0, 0x00000050 }, | 165 | { 0x44, 0, 0, 0x00000090 }, |
166 | { 0x16, 0, 0, 0x00000000 }, | 166 | { 0x16, 0, 0, 0x00000000 }, |
167 | { 0x06, 0, 0, 0x00000000 }, | 167 | { 0x06, 0, 0, 0x00000000 }, |
168 | { 0x15, 0, 8, 0x000086dd }, | 168 | { 0x15, 0, 8, 0x000086dd }, |
@@ -172,7 +172,7 @@ void __init ptp_classifier_init(void) | |||
172 | { 0x15, 0, 4, 0x0000013f }, | 172 | { 0x15, 0, 4, 0x0000013f }, |
173 | { 0x28, 0, 0, 0x00000042 }, | 173 | { 0x28, 0, 0, 0x00000042 }, |
174 | { 0x54, 0, 0, 0x0000000f }, | 174 | { 0x54, 0, 0, 0x0000000f }, |
175 | { 0x44, 0, 0, 0x00000060 }, | 175 | { 0x44, 0, 0, 0x000000a0 }, |
176 | { 0x16, 0, 0, 0x00000000 }, | 176 | { 0x16, 0, 0, 0x00000000 }, |
177 | { 0x06, 0, 0, 0x00000000 }, | 177 | { 0x06, 0, 0, 0x00000000 }, |
178 | { 0x15, 0, 7, 0x000088f7 }, | 178 | { 0x15, 0, 7, 0x000088f7 }, |
@@ -181,7 +181,7 @@ void __init ptp_classifier_init(void) | |||
181 | { 0x15, 0, 4, 0x00000000 }, | 181 | { 0x15, 0, 4, 0x00000000 }, |
182 | { 0x28, 0, 0, 0x0000000e }, | 182 | { 0x28, 0, 0, 0x0000000e }, |
183 | { 0x54, 0, 0, 0x0000000f }, | 183 | { 0x54, 0, 0, 0x0000000f }, |
184 | { 0x44, 0, 0, 0x00000030 }, | 184 | { 0x44, 0, 0, 0x00000040 }, |
185 | { 0x16, 0, 0, 0x00000000 }, | 185 | { 0x16, 0, 0, 0x00000000 }, |
186 | { 0x06, 0, 0, 0x00000000 }, | 186 | { 0x06, 0, 0, 0x00000000 }, |
187 | }; | 187 | }; |