2 * Copyright (c) 2018 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @brief NAT44 hairpinning
20 #include <vlib/vlib.h>
21 #include <vnet/vnet.h>
22 #include <vnet/fib/ip4_fib.h>
24 #include <nat/nat_inlines.h>
28 SNAT_HAIRPIN_SRC_NEXT_DROP,
29 SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT,
30 SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT_WH,
31 SNAT_HAIRPIN_SRC_NEXT_INTERFACE_OUTPUT,
32 SNAT_HAIRPIN_SRC_N_NEXT,
33 } snat_hairpin_src_next_t;
37 NAT_HAIRPIN_NEXT_LOOKUP,
38 NAT_HAIRPIN_NEXT_DROP,
48 } nat_hairpin_trace_t;
51 format_nat_hairpin_trace (u8 * s, va_list * args)
53 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
54 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
55 nat_hairpin_trace_t *t = va_arg (*args, nat_hairpin_trace_t *);
58 format (s, "new dst addr %U port %u fib-index %u", format_ip4_address,
59 &t->addr, clib_net_to_host_u16 (t->port), t->fib_index);
60 if (~0 == t->session_index)
62 s = format (s, " is-static-mapping");
66 s = format (s, " session-index %u", t->session_index);
72 extern vnet_feature_arc_registration_t vnet_feat_arc_ip4_local;
74 static_always_inline int
75 is_hairpinning (snat_main_t * sm, ip4_address_t * dst_addr)
78 clib_bihash_kv_8_8_t kv, value;
81 vec_foreach (ap, sm->addresses)
83 if (ap->addr.as_u32 == dst_addr->as_u32)
88 init_nat_k (&kv, *dst_addr, 0, 0, 0);
89 if (!clib_bihash_search_8_8 (&sm->static_mapping_by_external, &kv, &value))
95 #ifndef CLIB_MARCH_VARIANT
97 snat_hairpinning (vlib_main_t * vm, vlib_node_runtime_t * node,
98 snat_main_t * sm, vlib_buffer_t * b0, ip4_header_t * ip0,
99 udp_header_t * udp0, tcp_header_t * tcp0, u32 proto0,
100 int is_ed, int do_trace)
102 snat_session_t *s0 = NULL;
103 clib_bihash_kv_8_8_t kv0, value0;
105 u32 new_dst_addr0 = 0, old_dst_addr0, ti = 0, si = ~0;
106 u16 new_dst_port0 = ~0, old_dst_port0;
108 ip4_address_t sm0_addr;
111 /* Check if destination is static mappings */
112 if (!snat_static_mapping_match
113 (sm, ip0->dst_address, udp0->dst_port, sm->outside_fib_index, proto0,
114 &sm0_addr, &sm0_port, &sm0_fib_index, 1, 0, 0, 0, 0, 0))
116 new_dst_addr0 = sm0_addr.as_u32;
117 new_dst_port0 = sm0_port;
118 vnet_buffer (b0)->sw_if_index[VLIB_TX] = sm0_fib_index;
120 /* or active session */
123 if (sm->num_workers > 1)
125 (clib_net_to_host_u16 (udp0->dst_port) -
126 1024) / sm->port_per_thread;
128 ti = sm->num_workers;
132 clib_bihash_kv_16_8_t ed_kv, ed_value;
133 init_ed_k (&ed_kv, ip0->dst_address, udp0->dst_port,
134 ip0->src_address, udp0->src_port, sm->outside_fib_index,
136 rv = clib_bihash_search_16_8 (&sm->out2in_ed, &ed_kv, &ed_value);
137 ASSERT (ti == ed_value_get_thread_index (&ed_value));
138 si = ed_value_get_session_index (&ed_value);
143 init_nat_k (&kv0, ip0->dst_address, udp0->dst_port,
144 sm->outside_fib_index, proto0);
146 clib_bihash_search_8_8 (&sm->per_thread_data[ti].out2in, &kv0,
156 s0 = pool_elt_at_index (sm->per_thread_data[ti].sessions, si);
157 new_dst_addr0 = s0->in2out.addr.as_u32;
158 new_dst_port0 = s0->in2out.port;
159 vnet_buffer (b0)->sw_if_index[VLIB_TX] = s0->in2out.fib_index;
162 /* Destination is behind the same NAT, use internal address and port */
165 old_dst_addr0 = ip0->dst_address.as_u32;
166 ip0->dst_address.as_u32 = new_dst_addr0;
167 sum0 = ip0->checksum;
168 sum0 = ip_csum_update (sum0, old_dst_addr0, new_dst_addr0,
169 ip4_header_t, dst_address);
170 ip0->checksum = ip_csum_fold (sum0);
172 old_dst_port0 = tcp0->dst;
173 if (PREDICT_TRUE (new_dst_port0 != old_dst_port0))
175 if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
177 tcp0->dst = new_dst_port0;
178 sum0 = tcp0->checksum;
179 sum0 = ip_csum_update (sum0, old_dst_addr0, new_dst_addr0,
180 ip4_header_t, dst_address);
181 sum0 = ip_csum_update (sum0, old_dst_port0, new_dst_port0,
182 ip4_header_t /* cheat */ , length);
183 tcp0->checksum = ip_csum_fold (sum0);
187 udp0->dst_port = new_dst_port0;
193 if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
195 sum0 = tcp0->checksum;
196 sum0 = ip_csum_update (sum0, old_dst_addr0, new_dst_addr0,
197 ip4_header_t, dst_address);
198 tcp0->checksum = ip_csum_fold (sum0);
206 if (do_trace && PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
207 && (b0->flags & VLIB_BUFFER_IS_TRACED)))
209 nat_hairpin_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
210 t->addr.as_u32 = new_dst_addr0;
211 t->port = new_dst_port0;
212 t->fib_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
215 t->session_index = si;
219 t->session_index = ~0;
226 #ifndef CLIB_MARCH_VARIANT
228 snat_icmp_hairpinning (snat_main_t * sm,
230 ip4_header_t * ip0, icmp46_header_t * icmp0, int is_ed)
232 clib_bihash_kv_8_8_t kv0, value0;
233 u32 old_dst_addr0, new_dst_addr0;
234 u32 old_addr0, new_addr0;
235 u16 old_port0, new_port0;
236 u16 old_checksum0, new_checksum0;
240 snat_static_mapping_t *m0;
242 if (icmp_type_is_error_message
243 (vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags))
245 ip4_header_t *inner_ip0 = 0;
246 tcp_udp_header_t *l4_header = 0;
248 inner_ip0 = (ip4_header_t *) ((icmp_echo_header_t *) (icmp0 + 1) + 1);
249 l4_header = ip4_next_header (inner_ip0);
250 u32 protocol = ip_proto_to_nat_proto (inner_ip0->protocol);
252 if (protocol != NAT_PROTOCOL_TCP && protocol != NAT_PROTOCOL_UDP)
257 clib_bihash_kv_16_8_t ed_kv, ed_value;
258 init_ed_k (&ed_kv, ip0->dst_address, l4_header->src_port,
259 ip0->src_address, l4_header->dst_port,
260 sm->outside_fib_index, inner_ip0->protocol);
261 if (clib_bihash_search_16_8 (&sm->out2in_ed, &ed_kv, &ed_value))
263 ASSERT (ti == ed_value_get_thread_index (&ed_value));
264 si = ed_value_get_session_index (&ed_value);
268 init_nat_k (&kv0, ip0->dst_address, l4_header->src_port,
269 sm->outside_fib_index, protocol);
270 if (clib_bihash_search_8_8
271 (&sm->per_thread_data[ti].out2in, &kv0, &value0))
275 s0 = pool_elt_at_index (sm->per_thread_data[ti].sessions, si);
276 new_dst_addr0 = s0->in2out.addr.as_u32;
277 vnet_buffer (b0)->sw_if_index[VLIB_TX] = s0->in2out.fib_index;
279 /* update inner source IP address */
280 old_addr0 = inner_ip0->src_address.as_u32;
281 inner_ip0->src_address.as_u32 = new_dst_addr0;
282 new_addr0 = inner_ip0->src_address.as_u32;
283 sum0 = icmp0->checksum;
284 sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t,
286 icmp0->checksum = ip_csum_fold (sum0);
288 /* update inner IP header checksum */
289 old_checksum0 = inner_ip0->checksum;
290 sum0 = inner_ip0->checksum;
291 sum0 = ip_csum_update (sum0, old_addr0, new_addr0, ip4_header_t,
293 inner_ip0->checksum = ip_csum_fold (sum0);
294 new_checksum0 = inner_ip0->checksum;
295 sum0 = icmp0->checksum;
296 sum0 = ip_csum_update (sum0, old_checksum0, new_checksum0, ip4_header_t,
298 icmp0->checksum = ip_csum_fold (sum0);
300 /* update inner source port */
301 old_port0 = l4_header->src_port;
302 l4_header->src_port = s0->in2out.port;
303 new_port0 = l4_header->src_port;
304 sum0 = icmp0->checksum;
305 sum0 = ip_csum_update (sum0, old_port0, new_port0, tcp_udp_header_t,
307 icmp0->checksum = ip_csum_fold (sum0);
311 init_nat_k (&kv0, ip0->dst_address, 0, sm->outside_fib_index, 0);
312 if (clib_bihash_search_8_8
313 (&sm->static_mapping_by_external, &kv0, &value0))
317 icmp_echo_header_t *echo0 = (icmp_echo_header_t *) (icmp0 + 1);
318 u16 icmp_id0 = echo0->identifier;
319 init_nat_k (&kv0, ip0->dst_address, icmp_id0,
320 sm->outside_fib_index, NAT_PROTOCOL_ICMP);
321 if (sm->num_workers > 1)
323 (clib_net_to_host_u16 (icmp_id0) -
324 1024) / sm->port_per_thread;
326 ti = sm->num_workers;
328 clib_bihash_search_8_8 (&sm->per_thread_data[ti].out2in, &kv0,
334 pool_elt_at_index (sm->per_thread_data[ti].sessions, si);
335 new_dst_addr0 = s0->in2out.addr.as_u32;
336 vnet_buffer (b0)->sw_if_index[VLIB_TX] =
337 s0->in2out.fib_index;
338 echo0->identifier = s0->in2out.port;
339 sum0 = icmp0->checksum;
340 sum0 = ip_csum_update (sum0, icmp_id0, s0->in2out.port,
341 icmp_echo_header_t, identifier);
342 icmp0->checksum = ip_csum_fold (sum0);
350 m0 = pool_elt_at_index (sm->static_mappings, value0.value);
352 new_dst_addr0 = m0->local_addr.as_u32;
353 if (vnet_buffer (b0)->sw_if_index[VLIB_TX] == ~0)
354 vnet_buffer (b0)->sw_if_index[VLIB_TX] = m0->fib_index;
357 /* Destination is behind the same NAT, use internal address and port */
360 old_dst_addr0 = ip0->dst_address.as_u32;
361 ip0->dst_address.as_u32 = new_dst_addr0;
362 sum0 = ip0->checksum;
363 sum0 = ip_csum_update (sum0, old_dst_addr0, new_dst_addr0,
364 ip4_header_t, dst_address);
365 ip0->checksum = ip_csum_fold (sum0);
371 #ifndef CLIB_MARCH_VARIANT
373 nat_hairpinning_sm_unknown_proto (snat_main_t * sm,
374 vlib_buffer_t * b, ip4_header_t * ip)
376 clib_bihash_kv_8_8_t kv, value;
377 snat_static_mapping_t *m;
378 u32 old_addr, new_addr;
381 init_nat_k (&kv, ip->dst_address, 0, 0, 0);
382 if (clib_bihash_search_8_8 (&sm->static_mapping_by_external, &kv, &value))
385 m = pool_elt_at_index (sm->static_mappings, value.value);
387 old_addr = ip->dst_address.as_u32;
388 new_addr = ip->dst_address.as_u32 = m->local_addr.as_u32;
390 sum = ip_csum_update (sum, old_addr, new_addr, ip4_header_t, dst_address);
391 ip->checksum = ip_csum_fold (sum);
393 if (vnet_buffer (b)->sw_if_index[VLIB_TX] == ~0)
394 vnet_buffer (b)->sw_if_index[VLIB_TX] = m->fib_index;
398 #ifndef CLIB_MARCH_VARIANT
400 nat44_ed_hairpinning_unknown_proto (snat_main_t * sm,
401 vlib_buffer_t * b, ip4_header_t * ip)
403 u32 old_addr, new_addr = 0, ti = 0;
404 clib_bihash_kv_8_8_t kv, value;
405 clib_bihash_kv_16_8_t s_kv, s_value;
406 snat_static_mapping_t *m;
410 if (sm->num_workers > 1)
411 ti = sm->worker_out2in_cb (b, ip, sm->outside_fib_index, 0);
413 ti = sm->num_workers;
415 old_addr = ip->dst_address.as_u32;
416 init_ed_k (&s_kv, ip->dst_address, 0, ip->src_address, 0,
417 sm->outside_fib_index, ip->protocol);
418 if (clib_bihash_search_16_8 (&sm->out2in_ed, &s_kv, &s_value))
420 init_nat_k (&kv, ip->dst_address, 0, 0, 0);
421 if (clib_bihash_search_8_8
422 (&sm->static_mapping_by_external, &kv, &value))
425 m = pool_elt_at_index (sm->static_mappings, value.value);
426 if (vnet_buffer (b)->sw_if_index[VLIB_TX] == ~0)
427 vnet_buffer (b)->sw_if_index[VLIB_TX] = m->fib_index;
428 new_addr = ip->dst_address.as_u32 = m->local_addr.as_u32;
432 ASSERT (ti == ed_value_get_thread_index (&s_value));
434 pool_elt_at_index (sm->per_thread_data[ti].sessions,
435 ed_value_get_session_index (&s_value));
436 if (vnet_buffer (b)->sw_if_index[VLIB_TX] == ~0)
437 vnet_buffer (b)->sw_if_index[VLIB_TX] = s->in2out.fib_index;
438 new_addr = ip->dst_address.as_u32 = s->in2out.addr.as_u32;
441 sum = ip_csum_update (sum, old_addr, new_addr, ip4_header_t, dst_address);
442 ip->checksum = ip_csum_fold (sum);
447 nat44_hairpinning_fn_inline (vlib_main_t * vm,
448 vlib_node_runtime_t * node,
449 vlib_frame_t * frame, int is_ed)
451 u32 n_left_from, *from, *to_next;
452 nat_hairpin_next_t next_index;
453 snat_main_t *sm = &snat_main;
454 vnet_feature_main_t *fm = &feature_main;
455 u8 arc_index = vnet_feat_arc_ip4_local.feature_arc_index;
456 vnet_feature_config_main_t *cm = &fm->feature_config_mains[arc_index];
458 from = vlib_frame_vector_args (frame);
459 n_left_from = frame->n_vectors;
460 next_index = node->cached_next_index;
462 while (n_left_from > 0)
466 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
468 while (n_left_from > 0 && n_left_to_next > 0)
479 /* speculatively enqueue b0 to the current next frame */
487 b0 = vlib_get_buffer (vm, bi0);
488 ip0 = vlib_buffer_get_current (b0);
489 udp0 = ip4_next_header (ip0);
490 tcp0 = (tcp_header_t *) udp0;
491 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
493 proto0 = ip_proto_to_nat_proto (ip0->protocol);
495 vnet_get_config_data (&cm->config_main, &b0->current_config_index,
499 (vm, node, sm, b0, ip0, udp0, tcp0, proto0, is_ed,
501 next0 = NAT_HAIRPIN_NEXT_LOOKUP;
503 if (next0 != NAT_HAIRPIN_NEXT_DROP)
505 vlib_increment_simple_counter (&sm->counters.hairpinning,
506 vm->thread_index, sw_if_index0,
510 /* verify speculative enqueue, maybe switch current next frame */
511 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
512 to_next, n_left_to_next,
516 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
519 return frame->n_vectors;
522 VLIB_NODE_FN (nat44_hairpinning_node) (vlib_main_t * vm,
523 vlib_node_runtime_t * node,
524 vlib_frame_t * frame)
526 return nat44_hairpinning_fn_inline (vm, node, frame, 0);
530 VLIB_REGISTER_NODE (nat44_hairpinning_node) = {
531 .name = "nat44-hairpinning",
532 .vector_size = sizeof (u32),
533 .type = VLIB_NODE_TYPE_INTERNAL,
534 .format_trace = format_nat_hairpin_trace,
535 .n_next_nodes = NAT_HAIRPIN_N_NEXT,
537 [NAT_HAIRPIN_NEXT_DROP] = "error-drop",
538 [NAT_HAIRPIN_NEXT_LOOKUP] = "ip4-lookup",
543 VLIB_NODE_FN (nat44_ed_hairpinning_node) (vlib_main_t * vm,
544 vlib_node_runtime_t * node,
545 vlib_frame_t * frame)
547 return nat44_hairpinning_fn_inline (vm, node, frame, 1);
551 VLIB_REGISTER_NODE (nat44_ed_hairpinning_node) = {
552 .name = "nat44-ed-hairpinning",
553 .vector_size = sizeof (u32),
554 .type = VLIB_NODE_TYPE_INTERNAL,
555 .format_trace = format_nat_hairpin_trace,
556 .n_next_nodes = NAT_HAIRPIN_N_NEXT,
558 [NAT_HAIRPIN_NEXT_DROP] = "error-drop",
559 [NAT_HAIRPIN_NEXT_LOOKUP] = "ip4-lookup",
565 snat_hairpin_dst_fn_inline (vlib_main_t * vm,
566 vlib_node_runtime_t * node,
567 vlib_frame_t * frame, int is_ed)
569 u32 n_left_from, *from, *to_next;
570 nat_hairpin_next_t next_index;
571 snat_main_t *sm = &snat_main;
573 from = vlib_frame_vector_args (frame);
574 n_left_from = frame->n_vectors;
575 next_index = node->cached_next_index;
577 while (n_left_from > 0)
581 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
583 while (n_left_from > 0 && n_left_to_next > 0)
592 /* speculatively enqueue b0 to the current next frame */
600 b0 = vlib_get_buffer (vm, bi0);
601 next0 = NAT_HAIRPIN_NEXT_LOOKUP;
602 ip0 = vlib_buffer_get_current (b0);
603 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
605 proto0 = ip_proto_to_nat_proto (ip0->protocol);
607 vnet_buffer (b0)->snat.flags = 0;
608 if (PREDICT_FALSE (is_hairpinning (sm, &ip0->dst_address)))
610 if (proto0 == NAT_PROTOCOL_TCP || proto0 == NAT_PROTOCOL_UDP)
612 udp_header_t *udp0 = ip4_next_header (ip0);
613 tcp_header_t *tcp0 = (tcp_header_t *) udp0;
615 snat_hairpinning (vm, node, sm, b0, ip0, udp0, tcp0, proto0,
616 is_ed, 1 /* do_trace */ );
618 else if (proto0 == NAT_PROTOCOL_ICMP)
620 icmp46_header_t *icmp0 = ip4_next_header (ip0);
622 snat_icmp_hairpinning (sm, b0, ip0, icmp0, is_ed);
627 nat44_ed_hairpinning_unknown_proto (sm, b0, ip0);
629 nat_hairpinning_sm_unknown_proto (sm, b0, ip0);
632 vnet_buffer (b0)->snat.flags = SNAT_FLAG_HAIRPINNING;
636 if (next0 != NAT_HAIRPIN_NEXT_DROP)
638 vlib_increment_simple_counter (&sm->counters.hairpinning,
639 vm->thread_index, sw_if_index0,
643 /* verify speculative enqueue, maybe switch current next frame */
644 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
645 to_next, n_left_to_next,
649 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
652 return frame->n_vectors;
655 VLIB_NODE_FN (snat_hairpin_dst_node) (vlib_main_t * vm,
656 vlib_node_runtime_t * node,
657 vlib_frame_t * frame)
659 return snat_hairpin_dst_fn_inline (vm, node, frame, 0);
663 VLIB_REGISTER_NODE (snat_hairpin_dst_node) = {
664 .name = "nat44-hairpin-dst",
665 .vector_size = sizeof (u32),
666 .type = VLIB_NODE_TYPE_INTERNAL,
667 .format_trace = format_nat_hairpin_trace,
668 .n_next_nodes = NAT_HAIRPIN_N_NEXT,
670 [NAT_HAIRPIN_NEXT_DROP] = "error-drop",
671 [NAT_HAIRPIN_NEXT_LOOKUP] = "ip4-lookup",
676 VLIB_NODE_FN (nat44_ed_hairpin_dst_node) (vlib_main_t * vm,
677 vlib_node_runtime_t * node,
678 vlib_frame_t * frame)
680 return snat_hairpin_dst_fn_inline (vm, node, frame, 1);
684 VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node) = {
685 .name = "nat44-ed-hairpin-dst",
686 .vector_size = sizeof (u32),
687 .type = VLIB_NODE_TYPE_INTERNAL,
688 .format_trace = format_nat_hairpin_trace,
689 .n_next_nodes = NAT_HAIRPIN_N_NEXT,
691 [NAT_HAIRPIN_NEXT_DROP] = "error-drop",
692 [NAT_HAIRPIN_NEXT_LOOKUP] = "ip4-lookup",
698 snat_hairpin_src_fn_inline (vlib_main_t * vm,
699 vlib_node_runtime_t * node,
700 vlib_frame_t * frame, int is_ed)
702 u32 n_left_from, *from, *to_next;
703 snat_hairpin_src_next_t next_index;
704 snat_main_t *sm = &snat_main;
706 from = vlib_frame_vector_args (frame);
707 n_left_from = frame->n_vectors;
708 next_index = node->cached_next_index;
710 while (n_left_from > 0)
714 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
716 while (n_left_from > 0 && n_left_to_next > 0)
724 /* speculatively enqueue b0 to the current next frame */
732 b0 = vlib_get_buffer (vm, bi0);
733 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
734 vnet_feature_next (&next0, b0);
737 pool_foreach (i, sm->output_feature_interfaces,
739 /* Only packets from NAT inside interface */
740 if ((nat_interface_is_inside(i)) && (sw_if_index0 == i->sw_if_index))
742 if (PREDICT_FALSE ((vnet_buffer (b0)->snat.flags) &
743 SNAT_FLAG_HAIRPINNING))
745 if (PREDICT_TRUE (sm->num_workers > 1))
746 next0 = SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT_WH;
748 next0 = SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT;
755 if (next0 != SNAT_HAIRPIN_SRC_NEXT_DROP)
757 vlib_increment_simple_counter (&sm->counters.hairpinning,
758 vm->thread_index, sw_if_index0,
762 /* verify speculative enqueue, maybe switch current next frame */
763 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
764 to_next, n_left_to_next,
768 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
771 return frame->n_vectors;
774 VLIB_NODE_FN (snat_hairpin_src_node) (vlib_main_t * vm,
775 vlib_node_runtime_t * node,
776 vlib_frame_t * frame)
778 return snat_hairpin_src_fn_inline (vm, node, frame, 0);
782 VLIB_REGISTER_NODE (snat_hairpin_src_node) = {
783 .name = "nat44-hairpin-src",
784 .vector_size = sizeof (u32),
785 .type = VLIB_NODE_TYPE_INTERNAL,
786 .n_next_nodes = SNAT_HAIRPIN_SRC_N_NEXT,
788 [SNAT_HAIRPIN_SRC_NEXT_DROP] = "error-drop",
789 [SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT] = "nat44-in2out-output",
790 [SNAT_HAIRPIN_SRC_NEXT_INTERFACE_OUTPUT] = "interface-output",
791 [SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT_WH] = "nat44-in2out-output-worker-handoff",
796 VLIB_NODE_FN (nat44_ed_hairpin_src_node) (vlib_main_t * vm,
797 vlib_node_runtime_t * node,
798 vlib_frame_t * frame)
800 return snat_hairpin_src_fn_inline (vm, node, frame, 1);
804 VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node) = {
805 .name = "nat44-ed-hairpin-src",
806 .vector_size = sizeof (u32),
807 .type = VLIB_NODE_TYPE_INTERNAL,
808 .n_next_nodes = SNAT_HAIRPIN_SRC_N_NEXT,
810 [SNAT_HAIRPIN_SRC_NEXT_DROP] = "error-drop",
811 [SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT] = "nat44-ed-in2out-output",
812 [SNAT_HAIRPIN_SRC_NEXT_INTERFACE_OUTPUT] = "interface-output",
813 [SNAT_HAIRPIN_SRC_NEXT_SNAT_IN2OUT_WH] = "nat44-in2out-output-worker-handoff",
819 * fd.io coding-style-patch-verification: ON
822 * eval: (c-set-style "gnu")