aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/ptp_classifier.c
diff options
context:
space:
mode:
authorStefan Sørensen <stefan.sorensen@spectralink.com>2014-06-27 05:59:10 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-07 19:57:18 -0400
commitae5c6c6d7bcadfbedefb5fc8ff0ebe2bfa83a0a1 (patch)
treed1071ae8d47415a2575f689e54e35119f541befd /net/core/ptp_classifier.c
parentb9c701edc7ff6ddd522497b0194b0bc3ec1b51a9 (diff)
ptp: Classify ptp over ip over vlan packets
This extends the ptp bpf to also match ptp over ip over vlan packets. The ptp classes are changed to orthogonal bitfields representing version, transport and vlan values to simplify matching. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/ptp_classifier.c')
-rw-r--r--net/core/ptp_classifier.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/net/core/ptp_classifier.c b/net/core/ptp_classifier.c
index d3027a73fd4b..12ab7b4be609 100644
--- a/net/core/ptp_classifier.c
+++ b/net/core/ptp_classifier.c
@@ -52,14 +52,43 @@
52 * test_8021q: 52 * test_8021q:
53 * jneq #0x8100, test_ieee1588 ; ETH_P_8021Q ? 53 * jneq #0x8100, test_ieee1588 ; ETH_P_8021Q ?
54 * ldh [16] ; load inner type 54 * ldh [16] ; load inner type
55 * jneq #0x88f7, drop_ieee1588 ; ETH_P_1588 ? 55 * jneq #0x88f7, test_8021q_ipv4 ; ETH_P_1588 ?
56 * ldb [18] ; load payload 56 * ldb [18] ; load payload
57 * and #0x8 ; as we don't have ports here, test 57 * and #0x8 ; as we don't have ports here, test
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 #0x40 ; PTP_CLASS_V2_VLAN 61 * or #0x70 ; PTP_CLASS_VLAN|PTP_CLASS_L2
62 * ret a ; return PTP class
63 *
64 * ; PTP over UDP over IPv4 over 802.1Q over Ethernet
65 * test_8021q_ipv4:
66 * jneq #0x800, test_8021q_ipv6 ; ETH_P_IP ?
67 * ldb [27] ; load proto
68 * jneq #17, drop_8021q_ipv4 ; IPPROTO_UDP ?
69 * ldh [24] ; load frag offset field
70 * jset #0x1fff, drop_8021q_ipv4; don't allow fragments
71 * ldxb 4*([18]&0xf) ; load IP header len
72 * ldh [x + 20] ; load UDP dst port
73 * jneq #319, drop_8021q_ipv4 ; is port PTP_EV_PORT ?
74 * ldh [x + 26] ; load payload
75 * and #0xf ; mask PTP_CLASS_VMASK
76 * or #0x50 ; PTP_CLASS_VLAN|PTP_CLASS_IPV4
77 * ret a ; return PTP class
78 * drop_8021q_ipv4: ret #0x0 ; PTP_CLASS_NONE
79 *
80 * ; PTP over UDP over IPv6 over 802.1Q over Ethernet
81 * test_8021q_ipv6:
82 * jneq #0x86dd, drop_8021q_ipv6 ; ETH_P_IPV6 ?
83 * ldb [24] ; load proto
84 * jneq #17, drop_8021q_ipv6 ; IPPROTO_UDP ?
85 * ldh [60] ; load UDP dst port
86 * jneq #319, drop_8021q_ipv6 ; is port PTP_EV_PORT ?
87 * ldh [66] ; load payload
88 * and #0xf ; mask PTP_CLASS_VMASK
89 * or #0x60 ; PTP_CLASS_VLAN|PTP_CLASS_IPV6
62 * ret a ; return PTP class 90 * ret a ; return PTP class
91 * drop_8021q_ipv6: ret #0x0 ; PTP_CLASS_NONE
63 * 92 *
64 * ; PTP over Ethernet 93 * ; PTP over Ethernet
65 * test_ieee1588: 94 * test_ieee1588:
@@ -113,16 +142,39 @@ void __init ptp_classifier_init(void)
113 { 0x44, 0, 0, 0x00000020 }, 142 { 0x44, 0, 0, 0x00000020 },
114 { 0x16, 0, 0, 0x00000000 }, 143 { 0x16, 0, 0, 0x00000000 },
115 { 0x06, 0, 0, 0x00000000 }, 144 { 0x06, 0, 0, 0x00000000 },
116 { 0x15, 0, 9, 0x00008100 }, 145 { 0x15, 0, 32, 0x00008100 },
117 { 0x28, 0, 0, 0x00000010 }, 146 { 0x28, 0, 0, 0x00000010 },
118 { 0x15, 0, 15, 0x000088f7 }, 147 { 0x15, 0, 7, 0x000088f7 },
119 { 0x30, 0, 0, 0x00000012 }, 148 { 0x30, 0, 0, 0x00000012 },
120 { 0x54, 0, 0, 0x00000008 }, 149 { 0x54, 0, 0, 0x00000008 },
121 { 0x15, 0, 12, 0x00000000 }, 150 { 0x15, 0, 35, 0x00000000 },
122 { 0x28, 0, 0, 0x00000012 }, 151 { 0x28, 0, 0, 0x00000012 },
123 { 0x54, 0, 0, 0x0000000f }, 152 { 0x54, 0, 0, 0x0000000f },
124 { 0x44, 0, 0, 0x00000040 }, 153 { 0x44, 0, 0, 0x00000070 },
154 { 0x16, 0, 0, 0x00000000 },
155 { 0x15, 0, 12, 0x00000800 },
156 { 0x30, 0, 0, 0x0000001b },
157 { 0x15, 0, 9, 0x00000011 },
158 { 0x28, 0, 0, 0x00000018 },
159 { 0x45, 7, 0, 0x00001fff },
160 { 0xb1, 0, 0, 0x00000012 },
161 { 0x48, 0, 0, 0x00000014 },
162 { 0x15, 0, 4, 0x0000013f },
163 { 0x48, 0, 0, 0x0000001a },
164 { 0x54, 0, 0, 0x0000000f },
165 { 0x44, 0, 0, 0x00000050 },
166 { 0x16, 0, 0, 0x00000000 },
167 { 0x06, 0, 0, 0x00000000 },
168 { 0x15, 0, 8, 0x000086dd },
169 { 0x30, 0, 0, 0x00000018 },
170 { 0x15, 0, 6, 0x00000011 },
171 { 0x28, 0, 0, 0x0000003c },
172 { 0x15, 0, 4, 0x0000013f },
173 { 0x28, 0, 0, 0x00000042 },
174 { 0x54, 0, 0, 0x0000000f },
175 { 0x44, 0, 0, 0x00000060 },
125 { 0x16, 0, 0, 0x00000000 }, 176 { 0x16, 0, 0, 0x00000000 },
177 { 0x06, 0, 0, 0x00000000 },
126 { 0x15, 0, 7, 0x000088f7 }, 178 { 0x15, 0, 7, 0x000088f7 },
127 { 0x30, 0, 0, 0x0000000e }, 179 { 0x30, 0, 0, 0x0000000e },
128 { 0x54, 0, 0, 0x00000008 }, 180 { 0x54, 0, 0, 0x00000008 },