blob: 7f6c5ca4af768d919b790f9787ea66904a2544e5 [file] [log] [blame]
Klement Sekera75e7d132017-09-20 08:26:30 +02001/*
2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @brief IPv6 Reassembly.
19 *
20 * This file contains the source code for IPv6 reassembly.
21 */
22
23#include <vppinfra/vec.h>
24#include <vnet/vnet.h>
25#include <vnet/ip/ip.h>
26#include <vppinfra/bihash_48_8.h>
27#include <vnet/ip/ip6_reassembly.h>
28
29#define MSEC_PER_SEC 1000
30#define IP6_REASS_TIMEOUT_DEFAULT_MS 100
31#define IP6_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS 10000 // 10 seconds default
Klement Sekera4c533132018-02-22 11:41:12 +010032#define IP6_REASS_MAX_REASSEMBLIES_DEFAULT 1024
Klement Sekera75e7d132017-09-20 08:26:30 +020033#define IP6_REASS_HT_LOAD_FACTOR (0.75)
34
35static vlib_node_registration_t ip6_reass_node;
36
37typedef struct
38{
39 union
40 {
41 struct
42 {
43 ip6_address_t src;
44 ip6_address_t dst;
Klement Sekera75e7d132017-09-20 08:26:30 +020045 u32 xx_id;
Klement Sekera75e7d132017-09-20 08:26:30 +020046 u32 frag_id;
Klement Sekera8dcfed52018-06-28 11:16:15 +020047 u8 unused[7];
48 u8 proto;
Klement Sekera75e7d132017-09-20 08:26:30 +020049 };
50 u64 as_u64[6];
51 };
52} ip6_reass_key_t;
53
54always_inline u32
55ip6_reass_buffer_get_data_offset_no_check (vlib_buffer_t * b)
56{
57 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
58 return vnb->ip.reass.range_first - vnb->ip.reass.fragment_first;
59}
60
61always_inline u32
62ip6_reass_buffer_get_data_offset (vlib_buffer_t * b)
63{
64 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
65 ASSERT (vnb->ip.reass.range_first >= vnb->ip.reass.fragment_first);
66 return ip6_reass_buffer_get_data_offset_no_check (b);
67}
68
69always_inline u16
70ip6_reass_buffer_get_data_len_no_check (vlib_buffer_t * b)
71{
72 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
73 return clib_min (vnb->ip.reass.range_last, vnb->ip.reass.fragment_last) -
74 (vnb->ip.reass.fragment_first + ip6_reass_buffer_get_data_offset (b)) + 1;
75}
76
77always_inline u16
78ip6_reass_buffer_get_data_len (vlib_buffer_t * b)
79{
80 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
81 ASSERT (vnb->ip.reass.range_last > vnb->ip.reass.fragment_first);
82 return ip6_reass_buffer_get_data_len_no_check (b);
83}
84
85typedef struct
86{
87 // hash table key
88 ip6_reass_key_t key;
Klement Sekera75e7d132017-09-20 08:26:30 +020089 // time when last packet was received
90 f64 last_heard;
91 // internal id of this reassembly
Klement Sekera4c533132018-02-22 11:41:12 +010092 u64 id;
Klement Sekera75e7d132017-09-20 08:26:30 +020093 // buffer index of first buffer in this reassembly context
94 u32 first_bi;
95 // last octet of packet, ~0 until fragment without more_fragments arrives
96 u32 last_packet_octet;
97 // length of data collected so far
98 u32 data_len;
99 // trace operation counter
100 u32 trace_op_counter;
Klement Sekera4c533132018-02-22 11:41:12 +0100101 // next index - used by non-feature node
102 u8 next_index;
103 // minimum fragment length for this reassembly - used to estimate MTU
104 u16 min_fragment_length;
Klement Sekera75e7d132017-09-20 08:26:30 +0200105} ip6_reass_t;
106
107typedef struct
108{
Klement Sekera4c533132018-02-22 11:41:12 +0100109 ip6_reass_t *pool;
110 u32 reass_n;
111 u32 buffers_n;
112 u32 id_counter;
113 clib_spinlock_t lock;
114} ip6_reass_per_thread_t;
115
116typedef struct
117{
Klement Sekera75e7d132017-09-20 08:26:30 +0200118 // IPv6 config
119 u32 timeout_ms;
120 f64 timeout;
121 u32 expire_walk_interval_ms;
122 u32 max_reass_n;
123
124 // IPv6 runtime
Klement Sekera75e7d132017-09-20 08:26:30 +0200125 clib_bihash_48_8_t hash;
Klement Sekera4c533132018-02-22 11:41:12 +0100126
127 // per-thread data
128 ip6_reass_per_thread_t *per_thread_data;
Klement Sekera75e7d132017-09-20 08:26:30 +0200129
130 // convenience
131 vlib_main_t *vlib_main;
132 vnet_main_t *vnet_main;
133
134 // node index of ip6-drop node
135 u32 ip6_drop_idx;
136 u32 ip6_icmp_error_idx;
137 u32 ip6_reass_expire_node_idx;
138
139} ip6_reass_main_t;
140
141ip6_reass_main_t ip6_reass_main;
142
143typedef enum
144{
145 IP6_REASSEMBLY_NEXT_INPUT,
146 IP6_REASSEMBLY_NEXT_DROP,
147 IP6_REASSEMBLY_NEXT_ICMP_ERROR,
148 IP6_REASSEMBLY_N_NEXT,
149} ip6_reass_next_t;
150
151typedef enum
152{
153 RANGE_NEW,
154 RANGE_OVERLAP,
155 ICMP_ERROR_RT_EXCEEDED,
156 ICMP_ERROR_FL_TOO_BIG,
157 ICMP_ERROR_FL_NOT_MULT_8,
158 FINALIZE,
159} ip6_reass_trace_operation_e;
160
161typedef struct
162{
163 u16 range_first;
164 u16 range_last;
165 u32 range_bi;
166 i32 data_offset;
167 u32 data_len;
168 u32 first_bi;
169} ip6_reass_range_trace_t;
170
171typedef struct
172{
173 ip6_reass_trace_operation_e action;
Klement Sekera75e7d132017-09-20 08:26:30 +0200174 u32 reass_id;
175 ip6_reass_range_trace_t trace_range;
176 u32 size_diff;
177 u32 op_id;
178 u32 fragment_first;
179 u32 fragment_last;
180 u32 total_data_len;
181} ip6_reass_trace_t;
182
183static void
184ip6_reass_trace_details (vlib_main_t * vm, u32 bi,
185 ip6_reass_range_trace_t * trace)
186{
187 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
188 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
189 trace->range_first = vnb->ip.reass.range_first;
190 trace->range_last = vnb->ip.reass.range_last;
191 trace->data_offset = ip6_reass_buffer_get_data_offset_no_check (b);
192 trace->data_len = ip6_reass_buffer_get_data_len_no_check (b);
193 trace->range_bi = bi;
194}
195
Klement Sekera4c533132018-02-22 11:41:12 +0100196static u8 *
Klement Sekera75e7d132017-09-20 08:26:30 +0200197format_ip6_reass_range_trace (u8 * s, va_list * args)
198{
199 ip6_reass_range_trace_t *trace = va_arg (*args, ip6_reass_range_trace_t *);
200 s = format (s, "range: [%u, %u], off %d, len %u, bi %u", trace->range_first,
201 trace->range_last, trace->data_offset, trace->data_len,
202 trace->range_bi);
203 return s;
204}
205
Klement Sekera4c533132018-02-22 11:41:12 +0100206static u8 *
Klement Sekera75e7d132017-09-20 08:26:30 +0200207format_ip6_reass_trace (u8 * s, va_list * args)
208{
209 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
210 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
211 ip6_reass_trace_t *t = va_arg (*args, ip6_reass_trace_t *);
212 s = format (s, "reass id: %u, op id: %u ", t->reass_id, t->op_id);
213 u32 indent = format_get_indent (s);
214 s = format (s, "first bi: %u, data len: %u, ip/fragment[%u, %u]",
215 t->trace_range.first_bi, t->total_data_len, t->fragment_first,
216 t->fragment_last);
217 switch (t->action)
218 {
219 case RANGE_NEW:
220 s = format (s, "\n%Unew %U", format_white_space, indent,
221 format_ip6_reass_range_trace, &t->trace_range);
222 break;
223 case RANGE_OVERLAP:
224 s = format (s, "\n%Uoverlap %U", format_white_space, indent,
225 format_ip6_reass_range_trace, &t->trace_range);
226 break;
227 case ICMP_ERROR_FL_TOO_BIG:
228 s = format (s, "\n%Uicmp-error - frag_len > 65535 %U",
229 format_white_space, indent, format_ip6_reass_range_trace,
230 &t->trace_range);
231 break;
232 case ICMP_ERROR_FL_NOT_MULT_8:
233 s = format (s, "\n%Uicmp-error - frag_len mod 8 != 0 %U",
234 format_white_space, indent, format_ip6_reass_range_trace,
235 &t->trace_range);
236 break;
237 case ICMP_ERROR_RT_EXCEEDED:
238 s = format (s, "\n%Uicmp-error - reassembly time exceeded",
239 format_white_space, indent);
240 break;
241 case FINALIZE:
242 s = format (s, "\n%Ufinalize reassembly", format_white_space, indent);
243 break;
244 }
245 return s;
246}
247
248static void
249ip6_reass_add_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
250 ip6_reass_main_t * rm, ip6_reass_t * reass,
251 u32 bi, ip6_reass_trace_operation_e action,
252 u32 size_diff)
253{
254 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
255 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
Klement Sekera4c533132018-02-22 11:41:12 +0100256 if (pool_is_free_index (vm->trace_main.trace_buffer_pool, b->trace_index))
257 {
258 // this buffer's trace is gone
259 b->flags &= ~VLIB_BUFFER_IS_TRACED;
260 return;
261 }
Klement Sekera75e7d132017-09-20 08:26:30 +0200262 ip6_reass_trace_t *t = vlib_add_trace (vm, node, b, sizeof (t[0]));
Klement Sekera75e7d132017-09-20 08:26:30 +0200263 t->reass_id = reass->id;
264 t->action = action;
265 ip6_reass_trace_details (vm, bi, &t->trace_range);
266 t->size_diff = size_diff;
267 t->op_id = reass->trace_op_counter;
268 ++reass->trace_op_counter;
269 t->fragment_first = vnb->ip.reass.fragment_first;
270 t->fragment_last = vnb->ip.reass.fragment_last;
271 t->trace_range.first_bi = reass->first_bi;
272 t->total_data_len = reass->data_len;
273#if 0
274 static u8 *s = NULL;
275 s = format (s, "%U", format_ip6_reass_trace, NULL, NULL, t);
276 printf ("%.*s\n", vec_len (s), s);
277 fflush (stdout);
278 vec_reset_length (s);
279#endif
280}
281
Klement Sekera4c533132018-02-22 11:41:12 +0100282always_inline void
283ip6_reass_free (ip6_reass_main_t * rm, ip6_reass_per_thread_t * rt,
284 ip6_reass_t * reass)
Klement Sekera75e7d132017-09-20 08:26:30 +0200285{
286 clib_bihash_kv_48_8_t kv;
287 kv.key[0] = reass->key.as_u64[0];
288 kv.key[1] = reass->key.as_u64[1];
289 kv.key[2] = reass->key.as_u64[2];
290 kv.key[3] = reass->key.as_u64[3];
291 kv.key[4] = reass->key.as_u64[4];
292 kv.key[5] = reass->key.as_u64[5];
293 clib_bihash_add_del_48_8 (&rm->hash, &kv, 0);
Klement Sekera4c533132018-02-22 11:41:12 +0100294 pool_put (rt->pool, reass);
295 --rt->reass_n;
Klement Sekera75e7d132017-09-20 08:26:30 +0200296}
297
Klement Sekera4c533132018-02-22 11:41:12 +0100298always_inline void
Klement Sekera75e7d132017-09-20 08:26:30 +0200299ip6_reass_drop_all (vlib_main_t * vm, ip6_reass_main_t * rm,
300 ip6_reass_t * reass, u32 ** vec_drop_bi)
301{
302 u32 range_bi = reass->first_bi;
303 vlib_buffer_t *range_b;
304 vnet_buffer_opaque_t *range_vnb;
305 while (~0 != range_bi)
306 {
307 range_b = vlib_get_buffer (vm, range_bi);
308 range_vnb = vnet_buffer (range_b);
309 u32 bi = range_bi;
310 while (~0 != bi)
311 {
312 vec_add1 (*vec_drop_bi, bi);
313 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
314 if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
315 {
316 bi = b->next_buffer;
317 b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
318 }
319 else
320 {
321 bi = ~0;
322 }
323 }
324 range_bi = range_vnb->ip.reass.next_range_bi;
325 }
326}
327
Klement Sekera4c533132018-02-22 11:41:12 +0100328always_inline void
Klement Sekera75e7d132017-09-20 08:26:30 +0200329ip6_reass_on_timeout (vlib_main_t * vm, vlib_node_runtime_t * node,
330 ip6_reass_main_t * rm, ip6_reass_t * reass,
331 u32 * icmp_bi, u32 ** vec_timeout)
332{
333 if (~0 == reass->first_bi)
334 {
335 return;
336 }
337 vlib_buffer_t *b = vlib_get_buffer (vm, reass->first_bi);
338 if (0 == vnet_buffer (b)->ip.reass.fragment_first)
339 {
340 *icmp_bi = reass->first_bi;
341 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
342 {
343 ip6_reass_add_trace (vm, node, rm, reass, reass->first_bi,
344 ICMP_ERROR_RT_EXCEEDED, 0);
345 }
346 // fragment with offset zero received - send icmp message back
347 if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
348 {
349 // separate first buffer from chain and steer it towards icmp node
350 b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
351 reass->first_bi = b->next_buffer;
352 }
353 else
354 {
355 reass->first_bi = vnet_buffer (b)->ip.reass.next_range_bi;
356 }
357 icmp6_error_set_vnet_buffer (b, ICMP6_time_exceeded,
358 ICMP6_time_exceeded_fragment_reassembly_time_exceeded,
359 0);
360 }
361 ip6_reass_drop_all (vm, rm, reass, vec_timeout);
362}
363
Klement Sekera4c533132018-02-22 11:41:12 +0100364always_inline ip6_reass_t *
365ip6_reass_find_or_create (vlib_main_t * vm, vlib_node_runtime_t * node,
366 ip6_reass_main_t * rm, ip6_reass_per_thread_t * rt,
Klement Sekera75e7d132017-09-20 08:26:30 +0200367 ip6_reass_key_t * k, u32 * icmp_bi,
368 u32 ** vec_timeout)
369{
370 ip6_reass_t *reass = NULL;
371 f64 now = vlib_time_now (rm->vlib_main);
372 clib_bihash_kv_48_8_t kv, value;
373 kv.key[0] = k->as_u64[0];
374 kv.key[1] = k->as_u64[1];
375 kv.key[2] = k->as_u64[2];
376 kv.key[3] = k->as_u64[3];
377 kv.key[4] = k->as_u64[4];
378 kv.key[5] = k->as_u64[5];
379
380 if (!clib_bihash_search_48_8 (&rm->hash, &kv, &value))
381 {
Klement Sekera4c533132018-02-22 11:41:12 +0100382 reass = pool_elt_at_index (rt->pool, value.value);
Klement Sekera75e7d132017-09-20 08:26:30 +0200383 if (now > reass->last_heard + rm->timeout)
384 {
385 ip6_reass_on_timeout (vm, node, rm, reass, icmp_bi, vec_timeout);
Klement Sekera4c533132018-02-22 11:41:12 +0100386 ip6_reass_free (rm, rt, reass);
Klement Sekera75e7d132017-09-20 08:26:30 +0200387 reass = NULL;
388 }
389 }
390
391 if (reass)
392 {
393 reass->last_heard = now;
394 return reass;
395 }
396
Klement Sekera4c533132018-02-22 11:41:12 +0100397 if (rt->reass_n >= rm->max_reass_n)
Klement Sekera75e7d132017-09-20 08:26:30 +0200398 {
399 reass = NULL;
400 return reass;
401 }
402 else
403 {
Klement Sekera4c533132018-02-22 11:41:12 +0100404 pool_get (rt->pool, reass);
Dave Barachb7b92992018-10-17 10:38:51 -0400405 clib_memset (reass, 0, sizeof (*reass));
Klement Sekera4c533132018-02-22 11:41:12 +0100406 reass->id =
407 ((u64) os_get_thread_index () * 1000000000) + rt->id_counter;
408 ++rt->id_counter;
Klement Sekera75e7d132017-09-20 08:26:30 +0200409 reass->first_bi = ~0;
410 reass->last_packet_octet = ~0;
411 reass->data_len = 0;
Klement Sekera4c533132018-02-22 11:41:12 +0100412 ++rt->reass_n;
Klement Sekera75e7d132017-09-20 08:26:30 +0200413 }
414
415 reass->key.as_u64[0] = kv.key[0] = k->as_u64[0];
416 reass->key.as_u64[1] = kv.key[1] = k->as_u64[1];
417 reass->key.as_u64[2] = kv.key[2] = k->as_u64[2];
418 reass->key.as_u64[3] = kv.key[3] = k->as_u64[3];
419 reass->key.as_u64[4] = kv.key[4] = k->as_u64[4];
420 reass->key.as_u64[5] = kv.key[5] = k->as_u64[5];
Klement Sekera4c533132018-02-22 11:41:12 +0100421 kv.value = reass - rt->pool;
Klement Sekera75e7d132017-09-20 08:26:30 +0200422 reass->last_heard = now;
423
424 if (clib_bihash_add_del_48_8 (&rm->hash, &kv, 1))
425 {
Klement Sekera4c533132018-02-22 11:41:12 +0100426 ip6_reass_free (rm, rt, reass);
Klement Sekera75e7d132017-09-20 08:26:30 +0200427 reass = NULL;
428 }
429
430 return reass;
431}
432
Klement Sekera4c533132018-02-22 11:41:12 +0100433always_inline void
Klement Sekera75e7d132017-09-20 08:26:30 +0200434ip6_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
Klement Sekera4c533132018-02-22 11:41:12 +0100435 ip6_reass_main_t * rm, ip6_reass_per_thread_t * rt,
436 ip6_reass_t * reass, u32 * bi0, u32 * next0,
Damjan Marionaa682a32018-04-26 22:45:40 +0200437 u32 * error0, u32 ** vec_drop_compress, bool is_feature)
Klement Sekera75e7d132017-09-20 08:26:30 +0200438{
439 ASSERT (~0 != reass->first_bi);
440 *bi0 = reass->first_bi;
Klement Sekera75e7d132017-09-20 08:26:30 +0200441 *error0 = IP6_ERROR_NONE;
442 ip6_frag_hdr_t *frag_hdr;
443 vlib_buffer_t *last_b = NULL;
444 u32 sub_chain_bi = reass->first_bi;
445 u32 total_length = 0;
446 u32 buf_cnt = 0;
447 u32 dropped_cnt = 0;
448 do
449 {
450 u32 tmp_bi = sub_chain_bi;
451 vlib_buffer_t *tmp = vlib_get_buffer (vm, tmp_bi);
452 u32 data_len = ip6_reass_buffer_get_data_len (tmp);
453 u32 trim_front = vnet_buffer (tmp)->ip.reass.ip6_frag_hdr_offset +
454 sizeof (*frag_hdr) + ip6_reass_buffer_get_data_offset (tmp);
455 u32 trim_end =
456 vlib_buffer_length_in_chain (vm, tmp) - trim_front - data_len;
457 if (tmp_bi == reass->first_bi)
458 {
459 /* first buffer - keep ip6 header */
460 ASSERT (0 == ip6_reass_buffer_get_data_offset (tmp));
461 trim_front = 0;
462 trim_end = vlib_buffer_length_in_chain (vm, tmp) - data_len -
463 (vnet_buffer (tmp)->ip.reass.ip6_frag_hdr_offset +
464 sizeof (*frag_hdr));
Klement Sekera56e6f092018-02-02 16:17:55 +0100465 ASSERT (vlib_buffer_length_in_chain (vm, tmp) - trim_end > 0);
Klement Sekera75e7d132017-09-20 08:26:30 +0200466 }
467 u32 keep_data =
468 vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
469 while (1)
470 {
471 ++buf_cnt;
472 if (trim_front)
473 {
474 if (trim_front > tmp->current_length)
475 {
476 /* drop whole buffer */
477 vec_add1 (*vec_drop_compress, tmp_bi);
478 ++dropped_cnt;
479 trim_front -= tmp->current_length;
480 ASSERT (tmp->flags & VLIB_BUFFER_NEXT_PRESENT);
481 tmp->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
482 tmp_bi = tmp->next_buffer;
483 tmp = vlib_get_buffer (vm, tmp_bi);
484 continue;
485 }
486 else
487 {
488 vlib_buffer_advance (tmp, trim_front);
489 trim_front = 0;
490 }
491 }
492 if (keep_data)
493 {
494 if (last_b)
495 {
496 last_b->flags |= VLIB_BUFFER_NEXT_PRESENT;
497 last_b->next_buffer = tmp_bi;
498 }
499 last_b = tmp;
500 if (keep_data <= tmp->current_length)
501 {
502 tmp->current_length = keep_data;
503 keep_data = 0;
504 }
505 else
506 {
507 keep_data -= tmp->current_length;
508 ASSERT (tmp->flags & VLIB_BUFFER_NEXT_PRESENT);
509 }
510 total_length += tmp->current_length;
511 }
512 else
513 {
514 vec_add1 (*vec_drop_compress, tmp_bi);
515 ASSERT (reass->first_bi != tmp_bi);
516 ++dropped_cnt;
517 }
518 if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
519 {
520 tmp_bi = tmp->next_buffer;
521 tmp = vlib_get_buffer (vm, tmp->next_buffer);
522 }
523 else
524 {
525 break;
526 }
527 }
528 sub_chain_bi =
529 vnet_buffer (vlib_get_buffer (vm, sub_chain_bi))->ip.
530 reass.next_range_bi;
531 }
532 while (~0 != sub_chain_bi);
Chris Luke30684ac2018-03-29 12:56:58 -0700533
534 ASSERT (last_b != NULL);
Klement Sekera75e7d132017-09-20 08:26:30 +0200535 last_b->flags &= ~VLIB_BUFFER_NEXT_PRESENT;
536 vlib_buffer_t *first_b = vlib_get_buffer (vm, reass->first_bi);
537 ASSERT (total_length >= first_b->current_length);
538 total_length -= first_b->current_length;
539 first_b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
540 first_b->total_length_not_including_first_buffer = total_length;
541 // drop fragment header
542 vnet_buffer_opaque_t *first_b_vnb = vnet_buffer (first_b);
543 ip6_header_t *ip = vlib_buffer_get_current (first_b);
544 u16 ip6_frag_hdr_offset = first_b_vnb->ip.reass.ip6_frag_hdr_offset;
545 ip6_ext_header_t *prev_hdr;
546 ip6_ext_header_find_t (ip, prev_hdr, frag_hdr,
547 IP_PROTOCOL_IPV6_FRAGMENTATION);
548 if (prev_hdr)
549 {
550 prev_hdr->next_hdr = frag_hdr->next_hdr;
551 }
552 else
553 {
554 ip->protocol = frag_hdr->next_hdr;
555 }
556 ASSERT ((u8 *) frag_hdr - (u8 *) ip == ip6_frag_hdr_offset);
557 memmove (frag_hdr, (u8 *) frag_hdr + sizeof (*frag_hdr),
558 first_b->current_length - ip6_frag_hdr_offset -
559 sizeof (ip6_frag_hdr_t));
560 first_b->current_length -= sizeof (*frag_hdr);
561 ip->payload_length =
562 clib_host_to_net_u16 (total_length + first_b->current_length -
563 sizeof (*ip));
Klement Sekera75e7d132017-09-20 08:26:30 +0200564 vlib_buffer_chain_compress (vm, first_b, vec_drop_compress);
565 if (PREDICT_FALSE (first_b->flags & VLIB_BUFFER_IS_TRACED))
566 {
567 ip6_reass_add_trace (vm, node, rm, reass, reass->first_bi, FINALIZE, 0);
568#if 0
569 // following code does a hexdump of packet fragments to stdout ...
570 do
571 {
572 u32 bi = reass->first_bi;
573 u8 *s = NULL;
574 while (~0 != bi)
575 {
576 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
577 s = format (s, "%u: %U\n", bi, format_hexdump,
578 vlib_buffer_get_current (b), b->current_length);
579 if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
580 {
581 bi = b->next_buffer;
582 }
583 else
584 {
585 break;
586 }
587 }
588 printf ("%.*s\n", vec_len (s), s);
589 fflush (stdout);
590 vec_free (s);
591 }
592 while (0);
593#endif
594 }
Klement Sekera4c533132018-02-22 11:41:12 +0100595 if (is_feature)
596 {
597 *next0 = IP6_REASSEMBLY_NEXT_INPUT;
598 }
599 else
600 {
601 *next0 = reass->next_index;
602 }
603 vnet_buffer (first_b)->ip.reass.estimated_mtu = reass->min_fragment_length;
604 ip6_reass_free (rm, rt, reass);
Klement Sekera75e7d132017-09-20 08:26:30 +0200605 reass = NULL;
606}
607
Klement Sekera4c533132018-02-22 11:41:12 +0100608always_inline u32
Klement Sekera75e7d132017-09-20 08:26:30 +0200609ip6_reass_get_buffer_chain_length (vlib_main_t * vm, vlib_buffer_t * b)
610{
611 u32 len = 0;
612 while (b)
613 {
614 ++len;
615 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT))
616 {
617 b = vlib_get_buffer (vm, b->next_buffer);
618 }
619 else
620 {
621 break;
622 }
623 }
624 return len;
625}
626
Klement Sekera4c533132018-02-22 11:41:12 +0100627always_inline void
628ip6_reass_insert_range_in_chain (vlib_main_t * vm, ip6_reass_main_t * rm,
629 ip6_reass_per_thread_t * rt,
630 ip6_reass_t * reass, u32 prev_range_bi,
631 u32 new_next_bi)
Klement Sekera75e7d132017-09-20 08:26:30 +0200632{
633
634 vlib_buffer_t *new_next_b = vlib_get_buffer (vm, new_next_bi);
635 vnet_buffer_opaque_t *new_next_vnb = vnet_buffer (new_next_b);
636 if (~0 != prev_range_bi)
637 {
638 vlib_buffer_t *prev_b = vlib_get_buffer (vm, prev_range_bi);
639 vnet_buffer_opaque_t *prev_vnb = vnet_buffer (prev_b);
640 new_next_vnb->ip.reass.next_range_bi = prev_vnb->ip.reass.next_range_bi;
641 prev_vnb->ip.reass.next_range_bi = new_next_bi;
642 }
643 else
644 {
645 if (~0 != reass->first_bi)
646 {
647 new_next_vnb->ip.reass.next_range_bi = reass->first_bi;
648 }
649 reass->first_bi = new_next_bi;
650 }
651 reass->data_len += ip6_reass_buffer_get_data_len (new_next_b);
Klement Sekera4c533132018-02-22 11:41:12 +0100652 rt->buffers_n += ip6_reass_get_buffer_chain_length (vm, new_next_b);
Klement Sekera75e7d132017-09-20 08:26:30 +0200653}
654
Klement Sekera4c533132018-02-22 11:41:12 +0100655always_inline void
Klement Sekera75e7d132017-09-20 08:26:30 +0200656ip6_reass_update (vlib_main_t * vm, vlib_node_runtime_t * node,
Klement Sekera4c533132018-02-22 11:41:12 +0100657 ip6_reass_main_t * rm, ip6_reass_per_thread_t * rt,
658 ip6_reass_t * reass, u32 * bi0, u32 * next0,
Damjan Marionaa682a32018-04-26 22:45:40 +0200659 u32 * error0, ip6_frag_hdr_t * frag_hdr,
Klement Sekera4c533132018-02-22 11:41:12 +0100660 u32 ** vec_drop_overlap, u32 ** vec_drop_compress,
661 bool is_feature)
Klement Sekera75e7d132017-09-20 08:26:30 +0200662{
663 int consumed = 0;
664 vlib_buffer_t *fb = vlib_get_buffer (vm, *bi0);
665 vnet_buffer_opaque_t *fvnb = vnet_buffer (fb);
Vijayabhaskar Katamreddyb3610762018-06-29 05:03:40 -0700666 reass->next_index = fvnb->ip.reass.next_index; // store next_index before it's overwritten
Klement Sekera75e7d132017-09-20 08:26:30 +0200667 fvnb->ip.reass.ip6_frag_hdr_offset =
668 (u8 *) frag_hdr - (u8 *) vlib_buffer_get_current (fb);
669 ip6_header_t *fip = vlib_buffer_get_current (fb);
670 ASSERT (fb->current_length > sizeof (*fip));
671 ASSERT (fvnb->ip.reass.ip6_frag_hdr_offset > 0 &&
672 fvnb->ip.reass.ip6_frag_hdr_offset < fb->current_length);
673 u32 fragment_first = fvnb->ip.reass.fragment_first =
674 ip6_frag_hdr_offset_bytes (frag_hdr);
675 u32 fragment_length =
676 vlib_buffer_length_in_chain (vm, fb) -
677 (fvnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
678 u32 fragment_last = fvnb->ip.reass.fragment_last =
679 fragment_first + fragment_length - 1;
680 int more_fragments = ip6_frag_hdr_more (frag_hdr);
681 u32 candidate_range_bi = reass->first_bi;
682 u32 prev_range_bi = ~0;
683 fvnb->ip.reass.range_first = fragment_first;
684 fvnb->ip.reass.range_last = fragment_last;
685 fvnb->ip.reass.next_range_bi = ~0;
Klement Sekera75e7d132017-09-20 08:26:30 +0200686 if (!more_fragments)
687 {
688 reass->last_packet_octet = fragment_last;
689 }
690 if (~0 == reass->first_bi)
691 {
692 // starting a new reassembly
Klement Sekera4c533132018-02-22 11:41:12 +0100693 ip6_reass_insert_range_in_chain (vm, rm, rt, reass, prev_range_bi,
694 *bi0);
Klement Sekera75e7d132017-09-20 08:26:30 +0200695 if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
696 {
697 ip6_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0);
698 }
Klement Sekera4c533132018-02-22 11:41:12 +0100699 reass->min_fragment_length = clib_net_to_host_u16 (fip->payload_length);
Klement Sekera75e7d132017-09-20 08:26:30 +0200700 *bi0 = ~0;
701 return;
702 }
Klement Sekera4c533132018-02-22 11:41:12 +0100703 reass->min_fragment_length =
Klement Sekera75e7d132017-09-20 08:26:30 +0200704 clib_min (clib_net_to_host_u16 (fip->payload_length),
705 fvnb->ip.reass.estimated_mtu);
706 while (~0 != candidate_range_bi)
707 {
708 vlib_buffer_t *candidate_b = vlib_get_buffer (vm, candidate_range_bi);
709 vnet_buffer_opaque_t *candidate_vnb = vnet_buffer (candidate_b);
710 if (fragment_first > candidate_vnb->ip.reass.range_last)
711 {
712 // this fragments starts after candidate range
713 prev_range_bi = candidate_range_bi;
714 candidate_range_bi = candidate_vnb->ip.reass.next_range_bi;
715 if (candidate_vnb->ip.reass.range_last < fragment_last &&
716 ~0 == candidate_range_bi)
717 {
718 // special case - this fragment falls beyond all known ranges
Klement Sekera4c533132018-02-22 11:41:12 +0100719 ip6_reass_insert_range_in_chain (vm, rm, rt, reass,
720 prev_range_bi, *bi0);
Klement Sekera75e7d132017-09-20 08:26:30 +0200721 consumed = 1;
722 break;
723 }
724 continue;
725 }
726 if (fragment_last < candidate_vnb->ip.reass.range_first)
727 {
728 // this fragment ends before candidate range without any overlap
Klement Sekera4c533132018-02-22 11:41:12 +0100729 ip6_reass_insert_range_in_chain (vm, rm, rt, reass, prev_range_bi,
Klement Sekera75e7d132017-09-20 08:26:30 +0200730 *bi0);
731 consumed = 1;
732 }
733 else if (fragment_first == candidate_vnb->ip.reass.range_first &&
734 fragment_last == candidate_vnb->ip.reass.range_last)
735 {
736 // duplicate fragment - ignore
737 }
738 else
739 {
740 // overlapping fragment - not allowed by RFC 8200
741 ip6_reass_drop_all (vm, rm, reass, vec_drop_overlap);
Klement Sekera4c533132018-02-22 11:41:12 +0100742 ip6_reass_free (rm, rt, reass);
Klement Sekera75e7d132017-09-20 08:26:30 +0200743 if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
744 {
745 ip6_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_OVERLAP,
746 0);
747 }
Klement Sekera4c533132018-02-22 11:41:12 +0100748 *next0 = IP6_REASSEMBLY_NEXT_DROP;
Klement Sekera75e7d132017-09-20 08:26:30 +0200749 *error0 = IP6_ERROR_REASS_OVERLAPPING_FRAGMENT;
750 }
751 break;
752 }
753 if (consumed)
754 {
755 if (PREDICT_FALSE (fb->flags & VLIB_BUFFER_IS_TRACED))
756 {
757 ip6_reass_add_trace (vm, node, rm, reass, *bi0, RANGE_NEW, 0);
758 }
759 }
760 if (~0 != reass->last_packet_octet &&
761 reass->data_len == reass->last_packet_octet + 1)
762 {
Klement Sekera4c533132018-02-22 11:41:12 +0100763 ip6_reass_finalize (vm, node, rm, rt, reass, bi0, next0, error0,
764 vec_drop_compress, is_feature);
Klement Sekera75e7d132017-09-20 08:26:30 +0200765 }
766 else
767 {
768 if (consumed)
769 {
770 *bi0 = ~0;
771 }
772 else
773 {
Klement Sekera4c533132018-02-22 11:41:12 +0100774 *next0 = IP6_REASSEMBLY_NEXT_DROP;
775 ;
Klement Sekera75e7d132017-09-20 08:26:30 +0200776 *error0 = IP6_ERROR_REASS_DUPLICATE_FRAGMENT;
777 }
778 }
779}
780
Klement Sekera4c533132018-02-22 11:41:12 +0100781always_inline bool
782ip6_reass_verify_upper_layer_present (vlib_node_runtime_t * node,
783 vlib_buffer_t * b,
784 ip6_frag_hdr_t * frag_hdr)
785{
786 ip6_ext_header_t *tmp = (ip6_ext_header_t *) frag_hdr;
787 while (ip6_ext_hdr (tmp->next_hdr))
788 {
789 tmp = ip6_ext_next_header (tmp);
790 }
791 if (IP_PROTOCOL_IP6_NONXT == tmp->next_hdr)
792 {
793 icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
794 ICMP6_parameter_problem_first_fragment_has_incomplete_header_chain,
795 0);
796 b->error = node->errors[IP6_ERROR_REASS_MISSING_UPPER];
797
798 return false;
799 }
800 return true;
801}
802
803always_inline bool
804ip6_reass_verify_fragment_multiple_8 (vlib_main_t * vm,
805 vlib_node_runtime_t * node,
806 vlib_buffer_t * b,
807 ip6_frag_hdr_t * frag_hdr)
808{
809 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
810 ip6_header_t *ip = vlib_buffer_get_current (b);
811 int more_fragments = ip6_frag_hdr_more (frag_hdr);
812 u32 fragment_length =
813 vlib_buffer_length_in_chain (vm, b) -
814 (vnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
815 if (more_fragments && 0 != fragment_length % 8)
816 {
817 icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
818 ICMP6_parameter_problem_erroneous_header_field,
819 (u8 *) & ip->payload_length - (u8 *) ip);
820 return false;
821 }
822 return true;
823}
824
825always_inline bool
826ip6_reass_verify_packet_size_lt_64k (vlib_main_t * vm,
827 vlib_node_runtime_t * node,
828 vlib_buffer_t * b,
829 ip6_frag_hdr_t * frag_hdr)
830{
831 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
832 u32 fragment_first = ip6_frag_hdr_offset_bytes (frag_hdr);
833 u32 fragment_length =
834 vlib_buffer_length_in_chain (vm, b) -
835 (vnb->ip.reass.ip6_frag_hdr_offset + sizeof (*frag_hdr));
836 if (fragment_first + fragment_length > 65535)
837 {
838 ip6_header_t *ip0 = vlib_buffer_get_current (b);
839 icmp6_error_set_vnet_buffer (b, ICMP6_parameter_problem,
840 ICMP6_parameter_problem_erroneous_header_field,
841 (u8 *) & frag_hdr->fragment_offset_and_more
842 - (u8 *) ip0);
843 return false;
844 }
845 return true;
846}
847
Klement Sekera75e7d132017-09-20 08:26:30 +0200848always_inline uword
Klement Sekera4c533132018-02-22 11:41:12 +0100849ip6_reassembly_inline (vlib_main_t * vm,
850 vlib_node_runtime_t * node,
851 vlib_frame_t * frame, bool is_feature)
Klement Sekera75e7d132017-09-20 08:26:30 +0200852{
853 u32 *from = vlib_frame_vector_args (frame);
854 u32 n_left_from, n_left_to_next, *to_next, next_index;
855 ip6_reass_main_t *rm = &ip6_reass_main;
Klement Sekera4c533132018-02-22 11:41:12 +0100856 ip6_reass_per_thread_t *rt = &rm->per_thread_data[os_get_thread_index ()];
857 clib_spinlock_lock (&rt->lock);
Klement Sekera75e7d132017-09-20 08:26:30 +0200858
859 n_left_from = frame->n_vectors;
860 next_index = node->cached_next_index;
861 static u32 *vec_timeout = NULL; // indexes of buffers which timed out
862 static u32 *vec_drop_overlap = NULL; // indexes of buffers dropped due to overlap
863 static u32 *vec_drop_compress = NULL; // indexes of buffers dropped due to buffer compression
864 while (n_left_from > 0 || vec_len (vec_timeout) > 0 ||
Klement Sekera4c533132018-02-22 11:41:12 +0100865 vec_len (vec_drop_overlap) > 0 || vec_len (vec_drop_compress) > 0)
Klement Sekera75e7d132017-09-20 08:26:30 +0200866 {
867 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
868
869 while (vec_len (vec_timeout) > 0 && n_left_to_next > 0)
870 {
871 u32 bi = vec_pop (vec_timeout);
872 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
873 b->error = node->errors[IP6_ERROR_REASS_TIMEOUT];
874 to_next[0] = bi;
875 to_next += 1;
876 n_left_to_next -= 1;
877 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
878 n_left_to_next, bi,
879 IP6_REASSEMBLY_NEXT_DROP);
Klement Sekera4c533132018-02-22 11:41:12 +0100880 ASSERT (rt->buffers_n > 0);
881 --rt->buffers_n;
Klement Sekera75e7d132017-09-20 08:26:30 +0200882 }
883
884 while (vec_len (vec_drop_overlap) > 0 && n_left_to_next > 0)
885 {
886 u32 bi = vec_pop (vec_drop_overlap);
887 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
888 b->error = node->errors[IP6_ERROR_REASS_OVERLAPPING_FRAGMENT];
889 to_next[0] = bi;
890 to_next += 1;
891 n_left_to_next -= 1;
892 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
893 n_left_to_next, bi,
894 IP6_REASSEMBLY_NEXT_DROP);
Klement Sekera4c533132018-02-22 11:41:12 +0100895 ASSERT (rt->buffers_n > 0);
896 --rt->buffers_n;
Klement Sekera75e7d132017-09-20 08:26:30 +0200897 }
898
899 while (vec_len (vec_drop_compress) > 0 && n_left_to_next > 0)
900 {
901 u32 bi = vec_pop (vec_drop_compress);
902 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
903 b->error = node->errors[IP6_ERROR_NONE];
904 to_next[0] = bi;
905 to_next += 1;
906 n_left_to_next -= 1;
907 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
908 n_left_to_next, bi,
909 IP6_REASSEMBLY_NEXT_DROP);
Klement Sekera4c533132018-02-22 11:41:12 +0100910 ASSERT (rt->buffers_n > 0);
911 --rt->buffers_n;
Klement Sekera75e7d132017-09-20 08:26:30 +0200912 }
913
914 while (n_left_from > 0 && n_left_to_next > 0)
915 {
916 u32 bi0;
917 vlib_buffer_t *b0;
Klement Sekera4c533132018-02-22 11:41:12 +0100918 u32 next0;
919 u32 error0 = IP6_ERROR_NONE;
920 u32 icmp_bi = ~0;
Klement Sekera75e7d132017-09-20 08:26:30 +0200921
922 bi0 = from[0];
923 b0 = vlib_get_buffer (vm, bi0);
924
925 ip6_header_t *ip0 = vlib_buffer_get_current (b0);
Klement Sekera3ecc2212018-03-27 10:34:43 +0200926 ip6_frag_hdr_t *frag_hdr = NULL;
Klement Sekera75e7d132017-09-20 08:26:30 +0200927 ip6_ext_header_t *prev_hdr;
Klement Sekera3ecc2212018-03-27 10:34:43 +0200928 if (ip6_ext_hdr (ip0->protocol))
929 {
930 ip6_ext_header_find_t (ip0, prev_hdr, frag_hdr,
931 IP_PROTOCOL_IPV6_FRAGMENTATION);
932 }
Klement Sekera4c533132018-02-22 11:41:12 +0100933 if (!frag_hdr)
934 {
935 // this is a regular packet - no fragmentation
936 next0 = IP6_REASSEMBLY_NEXT_INPUT;
937 goto skip_reass;
938 }
Klement Sekera75e7d132017-09-20 08:26:30 +0200939 if (0 == ip6_frag_hdr_offset (frag_hdr))
940 {
941 // first fragment - verify upper-layer is present
Klement Sekera4c533132018-02-22 11:41:12 +0100942 if (!ip6_reass_verify_upper_layer_present (node, b0, frag_hdr))
Klement Sekera75e7d132017-09-20 08:26:30 +0200943 {
Klement Sekera4c533132018-02-22 11:41:12 +0100944 next0 = IP6_REASSEMBLY_NEXT_ICMP_ERROR;
945 goto skip_reass;
Klement Sekera75e7d132017-09-20 08:26:30 +0200946 }
Klement Sekera4c533132018-02-22 11:41:12 +0100947 }
948 if (!ip6_reass_verify_fragment_multiple_8 (vm, node, b0, frag_hdr)
949 || !ip6_reass_verify_packet_size_lt_64k (vm, node, b0,
950 frag_hdr))
951 {
952 next0 = IP6_REASSEMBLY_NEXT_ICMP_ERROR;
953 goto skip_reass;
Klement Sekera75e7d132017-09-20 08:26:30 +0200954 }
955 vnet_buffer (b0)->ip.reass.ip6_frag_hdr_offset =
956 (u8 *) frag_hdr - (u8 *) ip0;
957
958 ip6_reass_key_t k;
Klement Sekera8dcfed52018-06-28 11:16:15 +0200959 k.as_u64[0] = ip0->src_address.as_u64[0];
960 k.as_u64[1] = ip0->src_address.as_u64[1];
961 k.as_u64[2] = ip0->dst_address.as_u64[0];
962 k.as_u64[3] = ip0->dst_address.as_u64[1];
963 k.as_u64[4] =
964 (u64) vnet_buffer (b0)->
965 sw_if_index[VLIB_RX] << 32 | frag_hdr->identification;
966 k.as_u64[5] = ip0->protocol;
Klement Sekera75e7d132017-09-20 08:26:30 +0200967 ip6_reass_t *reass =
Klement Sekera4c533132018-02-22 11:41:12 +0100968 ip6_reass_find_or_create (vm, node, rm, rt, &k, &icmp_bi,
Klement Sekera75e7d132017-09-20 08:26:30 +0200969 &vec_timeout);
970
Klement Sekera75e7d132017-09-20 08:26:30 +0200971 if (reass)
972 {
Klement Sekera4c533132018-02-22 11:41:12 +0100973 ip6_reass_update (vm, node, rm, rt, reass, &bi0, &next0,
974 &error0, frag_hdr, &vec_drop_overlap,
975 &vec_drop_compress, is_feature);
Klement Sekera75e7d132017-09-20 08:26:30 +0200976 }
977 else
978 {
979 next0 = IP6_REASSEMBLY_NEXT_DROP;
980 error0 = IP6_ERROR_REASS_LIMIT_REACHED;
981 }
982
983 b0->error = node->errors[error0];
984
985 if (~0 != bi0)
986 {
Klement Sekera4c533132018-02-22 11:41:12 +0100987 skip_reass:
Klement Sekera75e7d132017-09-20 08:26:30 +0200988 to_next[0] = bi0;
989 to_next += 1;
990 n_left_to_next -= 1;
Klement Sekera4c533132018-02-22 11:41:12 +0100991 if (is_feature && IP6_ERROR_NONE == error0)
992 {
Kingwel Xiea0060652018-09-26 04:59:52 -0400993 b0 = vlib_get_buffer (vm, bi0);
Damjan Marion7d98a122018-07-19 20:42:08 +0200994 vnet_feature_next (&next0, b0);
Klement Sekera4c533132018-02-22 11:41:12 +0100995 }
Klement Sekera75e7d132017-09-20 08:26:30 +0200996 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
997 n_left_to_next, bi0, next0);
998 }
999
1000 if (~0 != icmp_bi)
1001 {
1002 next0 = IP6_REASSEMBLY_NEXT_ICMP_ERROR;
1003 to_next[0] = icmp_bi;
1004 to_next += 1;
1005 n_left_to_next -= 1;
1006 vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
1007 n_left_to_next, icmp_bi,
1008 next0);
1009 }
Klement Sekera75e7d132017-09-20 08:26:30 +02001010 from += 1;
1011 n_left_from -= 1;
1012 }
1013
1014 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
1015 }
1016
Klement Sekera4c533132018-02-22 11:41:12 +01001017 clib_spinlock_unlock (&rt->lock);
Klement Sekera75e7d132017-09-20 08:26:30 +02001018 return frame->n_vectors;
1019}
1020
1021static char *ip6_reassembly_error_strings[] = {
1022#define _(sym, string) string,
1023 foreach_ip6_error
1024#undef _
1025};
1026
Damjan Marion2574d9f2018-06-26 14:45:49 +02001027static uword
Klement Sekera4c533132018-02-22 11:41:12 +01001028ip6_reassembly (vlib_main_t * vm, vlib_node_runtime_t * node,
1029 vlib_frame_t * frame)
1030{
1031 return ip6_reassembly_inline (vm, node, frame, false /* is_feature */ );
1032}
1033
Klement Sekera75e7d132017-09-20 08:26:30 +02001034/* *INDENT-OFF* */
1035VLIB_REGISTER_NODE (ip6_reass_node, static) = {
1036 .function = ip6_reassembly,
1037 .name = "ip6-reassembly",
1038 .vector_size = sizeof (u32),
1039 .format_trace = format_ip6_reass_trace,
1040 .n_errors = ARRAY_LEN (ip6_reassembly_error_strings),
1041 .error_strings = ip6_reassembly_error_strings,
1042 .n_next_nodes = IP6_REASSEMBLY_N_NEXT,
1043 .next_nodes =
1044 {
1045 [IP6_REASSEMBLY_NEXT_INPUT] = "ip6-input",
1046 [IP6_REASSEMBLY_NEXT_DROP] = "ip6-drop",
1047 [IP6_REASSEMBLY_NEXT_ICMP_ERROR] = "ip6-icmp-error",
1048 },
1049};
1050/* *INDENT-ON* */
1051
Klement Sekera4c533132018-02-22 11:41:12 +01001052VLIB_NODE_FUNCTION_MULTIARCH (ip6_reass_node, ip6_reassembly);
1053
Damjan Marion2574d9f2018-06-26 14:45:49 +02001054static uword
Klement Sekera4c533132018-02-22 11:41:12 +01001055ip6_reassembly_feature (vlib_main_t * vm,
1056 vlib_node_runtime_t * node, vlib_frame_t * frame)
1057{
1058 return ip6_reassembly_inline (vm, node, frame, true /* is_feature */ );
1059}
1060
1061/* *INDENT-OFF* */
1062VLIB_REGISTER_NODE (ip6_reass_node_feature, static) = {
1063 .function = ip6_reassembly_feature,
1064 .name = "ip6-reassembly-feature",
1065 .vector_size = sizeof (u32),
1066 .format_trace = format_ip6_reass_trace,
1067 .n_errors = ARRAY_LEN (ip6_reassembly_error_strings),
1068 .error_strings = ip6_reassembly_error_strings,
1069 .n_next_nodes = IP6_REASSEMBLY_N_NEXT,
1070 .next_nodes =
1071 {
1072 [IP6_REASSEMBLY_NEXT_INPUT] = "ip6-input",
1073 [IP6_REASSEMBLY_NEXT_DROP] = "ip6-drop",
1074 [IP6_REASSEMBLY_NEXT_ICMP_ERROR] = "ip6-icmp-error",
1075 },
1076};
1077/* *INDENT-ON* */
1078
1079VLIB_NODE_FUNCTION_MULTIARCH (ip6_reass_node_feature, ip6_reassembly_feature);
1080
1081/* *INDENT-OFF* */
1082VNET_FEATURE_INIT (ip6_reassembly_feature, static) = {
1083 .arc_name = "ip6-unicast",
1084 .node_name = "ip6-reassembly-feature",
1085 .runs_before = VNET_FEATURES ("ip6-lookup"),
1086 .runs_after = 0,
1087};
1088/* *INDENT-ON* */
1089
1090static u32
1091ip6_reass_get_nbuckets ()
Klement Sekera75e7d132017-09-20 08:26:30 +02001092{
1093 ip6_reass_main_t *rm = &ip6_reass_main;
1094 u32 nbuckets;
1095 u8 i;
1096
1097 nbuckets = (u32) (rm->max_reass_n / IP6_REASS_HT_LOAD_FACTOR);
1098
1099 for (i = 0; i < 31; i++)
1100 if ((1 << i) >= nbuckets)
1101 break;
1102 nbuckets = 1 << i;
1103
1104 return nbuckets;
1105}
1106
1107typedef enum
1108{
1109 IP6_EVENT_CONFIG_CHANGED = 1,
1110} ip6_reass_event_t;
1111
1112typedef struct
1113{
1114 int failure;
1115 clib_bihash_48_8_t *new_hash;
1116} ip6_rehash_cb_ctx;
1117
Klement Sekera4c533132018-02-22 11:41:12 +01001118static void
Klement Sekera75e7d132017-09-20 08:26:30 +02001119ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
1120{
1121 ip6_rehash_cb_ctx *ctx = _ctx;
1122 if (clib_bihash_add_del_48_8 (ctx->new_hash, kv, 1))
1123 {
1124 ctx->failure = 1;
1125 }
1126}
1127
Klement Sekera4c533132018-02-22 11:41:12 +01001128static void
1129ip6_reass_set_params (u32 timeout_ms, u32 max_reassemblies,
1130 u32 expire_walk_interval_ms)
1131{
1132 ip6_reass_main.timeout_ms = timeout_ms;
1133 ip6_reass_main.timeout = (f64) timeout_ms / (f64) MSEC_PER_SEC;
1134 ip6_reass_main.max_reass_n = max_reassemblies;
1135 ip6_reass_main.expire_walk_interval_ms = expire_walk_interval_ms;
1136}
1137
Klement Sekera75e7d132017-09-20 08:26:30 +02001138vnet_api_error_t
1139ip6_reass_set (u32 timeout_ms, u32 max_reassemblies,
1140 u32 expire_walk_interval_ms)
1141{
1142 u32 old_nbuckets = ip6_reass_get_nbuckets ();
Klement Sekera4c533132018-02-22 11:41:12 +01001143 ip6_reass_set_params (timeout_ms, max_reassemblies,
1144 expire_walk_interval_ms);
Klement Sekera75e7d132017-09-20 08:26:30 +02001145 vlib_process_signal_event (ip6_reass_main.vlib_main,
1146 ip6_reass_main.ip6_reass_expire_node_idx,
1147 IP6_EVENT_CONFIG_CHANGED, 0);
1148 u32 new_nbuckets = ip6_reass_get_nbuckets ();
Klement Sekera3ecc2212018-03-27 10:34:43 +02001149 if (ip6_reass_main.max_reass_n > 0 && new_nbuckets > old_nbuckets)
Klement Sekera75e7d132017-09-20 08:26:30 +02001150 {
1151 clib_bihash_48_8_t new_hash;
Dave Barachb7b92992018-10-17 10:38:51 -04001152 clib_memset (&new_hash, 0, sizeof (new_hash));
Klement Sekera75e7d132017-09-20 08:26:30 +02001153 ip6_rehash_cb_ctx ctx;
1154 ctx.failure = 0;
1155 ctx.new_hash = &new_hash;
1156 clib_bihash_init_48_8 (&new_hash, "ip6-reass", new_nbuckets,
1157 new_nbuckets * 1024);
1158 clib_bihash_foreach_key_value_pair_48_8 (&ip6_reass_main.hash,
1159 ip6_rehash_cb, &ctx);
1160 if (ctx.failure)
1161 {
1162 clib_bihash_free_48_8 (&new_hash);
1163 return -1;
1164 }
1165 else
1166 {
1167 clib_bihash_free_48_8 (&ip6_reass_main.hash);
1168 clib_memcpy (&ip6_reass_main.hash, &new_hash,
1169 sizeof (ip6_reass_main.hash));
1170 }
1171 }
1172 return 0;
1173}
1174
1175vnet_api_error_t
1176ip6_reass_get (u32 * timeout_ms, u32 * max_reassemblies,
1177 u32 * expire_walk_interval_ms)
1178{
1179 *timeout_ms = ip6_reass_main.timeout_ms;
1180 *max_reassemblies = ip6_reass_main.max_reass_n;
1181 *expire_walk_interval_ms = ip6_reass_main.expire_walk_interval_ms;
1182 return 0;
1183}
1184
Klement Sekera4c533132018-02-22 11:41:12 +01001185static clib_error_t *
Klement Sekera75e7d132017-09-20 08:26:30 +02001186ip6_reass_init_function (vlib_main_t * vm)
1187{
1188 ip6_reass_main_t *rm = &ip6_reass_main;
1189 clib_error_t *error = 0;
1190 u32 nbuckets;
Dave Barach1403fcd2018-02-05 09:45:43 -05001191 vlib_node_t *node;
Klement Sekera75e7d132017-09-20 08:26:30 +02001192
1193 rm->vlib_main = vm;
1194 rm->vnet_main = vnet_get_main ();
1195
Juraj Slobodacd806922018-10-10 10:15:54 +02001196 vec_validate (rm->per_thread_data, vlib_num_workers ());
Klement Sekera4c533132018-02-22 11:41:12 +01001197 ip6_reass_per_thread_t *rt;
1198 vec_foreach (rt, rm->per_thread_data)
1199 {
1200 clib_spinlock_init (&rt->lock);
1201 pool_alloc (rt->pool, rm->max_reass_n);
1202 }
Dave Barach1403fcd2018-02-05 09:45:43 -05001203
1204 node = vlib_get_node_by_name (vm, (u8 *) "ip6-reassembly-expire-walk");
1205 ASSERT (node);
1206 rm->ip6_reass_expire_node_idx = node->index;
1207
Klement Sekera3ecc2212018-03-27 10:34:43 +02001208 ip6_reass_set_params (IP6_REASS_TIMEOUT_DEFAULT_MS,
1209 IP6_REASS_MAX_REASSEMBLIES_DEFAULT,
1210 IP6_REASS_EXPIRE_WALK_INTERVAL_DEFAULT_MS);
1211
Klement Sekera75e7d132017-09-20 08:26:30 +02001212 nbuckets = ip6_reass_get_nbuckets ();
1213 clib_bihash_init_48_8 (&rm->hash, "ip6-reass", nbuckets, nbuckets * 1024);
1214
Dave Barach1403fcd2018-02-05 09:45:43 -05001215 node = vlib_get_node_by_name (vm, (u8 *) "ip6-drop");
Klement Sekera75e7d132017-09-20 08:26:30 +02001216 ASSERT (node);
1217 rm->ip6_drop_idx = node->index;
Klement Sekera75e7d132017-09-20 08:26:30 +02001218 node = vlib_get_node_by_name (vm, (u8 *) "ip6-icmp-error");
1219 ASSERT (node);
1220 rm->ip6_icmp_error_idx = node->index;
1221
1222 if ((error = vlib_call_init_function (vm, ip_main_init)))
1223 return error;
1224 ip6_register_protocol (IP_PROTOCOL_IPV6_FRAGMENTATION,
1225 ip6_reass_node.index);
Klement Sekera4c533132018-02-22 11:41:12 +01001226
Klement Sekera75e7d132017-09-20 08:26:30 +02001227 return error;
1228}
1229
1230VLIB_INIT_FUNCTION (ip6_reass_init_function);
1231
1232static uword
1233ip6_reass_walk_expired (vlib_main_t * vm,
1234 vlib_node_runtime_t * node, vlib_frame_t * f)
1235{
1236 ip6_reass_main_t *rm = &ip6_reass_main;
1237 uword event_type, *event_data = 0;
1238
1239 while (true)
1240 {
1241 vlib_process_wait_for_event_or_clock (vm,
1242 (f64) rm->expire_walk_interval_ms
1243 / (f64) MSEC_PER_SEC);
1244 event_type = vlib_process_get_events (vm, &event_data);
1245
1246 switch (event_type)
1247 {
1248 case ~0: /* no events => timeout */
1249 /* nothing to do here */
1250 break;
1251 case IP6_EVENT_CONFIG_CHANGED:
1252 break;
1253 default:
1254 clib_warning ("BUG: event type 0x%wx", event_type);
1255 break;
1256 }
1257 f64 now = vlib_time_now (vm);
1258
1259 ip6_reass_t *reass;
1260 u32 *vec_timeout = NULL;
1261 int *pool_indexes_to_free = NULL;
1262
Klement Sekera4c533132018-02-22 11:41:12 +01001263 uword thread_index = 0;
Klement Sekera75e7d132017-09-20 08:26:30 +02001264 int index;
Juraj Slobodacd806922018-10-10 10:15:54 +02001265 const uword nthreads = vlib_num_workers () + 1;
Klement Sekera75e7d132017-09-20 08:26:30 +02001266 u32 *vec_icmp_bi = NULL;
Klement Sekera4c533132018-02-22 11:41:12 +01001267 for (thread_index = 0; thread_index < nthreads; ++thread_index)
1268 {
1269 ip6_reass_per_thread_t *rt = &rm->per_thread_data[thread_index];
1270 clib_spinlock_lock (&rt->lock);
1271
1272 vec_reset_length (pool_indexes_to_free);
1273 /* *INDENT-OFF* */
1274 pool_foreach_index (index, rt->pool, ({
1275 reass = pool_elt_at_index (rt->pool, index);
1276 if (now > reass->last_heard + rm->timeout)
1277 {
1278 vec_add1 (pool_indexes_to_free, index);
1279 }
1280 }));
1281 /* *INDENT-ON* */
1282 int *i;
1283 /* *INDENT-OFF* */
1284 vec_foreach (i, pool_indexes_to_free)
Klement Sekera75e7d132017-09-20 08:26:30 +02001285 {
Klement Sekera4c533132018-02-22 11:41:12 +01001286 ip6_reass_t *reass = pool_elt_at_index (rt->pool, i[0]);
1287 u32 icmp_bi = ~0;
1288 u32 before = vec_len (vec_timeout);
1289 vlib_buffer_t *b = vlib_get_buffer (vm, reass->first_bi);
1290 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
1291 {
1292 if (pool_is_free_index (vm->trace_main.trace_buffer_pool,
1293 b->trace_index))
1294 {
1295 /* the trace is gone, don't trace this buffer anymore */
1296 b->flags &= ~VLIB_BUFFER_IS_TRACED;
1297 }
1298 }
1299 ip6_reass_on_timeout (vm, node, rm, reass, &icmp_bi, &vec_timeout);
1300 u32 after = vec_len (vec_timeout);
1301 ASSERT (rt->buffers_n >= (after - before));
1302 rt->buffers_n -= (after - before);
1303 if (~0 != icmp_bi)
1304 {
1305 vec_add1 (vec_icmp_bi, icmp_bi);
1306 ASSERT (rt->buffers_n > 0);
1307 --rt->buffers_n;
1308 }
1309 ip6_reass_free (rm, rt, reass);
Klement Sekera75e7d132017-09-20 08:26:30 +02001310 }
Klement Sekera4c533132018-02-22 11:41:12 +01001311 /* *INDENT-ON* */
1312
1313 clib_spinlock_unlock (&rt->lock);
1314 }
Klement Sekera75e7d132017-09-20 08:26:30 +02001315
1316 while (vec_len (vec_timeout) > 0)
1317 {
1318 vlib_frame_t *f = vlib_get_frame_to_node (vm, rm->ip6_drop_idx);
1319 u32 *to_next = vlib_frame_vector_args (f);
1320 u32 n_left_to_next = VLIB_FRAME_SIZE - f->n_vectors;
Klement Sekera4c533132018-02-22 11:41:12 +01001321 int trace_frame = 0;
Klement Sekera75e7d132017-09-20 08:26:30 +02001322 while (vec_len (vec_timeout) > 0 && n_left_to_next > 0)
1323 {
1324 u32 bi = vec_pop (vec_timeout);
1325 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1326 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
1327 {
1328 if (pool_is_free_index (vm->trace_main.trace_buffer_pool,
1329 b->trace_index))
1330 {
1331 /* the trace is gone, don't trace this buffer anymore */
1332 b->flags &= ~VLIB_BUFFER_IS_TRACED;
1333 }
1334 else
1335 {
Klement Sekera4c533132018-02-22 11:41:12 +01001336 trace_frame = 1;
Klement Sekera75e7d132017-09-20 08:26:30 +02001337 }
1338 }
1339 b->error = node->errors[IP6_ERROR_REASS_TIMEOUT];
1340 to_next[0] = bi;
1341 ++f->n_vectors;
1342 to_next += 1;
1343 n_left_to_next -= 1;
Klement Sekera75e7d132017-09-20 08:26:30 +02001344 }
Damjan Marion633b6fd2018-09-14 14:38:53 +02001345 f->frame_flags |= (trace_frame * VLIB_FRAME_TRACE);
Klement Sekera75e7d132017-09-20 08:26:30 +02001346 vlib_put_frame_to_node (vm, rm->ip6_drop_idx, f);
1347 }
1348
1349 while (vec_len (vec_icmp_bi) > 0)
1350 {
1351 vlib_frame_t *f =
1352 vlib_get_frame_to_node (vm, rm->ip6_icmp_error_idx);
1353 u32 *to_next = vlib_frame_vector_args (f);
1354 u32 n_left_to_next = VLIB_FRAME_SIZE - f->n_vectors;
Klement Sekera4c533132018-02-22 11:41:12 +01001355 int trace_frame = 0;
Klement Sekera75e7d132017-09-20 08:26:30 +02001356 while (vec_len (vec_icmp_bi) > 0 && n_left_to_next > 0)
1357 {
1358 u32 bi = vec_pop (vec_icmp_bi);
1359 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1360 if (PREDICT_FALSE (b->flags & VLIB_BUFFER_IS_TRACED))
1361 {
1362 if (pool_is_free_index (vm->trace_main.trace_buffer_pool,
1363 b->trace_index))
1364 {
1365 /* the trace is gone, don't trace this buffer anymore */
1366 b->flags &= ~VLIB_BUFFER_IS_TRACED;
1367 }
1368 else
1369 {
Klement Sekera4c533132018-02-22 11:41:12 +01001370 trace_frame = 1;
Klement Sekera75e7d132017-09-20 08:26:30 +02001371 }
1372 }
1373 b->error = node->errors[IP6_ERROR_REASS_TIMEOUT];
1374 to_next[0] = bi;
1375 ++f->n_vectors;
1376 to_next += 1;
1377 n_left_to_next -= 1;
Klement Sekera75e7d132017-09-20 08:26:30 +02001378 }
Damjan Marion633b6fd2018-09-14 14:38:53 +02001379 f->frame_flags |= (trace_frame * VLIB_FRAME_TRACE);
Klement Sekera75e7d132017-09-20 08:26:30 +02001380 vlib_put_frame_to_node (vm, rm->ip6_icmp_error_idx, f);
1381 }
1382
1383 vec_free (pool_indexes_to_free);
1384 vec_free (vec_timeout);
1385 vec_free (vec_icmp_bi);
1386 if (event_data)
1387 {
1388 _vec_len (event_data) = 0;
1389 }
1390 }
1391
1392 return 0;
1393}
1394
1395static vlib_node_registration_t ip6_reass_expire_node;
1396
1397/* *INDENT-OFF* */
1398VLIB_REGISTER_NODE (ip6_reass_expire_node, static) = {
1399 .function = ip6_reass_walk_expired,
1400 .format_trace = format_ip6_reass_trace,
1401 .type = VLIB_NODE_TYPE_PROCESS,
1402 .name = "ip6-reassembly-expire-walk",
1403
1404 .n_errors = ARRAY_LEN (ip6_reassembly_error_strings),
1405 .error_strings = ip6_reassembly_error_strings,
1406
1407};
1408/* *INDENT-ON* */
1409
1410static u8 *
1411format_ip6_reass_key (u8 * s, va_list * args)
1412{
1413 ip6_reass_key_t *key = va_arg (*args, ip6_reass_key_t *);
1414 s = format (s, "xx_id: %u, src: %U, dst: %U, frag_id: %u, proto: %u",
1415 key->xx_id, format_ip6_address, &key->src, format_ip6_address,
1416 &key->dst, clib_net_to_host_u16 (key->frag_id), key->proto);
1417 return s;
1418}
1419
1420static u8 *
1421format_ip6_reass (u8 * s, va_list * args)
1422{
1423 vlib_main_t *vm = va_arg (*args, vlib_main_t *);
1424 ip6_reass_t *reass = va_arg (*args, ip6_reass_t *);
1425
Klement Sekera4c533132018-02-22 11:41:12 +01001426 s = format (s, "ID: %lu, key: %U\n first_bi: %u, data_len: %u, "
Klement Sekera75e7d132017-09-20 08:26:30 +02001427 "last_packet_octet: %u, trace_op_counter: %u\n",
1428 reass->id, format_ip6_reass_key, &reass->key, reass->first_bi,
1429 reass->data_len, reass->last_packet_octet,
1430 reass->trace_op_counter);
1431 u32 bi = reass->first_bi;
1432 u32 counter = 0;
1433 while (~0 != bi)
1434 {
1435 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
1436 vnet_buffer_opaque_t *vnb = vnet_buffer (b);
1437 s = format (s, " #%03u: range: [%u, %u], bi: %u, off: %d, len: %u, "
1438 "fragment[%u, %u]\n",
1439 counter, vnb->ip.reass.range_first,
1440 vnb->ip.reass.range_last, bi,
1441 ip6_reass_buffer_get_data_offset_no_check (b),
1442 ip6_reass_buffer_get_data_len_no_check (b),
1443 vnb->ip.reass.fragment_first, vnb->ip.reass.fragment_last);
1444 if (b->flags & VLIB_BUFFER_NEXT_PRESENT)
1445 {
1446 bi = b->next_buffer;
1447 }
1448 else
1449 {
1450 bi = ~0;
1451 }
1452 }
1453 return s;
1454}
1455
1456static clib_error_t *
1457show_ip6_reass (vlib_main_t * vm, unformat_input_t * input,
1458 CLIB_UNUSED (vlib_cli_command_t * lmd))
1459{
1460 ip6_reass_main_t *rm = &ip6_reass_main;
1461
1462 vlib_cli_output (vm, "---------------------");
1463 vlib_cli_output (vm, "IP6 reassembly status");
1464 vlib_cli_output (vm, "---------------------");
Klement Sekera4c533132018-02-22 11:41:12 +01001465 bool details = false;
Klement Sekera75e7d132017-09-20 08:26:30 +02001466 if (unformat (input, "details"))
1467 {
Klement Sekera4c533132018-02-22 11:41:12 +01001468 details = true;
1469 }
1470
1471 u32 sum_reass_n = 0;
1472 u64 sum_buffers_n = 0;
1473 ip6_reass_t *reass;
1474 uword thread_index;
Juraj Slobodacd806922018-10-10 10:15:54 +02001475 const uword nthreads = vlib_num_workers () + 1;
Klement Sekera4c533132018-02-22 11:41:12 +01001476 for (thread_index = 0; thread_index < nthreads; ++thread_index)
1477 {
1478 ip6_reass_per_thread_t *rt = &rm->per_thread_data[thread_index];
1479 clib_spinlock_lock (&rt->lock);
1480 if (details)
1481 {
1482 /* *INDENT-OFF* */
1483 pool_foreach (reass, rt->pool, {
1484 vlib_cli_output (vm, "%U", format_ip6_reass, vm, reass);
1485 });
1486 /* *INDENT-ON* */
1487 }
1488 sum_reass_n += rt->reass_n;
1489 sum_buffers_n += rt->buffers_n;
1490 clib_spinlock_unlock (&rt->lock);
Klement Sekera75e7d132017-09-20 08:26:30 +02001491 }
1492 vlib_cli_output (vm, "---------------------");
Klement Sekera4c533132018-02-22 11:41:12 +01001493 vlib_cli_output (vm, "Current IP6 reassemblies count: %lu\n",
1494 (long unsigned) sum_reass_n);
1495 vlib_cli_output (vm, "Maximum configured concurrent IP6 reassemblies per "
1496 "worker-thread: %lu\n", (long unsigned) rm->max_reass_n);
Klement Sekera75e7d132017-09-20 08:26:30 +02001497 vlib_cli_output (vm, "Buffers in use: %lu\n",
Klement Sekera4c533132018-02-22 11:41:12 +01001498 (long unsigned) sum_buffers_n);
Klement Sekera75e7d132017-09-20 08:26:30 +02001499 return 0;
1500}
1501
1502/* *INDENT-OFF* */
1503VLIB_CLI_COMMAND (show_ip6_reassembly_cmd, static) = {
1504 .path = "show ip6-reassembly",
1505 .short_help = "show ip6-reassembly [details]",
1506 .function = show_ip6_reass,
1507};
1508/* *INDENT-ON* */
1509
Klement Sekera4c533132018-02-22 11:41:12 +01001510vnet_api_error_t
1511ip6_reass_enable_disable (u32 sw_if_index, u8 enable_disable)
1512{
1513 return vnet_feature_enable_disable ("ip6-unicast", "ip6-reassembly-feature",
1514 sw_if_index, enable_disable, 0, 0);
1515}
1516
Klement Sekera75e7d132017-09-20 08:26:30 +02001517/*
1518 * fd.io coding-style-patch-verification: ON
1519 *
1520 * Local Variables:
1521 * eval: (c-set-style "gnu")
1522 * End:
1523 */