blob: 2b66467837ca16a020dde72a0815fa1ae113cd85 [file] [log] [blame]
Neale Rannsf068c3e2018-01-03 04:18:48 -08001/*
2 * Copyright (c) 2016 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#include <vnet/dpo/dvr_dpo.h>
17#include <vnet/fib/fib_node.h>
18#include <vnet/ip/ip.h>
19#include <vnet/ethernet/ethernet.h>
Neale Rannsa342da22019-06-06 10:35:07 +000020#include <vnet/l2/l2_input.h>
Neale Rannsf068c3e2018-01-03 04:18:48 -080021
Filip Tehlareb9a27f2019-03-07 01:42:11 -080022#ifndef CLIB_MARCH_VARIANT
BenoƮt Ganne47727c02019-02-12 13:35:08 +010023dvr_dpo_t *dvr_dpo_pool;
24
Neale Rannsf068c3e2018-01-03 04:18:48 -080025/**
26 * The 'DB' of DVR DPOs.
27 * There is one per-interface per-L3 proto, so this is a per-interface vector
28 */
29static index_t *dvr_dpo_db[DPO_PROTO_NUM];
30
31static dvr_dpo_t *
32dvr_dpo_alloc (void)
33{
34 dvr_dpo_t *dd;
35
36 pool_get(dvr_dpo_pool, dd);
37
38 return (dd);
39}
40
41static inline dvr_dpo_t *
42dvr_dpo_get_from_dpo (const dpo_id_t *dpo)
43{
44 ASSERT(DPO_DVR == dpo->dpoi_type);
45
46 return (dvr_dpo_get(dpo->dpoi_index));
47}
48
49static inline index_t
50dvr_dpo_get_index (dvr_dpo_t *dd)
51{
52 return (dd - dvr_dpo_pool);
53}
54
55static void
56dvr_dpo_lock (dpo_id_t *dpo)
57{
58 dvr_dpo_t *dd;
59
60 dd = dvr_dpo_get_from_dpo(dpo);
61 dd->dd_locks++;
62}
63
64static void
65dvr_dpo_unlock (dpo_id_t *dpo)
66{
67 dvr_dpo_t *dd;
68
69 dd = dvr_dpo_get_from_dpo(dpo);
70 dd->dd_locks--;
71
72 if (0 == dd->dd_locks)
73 {
74 if (DPO_PROTO_IP4 == dd->dd_proto)
75 {
76 vnet_feature_enable_disable ("ip4-output", "ip4-dvr-reinject",
77 dd->dd_sw_if_index, 0, 0, 0);
78 }
79 else
80 {
81 vnet_feature_enable_disable ("ip6-output", "ip6-dvr-reinject",
82 dd->dd_sw_if_index, 0, 0, 0);
83 }
84
85 dvr_dpo_db[dd->dd_proto][dd->dd_sw_if_index] = INDEX_INVALID;
86 pool_put(dvr_dpo_pool, dd);
87 }
88}
89
90void
91dvr_dpo_add_or_lock (u32 sw_if_index,
92 dpo_proto_t dproto,
93 dpo_id_t *dpo)
94{
Neale Rannsa342da22019-06-06 10:35:07 +000095 l2_input_config_t *config;
Neale Rannsf068c3e2018-01-03 04:18:48 -080096 dvr_dpo_t *dd;
97
98 vec_validate_init_empty(dvr_dpo_db[dproto],
99 sw_if_index,
100 INDEX_INVALID);
101
102 if (INDEX_INVALID == dvr_dpo_db[dproto][sw_if_index])
103 {
104 dd = dvr_dpo_alloc();
105
106 dd->dd_sw_if_index = sw_if_index;
107 dd->dd_proto = dproto;
108
109 dvr_dpo_db[dproto][sw_if_index] = dvr_dpo_get_index(dd);
110
Neale Rannsa342da22019-06-06 10:35:07 +0000111 config = l2input_intf_config (sw_if_index);
112
Neale Ranns47a3d992020-09-29 15:38:51 +0000113 if (l2_input_is_bridge(config) ||
114 l2_input_is_xconnect(config))
Neale Rannsa342da22019-06-06 10:35:07 +0000115 {
116 dd->dd_reinject = DVR_REINJECT_L2;
117 }
118 else
119 {
120 dd->dd_reinject = DVR_REINJECT_L3;
121 }
122
Neale Rannsf068c3e2018-01-03 04:18:48 -0800123 /*
124 * enable the reinject into L2 path feature on the interface
125 */
126 if (DPO_PROTO_IP4 == dproto)
127 vnet_feature_enable_disable ("ip4-output", "ip4-dvr-reinject",
128 dd->dd_sw_if_index, 1, 0, 0);
129 else if (DPO_PROTO_IP6 == dproto)
130 vnet_feature_enable_disable ("ip6-output", "ip6-dvr-reinject",
131 dd->dd_sw_if_index, 1, 0, 0);
132 else
133 ASSERT(0);
134 }
135 else
136 {
137 dd = dvr_dpo_get(dvr_dpo_db[dproto][sw_if_index]);
138 }
139
140 dpo_set(dpo, DPO_DVR, dproto, dvr_dpo_get_index(dd));
141}
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800142#endif /* CLIB_MARCH_VARIANT */
Neale Rannsf068c3e2018-01-03 04:18:48 -0800143
144
145static clib_error_t *
146dvr_dpo_interface_state_change (vnet_main_t * vnm,
147 u32 sw_if_index,
148 u32 flags)
149{
150 /*
151 */
152 return (NULL);
153}
154
155VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(
156 dvr_dpo_interface_state_change);
157
158/**
159 * @brief Registered callback for HW interface state changes
160 */
161static clib_error_t *
162dvr_dpo_hw_interface_state_change (vnet_main_t * vnm,
163 u32 hw_if_index,
164 u32 flags)
165{
166 return (NULL);
167}
168
169VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(
170 dvr_dpo_hw_interface_state_change);
171
172static clib_error_t *
173dvr_dpo_interface_delete (vnet_main_t * vnm,
174 u32 sw_if_index,
175 u32 is_add)
176{
177 return (NULL);
178}
179
180VNET_SW_INTERFACE_ADD_DEL_FUNCTION(
181 dvr_dpo_interface_delete);
182
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800183#ifndef CLIB_MARCH_VARIANT
184static u8*
Neale Rannsa342da22019-06-06 10:35:07 +0000185format_dvr_reinject (u8* s, va_list *ap)
186{
187 dvr_dpo_reinject_t ddr = va_arg(*ap, int);
188
189 switch (ddr)
190 {
191 case DVR_REINJECT_L2:
192 s = format (s, "l2");
193 break;
194 case DVR_REINJECT_L3:
195 s = format (s, "l3");
196 break;
197 }
198 return (s);
199}
200
201static u8*
Neale Rannsf068c3e2018-01-03 04:18:48 -0800202format_dvr_dpo (u8* s, va_list *ap)
203{
204 index_t index = va_arg(*ap, index_t);
205 CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
206 vnet_main_t * vnm = vnet_get_main();
207 dvr_dpo_t *dd = dvr_dpo_get(index);
208
Vladislav Grishenkofb9d1ac2022-08-04 20:36:45 +0500209 return format (s, "%U-dvr-%U-dpo %U", format_dpo_proto, dd->dd_proto,
210 format_vnet_sw_if_index_name, vnm, dd->dd_sw_if_index,
211 format_dvr_reinject, dd->dd_reinject);
Neale Rannsf068c3e2018-01-03 04:18:48 -0800212}
213
214static void
215dvr_dpo_mem_show (void)
216{
217 fib_show_memory_usage("DVR",
218 pool_elts(dvr_dpo_pool),
219 pool_len(dvr_dpo_pool),
220 sizeof(dvr_dpo_t));
221}
222
223
224const static dpo_vft_t dvr_dpo_vft = {
225 .dv_lock = dvr_dpo_lock,
226 .dv_unlock = dvr_dpo_unlock,
227 .dv_format = format_dvr_dpo,
228 .dv_mem_show = dvr_dpo_mem_show,
229};
230
231/**
232 * @brief The per-protocol VLIB graph nodes that are assigned to a glean
233 * object.
234 *
235 * this means that these graph nodes are ones from which a glean is the
236 * parent object in the DPO-graph.
237 */
238const static char* const dvr_dpo_ip4_nodes[] =
239{
240 "ip4-dvr-dpo",
241 NULL,
242};
243const static char* const dvr_dpo_ip6_nodes[] =
244{
245 "ip6-dvr-dpo",
246 NULL,
247};
248
249const static char* const * const dvr_dpo_nodes[DPO_PROTO_NUM] =
250{
251 [DPO_PROTO_IP4] = dvr_dpo_ip4_nodes,
252 [DPO_PROTO_IP6] = dvr_dpo_ip6_nodes,
253};
254
255void
256dvr_dpo_module_init (void)
257{
258 dpo_register(DPO_DVR,
259 &dvr_dpo_vft,
260 dvr_dpo_nodes);
261}
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800262#endif /* CLIB_MARCH_VARIANT */
Neale Rannsf068c3e2018-01-03 04:18:48 -0800263
264/**
265 * @brief Interface DPO trace data
266 */
267typedef struct dvr_dpo_trace_t_
268{
269 u32 sw_if_index;
270} dvr_dpo_trace_t;
271
272always_inline uword
273dvr_dpo_inline (vlib_main_t * vm,
274 vlib_node_runtime_t * node,
275 vlib_frame_t * from_frame,
276 u8 is_ip6)
277{
278 u32 n_left_from, next_index, * from, * to_next;
279 ip_lookup_main_t *lm = (is_ip6?
280 &ip6_main.lookup_main:
281 &ip4_main.lookup_main);
282
283 from = vlib_frame_vector_args (from_frame);
284 n_left_from = from_frame->n_vectors;
285
286 next_index = node->cached_next_index;
287
288 while (n_left_from > 0)
289 {
290 u32 n_left_to_next;
291
292 vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
293
294 while (n_left_from >= 4 && n_left_to_next > 2)
295 {
296 const dvr_dpo_t *dd0, *dd1;
297 u32 bi0, ddi0, bi1, ddi1;
298 vlib_buffer_t *b0, *b1;
299 u32 next0, next1;
300 u8 len0, len1;
301
302 bi0 = from[0];
303 to_next[0] = bi0;
304 bi1 = from[1];
305 to_next[1] = bi1;
306 from += 2;
307 to_next += 2;
308 n_left_from -= 2;
309 n_left_to_next -= 2;
310 next0 = next1 = 0;
311
312 b0 = vlib_get_buffer (vm, bi0);
313 b1 = vlib_get_buffer (vm, bi1);
314
315 ddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
316 ddi1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
317 dd0 = dvr_dpo_get(ddi0);
318 dd1 = dvr_dpo_get(ddi1);
319
320 vnet_buffer(b0)->sw_if_index[VLIB_TX] = dd0->dd_sw_if_index;
321 vnet_buffer(b1)->sw_if_index[VLIB_TX] = dd1->dd_sw_if_index;
322
323 len0 = ((u8*)vlib_buffer_get_current(b0) -
324 (u8*)ethernet_buffer_get_header(b0));
325 len1 = ((u8*)vlib_buffer_get_current(b1) -
326 (u8*)ethernet_buffer_get_header(b1));
Neale Ranns7bf3f9f2018-04-09 02:25:27 -0700327 vnet_buffer(b0)->l2.l2_len =
328 vnet_buffer(b0)->ip.save_rewrite_length =
329 len0;
330 vnet_buffer(b1)->l2.l2_len =
331 vnet_buffer(b1)->ip.save_rewrite_length =
332 len1;
Neale Rannsa342da22019-06-06 10:35:07 +0000333
Damjan Mariondac03522018-02-01 15:30:13 +0100334 b0->flags |= VNET_BUFFER_F_IS_DVR;
335 b1->flags |= VNET_BUFFER_F_IS_DVR;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800336
337 vlib_buffer_advance(b0, -len0);
338 vlib_buffer_advance(b1, -len1);
339
340 vnet_feature_arc_start (lm->output_feature_arc_index,
341 dd0->dd_sw_if_index, &next0, b0);
342 vnet_feature_arc_start (lm->output_feature_arc_index,
343 dd1->dd_sw_if_index, &next1, b1);
344
345 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
346 {
347 dvr_dpo_trace_t *tr0;
348
349 tr0 = vlib_add_trace (vm, node, b0, sizeof (*tr0));
350 tr0->sw_if_index = dd0->dd_sw_if_index;
351 }
352 if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
353 {
354 dvr_dpo_trace_t *tr1;
355
356 tr1 = vlib_add_trace (vm, node, b1, sizeof (*tr1));
357 tr1->sw_if_index = dd1->dd_sw_if_index;
358 }
359
360 vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
361 n_left_to_next, bi0, bi1,
362 next0, next1);
363 }
364
365 while (n_left_from > 0 && n_left_to_next > 0)
366 {
367 const dvr_dpo_t * dd0;
368 vlib_buffer_t * b0;
369 u32 bi0, ddi0;
370 u32 next0;
371 u8 len0;
372
373 bi0 = from[0];
374 to_next[0] = bi0;
375 from += 1;
376 to_next += 1;
377 n_left_from -= 1;
378 n_left_to_next -= 1;
379 next0 = 0;
380
381 b0 = vlib_get_buffer (vm, bi0);
382
383 ddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
384 dd0 = dvr_dpo_get(ddi0);
385
386 vnet_buffer(b0)->sw_if_index[VLIB_TX] = dd0->dd_sw_if_index;
387
388 /*
389 * take that, rewind it back...
390 */
391 len0 = ((u8*)vlib_buffer_get_current(b0) -
392 (u8*)ethernet_buffer_get_header(b0));
Neale Ranns7bf3f9f2018-04-09 02:25:27 -0700393 vnet_buffer(b0)->l2.l2_len =
394 vnet_buffer(b0)->ip.save_rewrite_length =
395 len0;
Damjan Mariondac03522018-02-01 15:30:13 +0100396 b0->flags |= VNET_BUFFER_F_IS_DVR;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800397 vlib_buffer_advance(b0, -len0);
398
399 /*
400 * start processing the ipX output features
401 */
402 vnet_feature_arc_start(lm->output_feature_arc_index,
403 dd0->dd_sw_if_index, &next0, b0);
404
405 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
406 {
407 dvr_dpo_trace_t *tr;
408
409 tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
410 tr->sw_if_index = dd0->dd_sw_if_index;
411 }
412
413 vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
414 n_left_to_next, bi0,
415 next0);
416 }
417 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
418 }
419 return from_frame->n_vectors;
420}
421
422static u8 *
423format_dvr_dpo_trace (u8 * s, va_list * args)
424{
425 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
426 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
427 dvr_dpo_trace_t * t = va_arg (*args, dvr_dpo_trace_t *);
428 u32 indent = format_get_indent (s);
429 s = format (s, "%U sw_if_index:%d",
430 format_white_space, indent,
431 t->sw_if_index);
432 return s;
433}
434
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800435VLIB_NODE_FN (ip4_dvr_dpo_node) (vlib_main_t * vm,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800436 vlib_node_runtime_t * node,
437 vlib_frame_t * from_frame)
438{
439 return (dvr_dpo_inline(vm, node, from_frame, 0));
440}
441
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800442VLIB_NODE_FN (ip6_dvr_dpo_node) (vlib_main_t * vm,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800443 vlib_node_runtime_t * node,
444 vlib_frame_t * from_frame)
445{
446 return (dvr_dpo_inline(vm, node, from_frame, 1));
447}
448
449VLIB_REGISTER_NODE (ip4_dvr_dpo_node) = {
Neale Rannsf068c3e2018-01-03 04:18:48 -0800450 .name = "ip4-dvr-dpo",
451 .vector_size = sizeof (u32),
452 .format_trace = format_dvr_dpo_trace,
453 .sibling_of = "ip4-rewrite",
454};
455VLIB_REGISTER_NODE (ip6_dvr_dpo_node) = {
Neale Rannsf068c3e2018-01-03 04:18:48 -0800456 .name = "ip6-dvr-dpo",
457 .vector_size = sizeof (u32),
458 .format_trace = format_dvr_dpo_trace,
459 .sibling_of = "ip6-rewrite",
460};
461
Neale Rannsf068c3e2018-01-03 04:18:48 -0800462typedef enum dvr_reinject_next_t_
463{
Neale Rannsa342da22019-06-06 10:35:07 +0000464 DVR_REINJECT_NEXT_L2,
465 DVR_REINJECT_NEXT_L3,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800466} dvr_reinject_next_t;
467
468always_inline uword
469dvr_reinject_inline (vlib_main_t * vm,
470 vlib_node_runtime_t * node,
471 vlib_frame_t * from_frame)
472{
473 u32 n_left_from, next_index, * from, * to_next;
474
475 from = vlib_frame_vector_args (from_frame);
476 n_left_from = from_frame->n_vectors;
477
478 next_index = node->cached_next_index;
479
480 while (n_left_from > 0)
481 {
482 u32 n_left_to_next;
483
484 vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
485
486 while (n_left_from >= 4 && n_left_to_next > 2)
487 {
488 dvr_reinject_next_t next0, next1;
Neale Rannsa342da22019-06-06 10:35:07 +0000489 const dvr_dpo_t *dd0, *dd1;
490 u32 bi0, bi1, ddi0, ddi1;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800491 vlib_buffer_t *b0, *b1;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800492
493 bi0 = from[0];
494 to_next[0] = bi0;
495 bi1 = from[1];
496 to_next[1] = bi1;
497 from += 2;
498 to_next += 2;
499 n_left_from -= 2;
500 n_left_to_next -= 2;
501
502 b0 = vlib_get_buffer (vm, bi0);
503 b1 = vlib_get_buffer (vm, bi1);
504
Damjan Mariondac03522018-02-01 15:30:13 +0100505 if (b0->flags & VNET_BUFFER_F_IS_DVR)
Neale Rannsa342da22019-06-06 10:35:07 +0000506 {
507 ddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
508 dd0 = dvr_dpo_get(ddi0);
509 next0 = (dd0->dd_reinject == DVR_REINJECT_L2 ?
510 DVR_REINJECT_NEXT_L2 :
511 DVR_REINJECT_NEXT_L3);
512 }
Neale Rannsf068c3e2018-01-03 04:18:48 -0800513 else
Damjan Marion7d98a122018-07-19 20:42:08 +0200514 vnet_feature_next( &next0, b0);
Neale Rannsf068c3e2018-01-03 04:18:48 -0800515
Damjan Mariondac03522018-02-01 15:30:13 +0100516 if (b1->flags & VNET_BUFFER_F_IS_DVR)
Neale Rannsa342da22019-06-06 10:35:07 +0000517 {
518 ddi1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
519 dd1 = dvr_dpo_get(ddi1);
520 next1 = (dd1->dd_reinject == DVR_REINJECT_L2 ?
521 DVR_REINJECT_NEXT_L2 :
522 DVR_REINJECT_NEXT_L3);
523 }
Neale Rannsf068c3e2018-01-03 04:18:48 -0800524 else
Damjan Marion7d98a122018-07-19 20:42:08 +0200525 vnet_feature_next( &next1, b1);
Neale Rannsf068c3e2018-01-03 04:18:48 -0800526
527 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
528 {
529 dvr_dpo_trace_t *tr0;
530
531 tr0 = vlib_add_trace (vm, node, b0, sizeof (*tr0));
532 tr0->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_TX];
533 }
534 if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
535 {
536 dvr_dpo_trace_t *tr1;
537
538 tr1 = vlib_add_trace (vm, node, b1, sizeof (*tr1));
539 tr1->sw_if_index = vnet_buffer(b1)->sw_if_index[VLIB_TX];
540 }
541
542 vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
543 n_left_to_next, bi0, bi1,
544 next0, next1);
545 }
546
547 while (n_left_from > 0 && n_left_to_next > 0)
548 {
549 dvr_reinject_next_t next0;
Neale Rannsa342da22019-06-06 10:35:07 +0000550 const dvr_dpo_t *dd0;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800551 vlib_buffer_t * b0;
Neale Rannsa342da22019-06-06 10:35:07 +0000552 u32 bi0, ddi0;
Neale Rannsf068c3e2018-01-03 04:18:48 -0800553
554 bi0 = from[0];
555 to_next[0] = bi0;
556 from += 1;
557 to_next += 1;
558 n_left_from -= 1;
559 n_left_to_next -= 1;
560
561 b0 = vlib_get_buffer (vm, bi0);
562
Damjan Mariondac03522018-02-01 15:30:13 +0100563 if (b0->flags & VNET_BUFFER_F_IS_DVR)
Neale Rannsa342da22019-06-06 10:35:07 +0000564 {
565 ddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
566 dd0 = dvr_dpo_get(ddi0);
567 next0 = (dd0->dd_reinject == DVR_REINJECT_L2 ?
568 DVR_REINJECT_NEXT_L2 :
569 DVR_REINJECT_NEXT_L3);
570 }
Neale Rannsf068c3e2018-01-03 04:18:48 -0800571 else
Damjan Marion7d98a122018-07-19 20:42:08 +0200572 vnet_feature_next( &next0, b0);
Neale Rannsf068c3e2018-01-03 04:18:48 -0800573
574 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
575 {
576 dvr_dpo_trace_t *tr;
577
578 tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
579 tr->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_TX];
580 }
581
582 vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
583 n_left_to_next, bi0, next0);
584 }
585 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
586 }
587 return from_frame->n_vectors;
588}
589
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800590VLIB_NODE_FN (ip4_dvr_reinject_node) (vlib_main_t * vm,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800591 vlib_node_runtime_t * node,
592 vlib_frame_t * from_frame)
593{
594 return (dvr_reinject_inline(vm, node, from_frame));
595}
596
Filip Tehlareb9a27f2019-03-07 01:42:11 -0800597VLIB_NODE_FN (ip6_dvr_reinject_node) (vlib_main_t * vm,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800598 vlib_node_runtime_t * node,
599 vlib_frame_t * from_frame)
600{
601 return (dvr_reinject_inline(vm, node, from_frame));
602}
603
604VLIB_REGISTER_NODE (ip4_dvr_reinject_node) = {
Neale Rannsf068c3e2018-01-03 04:18:48 -0800605 .name = "ip4-dvr-reinject",
606 .vector_size = sizeof (u32),
607 .format_trace = format_dvr_dpo_trace,
608
609 .n_next_nodes = 1,
610 .next_nodes = {
Neale Rannsa342da22019-06-06 10:35:07 +0000611 [DVR_REINJECT_NEXT_L2] = "l2-output",
612 [DVR_REINJECT_NEXT_L3] = "interface-output",
Neale Rannsf068c3e2018-01-03 04:18:48 -0800613 },
614};
615
616VLIB_REGISTER_NODE (ip6_dvr_reinject_node) = {
Neale Rannsf068c3e2018-01-03 04:18:48 -0800617 .name = "ip6-dvr-reinject",
618 .vector_size = sizeof (u32),
619 .format_trace = format_dvr_dpo_trace,
620
621 .n_next_nodes = 1,
622 .next_nodes = {
Neale Rannsa342da22019-06-06 10:35:07 +0000623 [DVR_REINJECT_NEXT_L2] = "l2-output",
624 [DVR_REINJECT_NEXT_L3] = "interface-output",
Neale Rannsf068c3e2018-01-03 04:18:48 -0800625 },
626};
627
628VNET_FEATURE_INIT (ip4_dvr_reinject_feat_node, static) =
629{
630 .arc_name = "ip4-output",
631 .node_name = "ip4-dvr-reinject",
Neale Rannsf068c3e2018-01-03 04:18:48 -0800632};
633VNET_FEATURE_INIT (ip6_dvr_reinject_feat_node, static) =
634{
635 .arc_name = "ip6-output",
636 .node_name = "ip6-dvr-reinject",
Neale Rannsf068c3e2018-01-03 04:18:48 -0800637};
638