50 #define foreach_det44_in2out_error \
51 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \
52 _(NO_TRANSLATION, "No translation") \
53 _(BAD_ICMP_TYPE, "unsupported ICMP type") \
54 _(OUT_OF_PORTS, "Out of ports") \
55 _(IN2OUT_PACKETS, "Good in2out packets processed")
59 #define _(sym,str) DET44_IN2OUT_ERROR_##sym,
66 #define _(sym,string) string,
78 s =
format (s,
"DET44_IN2OUT: sw_if_index %d, next index %d, session %d",
84 #ifndef CLIB_MARCH_VARIANT
109 icmp46_header_t *icmp0;
118 icmp46_header_t *inner_icmp0;
148 case NAT_PROTOCOL_ICMP:
149 inner_icmp0 = (icmp46_header_t *) l4_header;
153 case NAT_PROTOCOL_UDP:
154 case NAT_PROTOCOL_TCP:
158 b0->
error =
node->errors[DET44_IN2OUT_ERROR_UNSUPPORTED_PROTOCOL];
168 IP_PROTOCOL_ICMP, rx_fib_index0)))
174 b0->
error =
node->errors[DET44_IN2OUT_ERROR_NO_TRANSLATION];
187 IP_PROTOCOL_ICMP, rx_fib_index0)))
192 if (icmp0->type != ICMP4_echo_request)
194 b0->
error =
node->errors[DET44_IN2OUT_ERROR_BAD_ICMP_TYPE];
200 key0.
out_port = clib_host_to_net_u16 (lo_port0 +
217 b0->
error =
node->errors[DET44_IN2OUT_ERROR_OUT_OF_PORTS];
223 (
vnet_buffer (b0)->
ip.reass.icmp_type_or_tcp_flags != ICMP4_echo_request
225 reass.icmp_type_or_tcp_flags)))
227 b0->
error =
node->errors[DET44_IN2OUT_ERROR_BAD_ICMP_TYPE];
234 ses0->
state = DET44_SESSION_ICMP_ACTIVE;
253 #ifndef CLIB_MARCH_VARIANT
257 icmp46_header_t * icmp0,
264 u16 old_id0, new_id0,
port, checksum0, old_checksum0, new_checksum0;
265 u32 new_addr0, old_addr0, next0_tmp, fib_index;
267 icmp46_header_t *inner_icmp0;
278 d, e, &dont_translate);
310 if (icmp0->checksum == 0)
311 icmp0->checksum = 0xffff;
322 sum0 = icmp0->checksum;
344 sum0 = icmp0->checksum;
350 old_checksum0 = inner_ip0->
checksum;
355 new_checksum0 = inner_ip0->
checksum;
356 sum0 = icmp0->checksum;
364 case NAT_PROTOCOL_ICMP:
365 inner_icmp0 = (icmp46_header_t *) l4_header;
372 sum0 = icmp0->checksum;
378 case NAT_PROTOCOL_UDP:
379 case NAT_PROTOCOL_TCP:
384 sum0 = icmp0->checksum;
407 u32 pkts_processed = 0;
423 u32 sw_if_index0, sw_if_index1;
427 u16 old_port0, new_port0, lo_port0, i0;
428 u16 old_port1, new_port1, lo_port1, i1;
435 u32 rx_fib_index0, rx_fib_index1;
436 icmp46_header_t *icmp0, *icmp1;
471 ICMP4_time_exceeded_ttl_exceeded_in_transit,
483 icmp0 = (icmp46_header_t *) udp0;
487 rx_fib_index0,
node, next0,
498 b0->
error =
node->errors[DET44_IN2OUT_ERROR_NO_TRANSLATION];
513 key0.
out_port = clib_host_to_net_u16 (lo_port0 +
533 ICMP4_destination_unreachable,
534 ICMP4_destination_unreachable_destination_unreachable_host,
556 ses0->
state = DET44_SESSION_TCP_SYN_SENT;
558 && ses0->
state == DET44_SESSION_TCP_SYN_SENT)
559 ses0->
state = DET44_SESSION_TCP_ESTABLISHED;
561 && ses0->
state == DET44_SESSION_TCP_ESTABLISHED)
562 ses0->
state = DET44_SESSION_TCP_FIN_WAIT;
564 && ses0->
state == DET44_SESSION_TCP_FIN_WAIT)
567 && ses0->
state == DET44_SESSION_TCP_CLOSE_WAIT)
568 ses0->
state = DET44_SESSION_TCP_LAST_ACK;
569 else if (tcp0->flags == 0 && ses0->
state == DET44_SESSION_UNKNOWN)
570 ses0->
state = DET44_SESSION_TCP_ESTABLISHED;
572 sum0 = tcp0->checksum;
584 ses0->
state = DET44_SESSION_UDP_ACTIVE;
603 case DET44_SESSION_UDP_ACTIVE:
606 case DET44_SESSION_TCP_SYN_SENT:
607 case DET44_SESSION_TCP_FIN_WAIT:
608 case DET44_SESSION_TCP_CLOSE_WAIT:
609 case DET44_SESSION_TCP_LAST_ACK:
612 case DET44_SESSION_TCP_ESTABLISHED:
619 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
642 ICMP4_time_exceeded_ttl_exceeded_in_transit,
654 icmp1 = (icmp46_header_t *) udp1;
657 rx_fib_index1,
node, next1,
668 b1->
error =
node->errors[DET44_IN2OUT_ERROR_NO_TRANSLATION];
683 key1.
out_port = clib_host_to_net_u16 (lo_port1 +
703 ICMP4_destination_unreachable,
704 ICMP4_destination_unreachable_destination_unreachable_host,
712 udp1->
src_port = new_port1 = ses1->out.out_port;
726 ses1->state = DET44_SESSION_TCP_SYN_SENT;
728 && ses1->state == DET44_SESSION_TCP_SYN_SENT)
729 ses1->state = DET44_SESSION_TCP_ESTABLISHED;
731 && ses1->state == DET44_SESSION_TCP_ESTABLISHED)
732 ses1->state = DET44_SESSION_TCP_FIN_WAIT;
734 && ses1->state == DET44_SESSION_TCP_FIN_WAIT)
737 && ses1->state == DET44_SESSION_TCP_CLOSE_WAIT)
738 ses1->state = DET44_SESSION_TCP_LAST_ACK;
739 else if (tcp1->flags == 0 && ses1->state == DET44_SESSION_UNKNOWN)
740 ses1->state = DET44_SESSION_TCP_ESTABLISHED;
742 sum1 = tcp1->checksum;
754 ses1->state = DET44_SESSION_UDP_ACTIVE;
773 case DET44_SESSION_UDP_ACTIVE:
776 case DET44_SESSION_TCP_SYN_SENT:
777 case DET44_SESSION_TCP_FIN_WAIT:
778 case DET44_SESSION_TCP_CLOSE_WAIT:
779 case DET44_SESSION_TCP_LAST_ACK:
782 case DET44_SESSION_TCP_ESTABLISHED:
789 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
816 u16 old_port0, new_port0, lo_port0, i0;
824 icmp46_header_t *icmp0;
840 ICMP4_time_exceeded_ttl_exceeded_in_transit,
852 icmp0 = (icmp46_header_t *) udp0;
855 rx_fib_index0,
node, next0,
866 b0->
error =
node->errors[DET44_IN2OUT_ERROR_NO_TRANSLATION];
881 key0.
out_port = clib_host_to_net_u16 (lo_port0 +
901 ICMP4_destination_unreachable,
902 ICMP4_destination_unreachable_destination_unreachable_host,
924 ses0->
state = DET44_SESSION_TCP_SYN_SENT;
926 && ses0->
state == DET44_SESSION_TCP_SYN_SENT)
927 ses0->
state = DET44_SESSION_TCP_ESTABLISHED;
929 && ses0->
state == DET44_SESSION_TCP_ESTABLISHED)
930 ses0->
state = DET44_SESSION_TCP_FIN_WAIT;
932 && ses0->
state == DET44_SESSION_TCP_FIN_WAIT)
935 && ses0->
state == DET44_SESSION_TCP_CLOSE_WAIT)
936 ses0->
state = DET44_SESSION_TCP_LAST_ACK;
937 else if (tcp0->flags == 0 && ses0->
state == DET44_SESSION_UNKNOWN)
938 ses0->
state = DET44_SESSION_TCP_ESTABLISHED;
940 sum0 = tcp0->checksum;
952 ses0->
state = DET44_SESSION_UDP_ACTIVE;
971 case DET44_SESSION_UDP_ACTIVE:
974 case DET44_SESSION_TCP_SYN_SENT:
975 case DET44_SESSION_TCP_FIN_WAIT:
976 case DET44_SESSION_TCP_CLOSE_WAIT:
977 case DET44_SESSION_TCP_LAST_ACK:
980 case DET44_SESSION_TCP_ESTABLISHED:
987 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
1009 DET44_IN2OUT_ERROR_IN2OUT_PACKETS,
1011 return frame->n_vectors;
1016 .name =
"det44-in2out",
1017 .vector_size =
sizeof (
u32),