Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2022 Marvell.
3 : : */
4 : : #ifndef _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
5 : : #define _TEST_INLINE_IPSEC_REASSEMBLY_VECTORS_H_
6 : :
7 : : #include "test_cryptodev_security_ipsec.h"
8 : :
9 : : uint8_t dummy_ipv4_eth_hdr[] = {
10 : : /* ETH */
11 : : 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
12 : : 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00,
13 : : };
14 : : uint8_t dummy_ipv6_eth_hdr[] = {
15 : : /* ETH */
16 : : 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1,
17 : : 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd,
18 : : };
19 : :
20 : : #define MAX_FRAG_LEN IPSEC_TEXT_MAX_LEN
21 : : #define MAX_FRAGS 6
22 : : #define MAX_PKT_LEN (MAX_FRAG_LEN * MAX_FRAGS)
23 : :
24 : : struct ip_reassembly_test_packet {
25 : : uint32_t len;
26 : : uint32_t l4_offset;
27 : : uint8_t data[MAX_PKT_LEN];
28 : : };
29 : :
30 : : struct reassembly_vector {
31 : : /* input/output text in struct ipsec_test_data are not used */
32 : : struct ipsec_test_data *sa_data;
33 : : struct ip_reassembly_test_packet *full_pkt;
34 : : struct ip_reassembly_test_packet *frags[MAX_FRAGS];
35 : : uint16_t nb_frags;
36 : : bool burst;
37 : : };
38 : :
39 : : struct sa_expiry_vector {
40 : : struct ipsec_session_data *sa_data;
41 : : enum rte_eth_event_ipsec_subtype event;
42 : : bool notify_event;
43 : : };
44 : :
45 : : /* The source file includes below test vectors */
46 : : /* IPv6:
47 : : *
48 : : * 1) pkt_ipv6_udp_p1
49 : : * pkt_ipv6_udp_p1_f1
50 : : * pkt_ipv6_udp_p1_f2
51 : : *
52 : : * 2) pkt_ipv6_udp_p2
53 : : * pkt_ipv6_udp_p2_f1
54 : : * pkt_ipv6_udp_p2_f2
55 : : * pkt_ipv6_udp_p2_f3
56 : : * pkt_ipv6_udp_p2_f4
57 : : *
58 : : * 3) pkt_ipv6_udp_p3
59 : : * pkt_ipv6_udp_p3_f1
60 : : * pkt_ipv6_udp_p3_f2
61 : : * pkt_ipv6_udp_p3_f3
62 : : * pkt_ipv6_udp_p3_f4
63 : : * pkt_ipv6_udp_p3_f5
64 : : */
65 : :
66 : : /* IPv4:
67 : : *
68 : : * 1) pkt_ipv4_udp_p1
69 : : * pkt_ipv4_udp_p1_f1
70 : : * pkt_ipv4_udp_p1_f2
71 : : *
72 : : * 2) pkt_ipv4_udp_p2
73 : : * pkt_ipv4_udp_p2_f1
74 : : * pkt_ipv4_udp_p2_f2
75 : : * pkt_ipv4_udp_p2_f3
76 : : * pkt_ipv4_udp_p2_f4
77 : : *
78 : : * 3) pkt_ipv4_udp_p3
79 : : * pkt_ipv4_udp_p3_f1
80 : : * pkt_ipv4_udp_p3_f2
81 : : * pkt_ipv4_udp_p3_f3
82 : : * pkt_ipv4_udp_p3_f4
83 : : * pkt_ipv4_udp_p3_f5
84 : : */
85 : :
86 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p1 = {
87 : : .len = 1500,
88 : : .l4_offset = 40,
89 : : .data = {
90 : : /* IP */
91 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0xb4, 0x11, 0x40,
92 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
94 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
95 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
96 : :
97 : : /* UDP */
98 : : 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
99 : : },
100 : : };
101 : :
102 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f1 = {
103 : : .len = 1384,
104 : : .l4_offset = 48,
105 : : .data = {
106 : : /* IP */
107 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
108 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
110 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
112 : : 0x11, 0x00, 0x00, 0x01, 0x5c, 0x92, 0xac, 0xf1,
113 : :
114 : : /* UDP */
115 : : 0x08, 0x00, 0x27, 0x10, 0x05, 0xb4, 0x2b, 0xe8,
116 : : },
117 : : };
118 : :
119 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p1_f2 = {
120 : : .len = 172,
121 : : .l4_offset = 48,
122 : : .data = {
123 : : /* IP */
124 : : 0x60, 0x00, 0x00, 0x00, 0x00, 0x84, 0x2c, 0x40,
125 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
126 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
127 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
128 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
129 : : 0x11, 0x00, 0x05, 0x38, 0x5c, 0x92, 0xac, 0xf1,
130 : : },
131 : : };
132 : :
133 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p2 = {
134 : : .len = 4482,
135 : : .l4_offset = 40,
136 : : .data = {
137 : : /* IP */
138 : : 0x60, 0x00, 0x00, 0x00, 0x11, 0x5a, 0x11, 0x40,
139 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
141 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
143 : :
144 : : /* UDP */
145 : : 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
146 : : },
147 : : };
148 : :
149 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f1 = {
150 : : .len = 1384,
151 : : .l4_offset = 48,
152 : : .data = {
153 : : /* IP */
154 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
155 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
157 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
159 : : 0x11, 0x00, 0x00, 0x01, 0x64, 0x6c, 0x68, 0x9f,
160 : :
161 : : /* UDP */
162 : : 0x08, 0x00, 0x27, 0x10, 0x11, 0x5a, 0x8a, 0x11,
163 : : },
164 : : };
165 : :
166 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f2 = {
167 : : .len = 1384,
168 : : .l4_offset = 48,
169 : : .data = {
170 : : /* IP */
171 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
172 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
174 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
176 : : 0x11, 0x00, 0x05, 0x39, 0x64, 0x6c, 0x68, 0x9f,
177 : : },
178 : : };
179 : :
180 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f3 = {
181 : : .len = 1384,
182 : : .l4_offset = 48,
183 : : .data = {
184 : : /* IP */
185 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
186 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
188 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
190 : : 0x11, 0x00, 0x0a, 0x71, 0x64, 0x6c, 0x68, 0x9f,
191 : : },
192 : : };
193 : :
194 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p2_f4 = {
195 : : .len = 482,
196 : : .l4_offset = 48,
197 : : .data = {
198 : : /* IP */
199 : : 0x60, 0x00, 0x00, 0x00, 0x01, 0xba, 0x2c, 0x40,
200 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
202 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
204 : : 0x11, 0x00, 0x0f, 0xa8, 0x64, 0x6c, 0x68, 0x9f,
205 : : },
206 : : };
207 : :
208 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3 = {
209 : : .len = 5782,
210 : : .l4_offset = 40,
211 : : .data = {
212 : : /* IP */
213 : : 0x60, 0x00, 0x00, 0x00, 0x16, 0x6e, 0x2c, 0x40,
214 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
216 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
217 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
218 : :
219 : : /* UDP */
220 : : 0x08, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
221 : : },
222 : : };
223 : :
224 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f1 = {
225 : : .len = 1384,
226 : : .l4_offset = 48,
227 : : .data = {
228 : : /* IP */
229 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
230 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
232 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
233 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
234 : : 0x11, 0x00, 0x00, 0x01, 0x65, 0xcf, 0x5a, 0xae,
235 : :
236 : : /* UDP */
237 : : 0x80, 0x00, 0x27, 0x10, 0x16, 0x6e, 0x2f, 0x99,
238 : : },
239 : : };
240 : :
241 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f2 = {
242 : : .len = 1384,
243 : : .l4_offset = 48,
244 : : .data = {
245 : : /* IP */
246 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
247 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
249 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
251 : : 0x11, 0x00, 0x05, 0x39, 0x65, 0xcf, 0x5a, 0xae,
252 : : },
253 : : };
254 : :
255 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f3 = {
256 : : .len = 1384,
257 : : .l4_offset = 48,
258 : : .data = {
259 : : /* IP */
260 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
261 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
263 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
265 : : 0x11, 0x00, 0x0a, 0x71, 0x65, 0xcf, 0x5a, 0xae,
266 : : },
267 : : };
268 : :
269 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f4 = {
270 : : .len = 1384,
271 : : .l4_offset = 48,
272 : : .data = {
273 : : /* IP */
274 : : 0x60, 0x00, 0x00, 0x00, 0x05, 0x40, 0x2c, 0x40,
275 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
277 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
279 : : 0x11, 0x00, 0x0f, 0xa9, 0x65, 0xcf, 0x5a, 0xae,
280 : : },
281 : : };
282 : :
283 : : struct ip_reassembly_test_packet pkt_ipv6_udp_p3_f5 = {
284 : : .len = 446,
285 : : .l4_offset = 48,
286 : : .data = {
287 : : /* IP */
288 : : 0x60, 0x00, 0x00, 0x00, 0x01, 0x96, 0x2c, 0x40,
289 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 : : 0x00, 0x00, 0xff, 0xff, 0x0d, 0x00, 0x00, 0x02,
291 : : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 : : 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x02,
293 : : 0x11, 0x00, 0x14, 0xe0, 0x65, 0xcf, 0x5a, 0xae,
294 : : },
295 : : };
296 : :
297 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p1 = {
298 : : .len = 1500,
299 : : .l4_offset = 20,
300 : : .data = {
301 : : /* IP */
302 : : 0x45, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x00, 0x00,
303 : : 0x40, 0x11, 0x66, 0x0d, 0x0d, 0x00, 0x00, 0x02,
304 : : 0x02, 0x00, 0x00, 0x02,
305 : :
306 : : /* UDP */
307 : : 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
308 : : },
309 : : };
310 : :
311 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f1 = {
312 : : .len = 1420,
313 : : .l4_offset = 20,
314 : : .data = {
315 : : /* IP */
316 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x01, 0x20, 0x00,
317 : : 0x40, 0x11, 0x46, 0x5d, 0x0d, 0x00, 0x00, 0x02,
318 : : 0x02, 0x00, 0x00, 0x02,
319 : :
320 : : /* UDP */
321 : : 0x08, 0x00, 0x27, 0x10, 0x05, 0xc8, 0xb8, 0x4c,
322 : : },
323 : : };
324 : :
325 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p1_f2 = {
326 : : .len = 100,
327 : : .l4_offset = 20,
328 : : .data = {
329 : : /* IP */
330 : : 0x45, 0x00, 0x00, 0x64, 0x00, 0x01, 0x00, 0xaf,
331 : : 0x40, 0x11, 0x6a, 0xd6, 0x0d, 0x00, 0x00, 0x02,
332 : : 0x02, 0x00, 0x00, 0x02,
333 : : },
334 : : };
335 : :
336 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p2 = {
337 : : .len = 4482,
338 : : .l4_offset = 20,
339 : : .data = {
340 : : /* IP */
341 : : 0x45, 0x00, 0x11, 0x82, 0x00, 0x02, 0x00, 0x00,
342 : : 0x40, 0x11, 0x5a, 0x66, 0x0d, 0x00, 0x00, 0x02,
343 : : 0x02, 0x00, 0x00, 0x02,
344 : :
345 : : /* UDP */
346 : : 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
347 : : },
348 : : };
349 : :
350 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f1 = {
351 : : .len = 1420,
352 : : .l4_offset = 20,
353 : : .data = {
354 : : /* IP */
355 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0x00,
356 : : 0x40, 0x11, 0x46, 0x5c, 0x0d, 0x00, 0x00, 0x02,
357 : : 0x02, 0x00, 0x00, 0x02,
358 : :
359 : : /* UDP */
360 : : 0x08, 0x00, 0x27, 0x10, 0x11, 0x6e, 0x16, 0x76,
361 : : },
362 : : };
363 : :
364 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f2 = {
365 : : .len = 1420,
366 : : .l4_offset = 20,
367 : : .data = {
368 : : /* IP */
369 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x20, 0xaf,
370 : : 0x40, 0x11, 0x45, 0xad, 0x0d, 0x00, 0x00, 0x02,
371 : : 0x02, 0x00, 0x00, 0x02,
372 : : },
373 : : };
374 : :
375 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f3 = {
376 : : .len = 1420,
377 : : .l4_offset = 20,
378 : : .data = {
379 : : /* IP */
380 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x02, 0x21, 0x5e,
381 : : 0x40, 0x11, 0x44, 0xfe, 0x0d, 0x00, 0x00, 0x02,
382 : : 0x02, 0x00, 0x00, 0x02,
383 : : },
384 : : };
385 : :
386 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p2_f4 = {
387 : : .len = 282,
388 : : .l4_offset = 20,
389 : : .data = {
390 : : /* IP */
391 : : 0x45, 0x00, 0x01, 0x1a, 0x00, 0x02, 0x02, 0x0d,
392 : : 0x40, 0x11, 0x68, 0xc1, 0x0d, 0x00, 0x00, 0x02,
393 : : 0x02, 0x00, 0x00, 0x02,
394 : : },
395 : : };
396 : :
397 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3 = {
398 : : .len = 5782,
399 : : .l4_offset = 20,
400 : : .data = {
401 : : /* IP */
402 : : 0x45, 0x00, 0x16, 0x96, 0x00, 0x03, 0x00, 0x00,
403 : : 0x40, 0x11, 0x55, 0x51, 0x0d, 0x00, 0x00, 0x02,
404 : : 0x02, 0x00, 0x00, 0x02,
405 : :
406 : : /* UDP */
407 : : 0x08, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
408 : : },
409 : : };
410 : :
411 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f1 = {
412 : : .len = 1420,
413 : : .l4_offset = 20,
414 : : .data = {
415 : : /* IP */
416 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0x00,
417 : : 0x40, 0x11, 0x46, 0x5b, 0x0d, 0x00, 0x00, 0x02,
418 : : 0x02, 0x00, 0x00, 0x02,
419 : :
420 : : /* UDP */
421 : : 0x80, 0x00, 0x27, 0x10, 0x16, 0x82, 0xbb, 0xfd,
422 : : },
423 : : };
424 : :
425 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f2 = {
426 : : .len = 1420,
427 : : .l4_offset = 20,
428 : : .data = {
429 : : /* IP */
430 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x20, 0xaf,
431 : : 0x40, 0x11, 0x45, 0xac, 0x0d, 0x00, 0x00, 0x02,
432 : : 0x02, 0x00, 0x00, 0x02,
433 : : },
434 : : };
435 : :
436 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f3 = {
437 : : .len = 1420,
438 : : .l4_offset = 20,
439 : : .data = {
440 : : /* IP */
441 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x21, 0x5e,
442 : : 0x40, 0x11, 0x44, 0xfd, 0x0d, 0x00, 0x00, 0x02,
443 : : 0x02, 0x00, 0x00, 0x02,
444 : : },
445 : : };
446 : :
447 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f4 = {
448 : : .len = 1420,
449 : : .l4_offset = 20,
450 : : .data = {
451 : : /* IP */
452 : : 0x45, 0x00, 0x05, 0x8c, 0x00, 0x03, 0x22, 0x0d,
453 : : 0x40, 0x11, 0x44, 0x4e, 0x0d, 0x00, 0x00, 0x02,
454 : : 0x02, 0x00, 0x00, 0x02,
455 : : },
456 : : };
457 : :
458 : : struct ip_reassembly_test_packet pkt_ipv4_udp_p3_f5 = {
459 : : .len = 182,
460 : : .l4_offset = 20,
461 : : .data = {
462 : : /* IP */
463 : : 0x45, 0x00, 0x00, 0xb6, 0x00, 0x03, 0x02, 0xbc,
464 : : 0x40, 0x11, 0x68, 0x75, 0x0d, 0x00, 0x00, 0x02,
465 : : 0x02, 0x00, 0x00, 0x02,
466 : : },
467 : : };
468 : :
469 : : static inline void
470 : 0 : test_vector_payload_populate(struct ip_reassembly_test_packet *pkt,
471 : : bool first_frag, uint16_t extra_data, uint16_t extra_data_sum)
472 : : {
473 : 0 : bool is_ipv6 = ((pkt->data[0] >> 4) == 0x6);
474 : 0 : uint32_t i = pkt->l4_offset;
475 : : uint16_t len, off;
476 : 0 : size_t ext_len = 0;
477 : : int proto;
478 : :
479 : : /**
480 : : * For non-fragmented packets and first frag, skip 8 bytes from
481 : : * l4_offset for UDP header.
482 : : */
483 [ # # ]: 0 : if (first_frag)
484 : 0 : i += 8;
485 : :
486 : : /* Fixup header and checksum */
487 [ # # ]: 0 : if (extra_data || extra_data_sum) {
488 [ # # ]: 0 : if (is_ipv6) {
489 : : struct rte_ipv6_hdr *hdr = (struct rte_ipv6_hdr *)pkt->data;
490 : : struct rte_ipv6_fragment_ext *frag_ext;
491 : : uint8_t *p = pkt->data;
492 : : uint16_t old_off;
493 : :
494 [ # # ]: 0 : len = rte_be_to_cpu_16(hdr->payload_len) + extra_data;
495 [ # # ]: 0 : hdr->payload_len = rte_cpu_to_be_16(len);
496 : :
497 : : /* Find frag extension header to add to frag offset */
498 [ # # ]: 0 : if (extra_data_sum) {
499 : 0 : proto = hdr->proto;
500 : 0 : p += sizeof(struct rte_ipv6_hdr);
501 [ # # ]: 0 : while (proto != IPPROTO_FRAGMENT &&
502 [ # # ]: 0 : (proto = rte_ipv6_get_next_ext(p, proto, &ext_len) >= 0))
503 : 0 : p += ext_len;
504 : :
505 : : /* Found fragment header, update the frag offset */
506 [ # # ]: 0 : if (proto == IPPROTO_FRAGMENT) {
507 : : frag_ext = (struct rte_ipv6_fragment_ext *)p;
508 [ # # ]: 0 : old_off = rte_be_to_cpu_16(frag_ext->frag_data);
509 : 0 : off = old_off & 0xFFF8;
510 : 0 : off += extra_data_sum;
511 [ # # ]: 0 : frag_ext->frag_data = rte_cpu_to_be_16(off |
512 : : (old_off & 0x7));
513 : : }
514 : : }
515 : : } else {
516 : 0 : struct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)pkt->data;
517 [ # # ]: 0 : uint16_t old_off = rte_be_to_cpu_16(hdr->fragment_offset);
518 : :
519 [ # # ]: 0 : len = rte_be_to_cpu_16(hdr->total_length) + extra_data;
520 : 0 : off = old_off & 0x1FFF;
521 : 0 : off += (extra_data_sum >> 3);
522 : :
523 [ # # ]: 0 : hdr->total_length = rte_cpu_to_be_16(len);
524 [ # # ]: 0 : hdr->fragment_offset = rte_cpu_to_be_16(off | (old_off & 0xe000));
525 : 0 : hdr->hdr_checksum = 0;
526 : 0 : hdr->hdr_checksum = rte_ipv4_cksum(hdr);
527 : : }
528 : 0 : pkt->len += extra_data;
529 : : }
530 : :
531 [ # # ]: 0 : for (; i < pkt->len; i++)
532 : 0 : pkt->data[i] = 0x58;
533 : 0 : }
534 : :
535 : : struct ipsec_test_data conf_aes_128_gcm = {
536 : : .key = {
537 : : .data = {
538 : : 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
539 : : 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
540 : : },
541 : : },
542 : :
543 : : .salt = {
544 : : .data = {
545 : : 0xca, 0xfe, 0xba, 0xbe
546 : : },
547 : : .len = 4,
548 : : },
549 : :
550 : : .iv = {
551 : : .data = {
552 : : 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
553 : : },
554 : : },
555 : :
556 : : .ipsec_xform = {
557 : : .spi = 0xa5f8,
558 : : .salt = 0xbebafeca,
559 : : .options.esn = 0,
560 : : .options.udp_encap = 0,
561 : : .options.copy_dscp = 0,
562 : : .options.copy_flabel = 0,
563 : : .options.copy_df = 0,
564 : : .options.dec_ttl = 0,
565 : : .options.ecn = 0,
566 : : .options.stats = 0,
567 : : .options.tunnel_hdr_verify = 0,
568 : : .options.ip_csum_enable = 0,
569 : : .options.l4_csum_enable = 0,
570 : : .options.ip_reassembly_en = 1,
571 : : .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
572 : : .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
573 : : .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
574 : : .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
575 : : .replay_win_sz = 0,
576 : : },
577 : :
578 : : .aead = true,
579 : :
580 : : .xform = {
581 : : .aead = {
582 : : .next = NULL,
583 : : .type = RTE_CRYPTO_SYM_XFORM_AEAD,
584 : : .aead = {
585 : : .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
586 : : .algo = RTE_CRYPTO_AEAD_AES_GCM,
587 : : .key.length = 16,
588 : : .iv.length = 12,
589 : : .iv.offset = 0,
590 : : .digest_length = 16,
591 : : .aad_length = 12,
592 : : },
593 : : },
594 : : },
595 : : };
596 : :
597 : : struct ipsec_test_data conf_aes_128_gcm_v6_tunnel = {
598 : : .key = {
599 : : .data = {
600 : : 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
601 : : 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
602 : : },
603 : : },
604 : :
605 : : .salt = {
606 : : .data = {
607 : : 0xca, 0xfe, 0xba, 0xbe
608 : : },
609 : : .len = 4,
610 : : },
611 : :
612 : : .iv = {
613 : : .data = {
614 : : 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88
615 : : },
616 : : },
617 : :
618 : : .ipsec_xform = {
619 : : .spi = 0xa5f8,
620 : : .salt = 0xbebafeca,
621 : : .options.esn = 0,
622 : : .options.udp_encap = 0,
623 : : .options.copy_dscp = 0,
624 : : .options.copy_flabel = 0,
625 : : .options.copy_df = 0,
626 : : .options.dec_ttl = 0,
627 : : .options.ecn = 0,
628 : : .options.stats = 0,
629 : : .options.tunnel_hdr_verify = 0,
630 : : .options.ip_csum_enable = 0,
631 : : .options.l4_csum_enable = 0,
632 : : .options.ip_reassembly_en = 1,
633 : : .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
634 : : .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
635 : : .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
636 : : .tunnel.type = RTE_SECURITY_IPSEC_TUNNEL_IPV4,
637 : : .replay_win_sz = 0,
638 : : },
639 : :
640 : : .aead = true,
641 : :
642 : : .xform = {
643 : : .aead = {
644 : : .next = NULL,
645 : : .type = RTE_CRYPTO_SYM_XFORM_AEAD,
646 : : .aead = {
647 : : .op = RTE_CRYPTO_AEAD_OP_ENCRYPT,
648 : : .algo = RTE_CRYPTO_AEAD_AES_GCM,
649 : : .key.length = 16,
650 : : .iv.length = 12,
651 : : .iv.offset = 0,
652 : : .digest_length = 16,
653 : : .aad_length = 12,
654 : : },
655 : : },
656 : : },
657 : : };
658 : :
659 : : const struct reassembly_vector ipv4_2frag_vector = {
660 : : .sa_data = &conf_aes_128_gcm,
661 : : .full_pkt = &pkt_ipv4_udp_p1,
662 : : .frags[0] = &pkt_ipv4_udp_p1_f1,
663 : : .frags[1] = &pkt_ipv4_udp_p1_f2,
664 : : .nb_frags = 2,
665 : : .burst = false,
666 : : };
667 : :
668 : : const struct reassembly_vector ipv6_2frag_vector = {
669 : : .sa_data = &conf_aes_128_gcm_v6_tunnel,
670 : : .full_pkt = &pkt_ipv6_udp_p1,
671 : : .frags[0] = &pkt_ipv6_udp_p1_f1,
672 : : .frags[1] = &pkt_ipv6_udp_p1_f2,
673 : : .nb_frags = 2,
674 : : .burst = false,
675 : : };
676 : :
677 : : const struct reassembly_vector ipv4_4frag_vector = {
678 : : .sa_data = &conf_aes_128_gcm,
679 : : .full_pkt = &pkt_ipv4_udp_p2,
680 : : .frags[0] = &pkt_ipv4_udp_p2_f1,
681 : : .frags[1] = &pkt_ipv4_udp_p2_f2,
682 : : .frags[2] = &pkt_ipv4_udp_p2_f3,
683 : : .frags[3] = &pkt_ipv4_udp_p2_f4,
684 : : .nb_frags = 4,
685 : : .burst = false,
686 : : };
687 : :
688 : : const struct reassembly_vector ipv6_4frag_vector = {
689 : : .sa_data = &conf_aes_128_gcm_v6_tunnel,
690 : : .full_pkt = &pkt_ipv6_udp_p2,
691 : : .frags[0] = &pkt_ipv6_udp_p2_f1,
692 : : .frags[1] = &pkt_ipv6_udp_p2_f2,
693 : : .frags[2] = &pkt_ipv6_udp_p2_f3,
694 : : .frags[3] = &pkt_ipv6_udp_p2_f4,
695 : : .nb_frags = 4,
696 : : .burst = false,
697 : : };
698 : : const struct reassembly_vector ipv4_5frag_vector = {
699 : : .sa_data = &conf_aes_128_gcm,
700 : : .full_pkt = &pkt_ipv4_udp_p3,
701 : : .frags[0] = &pkt_ipv4_udp_p3_f1,
702 : : .frags[1] = &pkt_ipv4_udp_p3_f2,
703 : : .frags[2] = &pkt_ipv4_udp_p3_f3,
704 : : .frags[3] = &pkt_ipv4_udp_p3_f4,
705 : : .frags[4] = &pkt_ipv4_udp_p3_f5,
706 : : .nb_frags = 5,
707 : : .burst = false,
708 : : };
709 : : const struct reassembly_vector ipv6_5frag_vector = {
710 : : .sa_data = &conf_aes_128_gcm_v6_tunnel,
711 : : .full_pkt = &pkt_ipv6_udp_p3,
712 : : .frags[0] = &pkt_ipv6_udp_p3_f1,
713 : : .frags[1] = &pkt_ipv6_udp_p3_f2,
714 : : .frags[2] = &pkt_ipv6_udp_p3_f3,
715 : : .frags[3] = &pkt_ipv6_udp_p3_f4,
716 : : .frags[4] = &pkt_ipv6_udp_p3_f5,
717 : : .nb_frags = 5,
718 : : .burst = false,
719 : : };
720 : : /* Negative test cases. */
721 : : const struct reassembly_vector ipv4_incomplete_vector = {
722 : : .sa_data = &conf_aes_128_gcm,
723 : : .full_pkt = &pkt_ipv4_udp_p2,
724 : : .frags[0] = &pkt_ipv4_udp_p2_f1,
725 : : .frags[1] = &pkt_ipv4_udp_p2_f2,
726 : : .nb_frags = 2,
727 : : .burst = false,
728 : : };
729 : : const struct reassembly_vector ipv4_overlap_vector = {
730 : : .sa_data = &conf_aes_128_gcm,
731 : : .full_pkt = &pkt_ipv4_udp_p1,
732 : : .frags[0] = &pkt_ipv4_udp_p1_f1,
733 : : .frags[1] = &pkt_ipv4_udp_p1_f1, /* Overlap */
734 : : .frags[2] = &pkt_ipv4_udp_p1_f2,
735 : : .nb_frags = 3,
736 : : .burst = false,
737 : : };
738 : : const struct reassembly_vector ipv4_out_of_order_vector = {
739 : : .sa_data = &conf_aes_128_gcm,
740 : : .full_pkt = &pkt_ipv4_udp_p2,
741 : : .frags[0] = &pkt_ipv4_udp_p2_f1,
742 : : .frags[1] = &pkt_ipv4_udp_p2_f3,
743 : : .frags[2] = &pkt_ipv4_udp_p2_f4,
744 : : .frags[3] = &pkt_ipv4_udp_p2_f2, /* out of order */
745 : : .nb_frags = 4,
746 : : .burst = false,
747 : : };
748 : : const struct reassembly_vector ipv4_4frag_burst_vector = {
749 : : .sa_data = &conf_aes_128_gcm,
750 : : .full_pkt = &pkt_ipv4_udp_p2,
751 : : .frags[0] = &pkt_ipv4_udp_p2_f1,
752 : : .frags[1] = &pkt_ipv4_udp_p2_f2,
753 : : .frags[2] = &pkt_ipv4_udp_p2_f3,
754 : : .frags[3] = &pkt_ipv4_udp_p2_f4,
755 : : .nb_frags = 4,
756 : : .burst = true,
757 : : };
758 : :
759 : : #endif
|