X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fout2in.c;fp=src%2Fplugins%2Fsnat%2Fout2in.c;h=679500668c526db87eabc3c38e35fc0cead6ee4c;hb=2ba92e32e0197f676dd905e5edcb4ff3e1bec241;hp=329d67dc3bff97b2b2560b45736f1c516df40e5c;hpb=cfc997ef3da9f406afe5caad99fc98a53aab7a77;p=vpp.git diff --git a/src/plugins/snat/out2in.c b/src/plugins/nat/out2in.c similarity index 97% rename from src/plugins/snat/out2in.c rename to src/plugins/nat/out2in.c index 329d67dc3bf..679500668c5 100644 --- a/src/plugins/snat/out2in.c +++ b/src/plugins/nat/out2in.c @@ -22,9 +22,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -47,8 +47,8 @@ static u8 * format_snat_out2in_trace (u8 * s, va_list * args) CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); snat_out2in_trace_t * t = va_arg (*args, snat_out2in_trace_t *); - - s = format (s, "SNAT_OUT2IN: sw_if_index %d, next index %d, session index %d", + + s = format (s, "NAT44_OUT2IN: sw_if_index %d, next index %d, session index %d", t->sw_if_index, t->next_index, t->session_index); return s; } @@ -58,8 +58,8 @@ static u8 * format_snat_out2in_fast_trace (u8 * s, va_list * args) CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); snat_out2in_trace_t * t = va_arg (*args, snat_out2in_trace_t *); - - s = format (s, "SNAT_OUT2IN_FAST: sw_if_index %d, next index %d", + + s = format (s, "NAT44_OUT2IN_FAST: sw_if_index %d, next index %d", t->sw_if_index, t->next_index); return s; } @@ -73,7 +73,7 @@ static u8 * format_snat_out2in_worker_handoff_trace (u8 * s, va_list * args) char * m; m = t->do_handoff ? "next worker" : "same worker"; - s = format (s, "SNAT_OUT2IN_WORKER_HANDOFF: %s %d", m, t->next_worker_index); + s = format (s, "NAT44_OUT2IN_WORKER_HANDOFF: %s %d", m, t->next_worker_index); return s; } @@ -88,7 +88,7 @@ _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ _(OUT2IN_PACKETS, "Good out2in packets processed") \ _(BAD_ICMP_TYPE, "unsupported ICMP type") \ _(NO_TRANSLATION, "No translation") - + typedef enum { #define _(sym,str) SNAT_OUT2IN_ERROR_##sym, foreach_snat_out2in_error @@ -115,10 +115,10 @@ typedef enum { * Create NAT session initiated by host from external network with static * mapping. * - * @param sm SNAT main. + * @param sm NAT main. * @param b0 Vlib buffer. - * @param in2out In2out SNAT session key. - * @param out2in Out2in SNAT session key. + * @param in2out In2out NAT44 session key. + * @param out2in Out2in NAT44 session key. * @param node Vlib node. * * @returns SNAT session if successfully created otherwise 0. @@ -276,11 +276,11 @@ snat_out2in_error_t icmp_get_key(ip4_header_t *ip0, } /** - * Get address and port values to be used for packet SNAT translation + * Get address and port values to be used for ICMP packet translation * and create session if needed * - * @param[in,out] sm SNAT main - * @param[in,out] node SNAT node runtime + * @param[in,out] sm NAT main + * @param[in,out] node NAT node runtime * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_proto protocol used for matching @@ -387,10 +387,10 @@ out: } /** - * Get address and port values to be used for packet SNAT translation + * Get address and port values to be used for ICMP packet translation * - * @param[in] sm SNAT main - * @param[in,out] node SNAT node runtime + * @param[in] sm NAT main + * @param[in,out] node NAT node runtime * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_proto protocol used for matching @@ -793,14 +793,14 @@ snat_out2in_node_fn (vlib_main_t * vm, u32 proto0, proto1; snat_session_t * s0 = 0, * s1 = 0; clib_bihash_kv_8_8_t kv0, kv1, value0, value1; - + /* Prefetch next iteration. */ { vlib_buffer_t * p2, * p3; - + p2 = vlib_get_buffer (vm, from[2]); p3 = vlib_get_buffer (vm, from[3]); - + vlib_prefetch_buffer_header (p2, LOAD); vlib_prefetch_buffer_header (p3, LOAD); @@ -828,7 +828,7 @@ snat_out2in_node_fn (vlib_main_t * vm, icmp0 = (icmp46_header_t *) udp0; sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; - rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index0); if (PREDICT_FALSE(ip0->ttl == 1)) @@ -852,8 +852,8 @@ snat_out2in_node_fn (vlib_main_t * vm, if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) { - next0 = icmp_out2in_slow_path - (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, + next0 = icmp_out2in_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, next0, now, thread_index, &s0); goto trace0; } @@ -862,7 +862,7 @@ snat_out2in_node_fn (vlib_main_t * vm, key0.port = udp0->dst_port; key0.protocol = proto0; key0.fib_index = rx_fib_index0; - + kv0.key = key0.as_u64; if (clib_bihash_search_8_8 (&sm->out2in, &kv0, &value0)) @@ -872,12 +872,12 @@ snat_out2in_node_fn (vlib_main_t * vm, if (snat_static_mapping_match(sm, key0, &sm0, 1, 0)) { b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; - /* + /* * Send DHCP packets to the ipv4 stack, or we won't * be able to use dhcp client on the outside interface */ - if (proto0 != SNAT_PROTOCOL_UDP - || (udp0->dst_port + if (proto0 != SNAT_PROTOCOL_UDP + || (udp0->dst_port != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client))) next0 = SNAT_OUT2IN_NEXT_DROP; goto trace0; @@ -946,10 +946,10 @@ snat_out2in_node_fn (vlib_main_t * vm, } trace0: - if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) - && (b0->flags & VLIB_BUFFER_IS_TRACED))) + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) { - snat_out2in_trace_t *t = + snat_out2in_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); t->sw_if_index = sw_if_index0; t->next_index = next0; @@ -967,7 +967,7 @@ snat_out2in_node_fn (vlib_main_t * vm, icmp1 = (icmp46_header_t *) udp1; sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX]; - rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index1); if (PREDICT_FALSE(ip1->ttl == 1)) @@ -991,8 +991,8 @@ snat_out2in_node_fn (vlib_main_t * vm, if (PREDICT_FALSE (proto1 == SNAT_PROTOCOL_ICMP)) { - next1 = icmp_out2in_slow_path - (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, + next1 = icmp_out2in_slow_path + (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, next1, now, thread_index, &s1); goto trace1; } @@ -1001,7 +1001,7 @@ snat_out2in_node_fn (vlib_main_t * vm, key1.port = udp1->dst_port; key1.protocol = proto1; key1.fib_index = rx_fib_index1; - + kv1.key = key1.as_u64; if (clib_bihash_search_8_8 (&sm->out2in, &kv1, &value1)) @@ -1011,12 +1011,12 @@ snat_out2in_node_fn (vlib_main_t * vm, if (snat_static_mapping_match(sm, key1, &sm1, 1, 0)) { b1->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; - /* + /* * Send DHCP packets to the ipv4 stack, or we won't * be able to use dhcp client on the outside interface */ - if (proto1 != SNAT_PROTOCOL_UDP - || (udp1->dst_port + if (proto1 != SNAT_PROTOCOL_UDP + || (udp1->dst_port != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client))) next1 = SNAT_OUT2IN_NEXT_DROP; goto trace1; @@ -1085,10 +1085,10 @@ snat_out2in_node_fn (vlib_main_t * vm, } trace1: - if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) - && (b1->flags & VLIB_BUFFER_IS_TRACED))) + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b1->flags & VLIB_BUFFER_IS_TRACED))) { - snat_out2in_trace_t *t = + snat_out2in_trace_t *t = vlib_add_trace (vm, node, b1, sizeof (*t)); t->sw_if_index = sw_if_index1; t->next_index = next1; @@ -1123,7 +1123,7 @@ snat_out2in_node_fn (vlib_main_t * vm, u32 proto0; snat_session_t * s0 = 0; clib_bihash_kv_8_8_t kv0, value0; - + /* speculatively enqueue b0 to the current next frame */ bi0 = from[0]; to_next[0] = bi0; @@ -1142,7 +1142,7 @@ snat_out2in_node_fn (vlib_main_t * vm, icmp0 = (icmp46_header_t *) udp0; sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; - rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index0); proto0 = ip_proto_to_snat_proto (ip0->protocol); @@ -1166,8 +1166,8 @@ snat_out2in_node_fn (vlib_main_t * vm, if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) { - next0 = icmp_out2in_slow_path - (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, + next0 = icmp_out2in_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, next0, now, thread_index, &s0); goto trace00; } @@ -1176,7 +1176,7 @@ snat_out2in_node_fn (vlib_main_t * vm, key0.port = udp0->dst_port; key0.protocol = proto0; key0.fib_index = rx_fib_index0; - + kv0.key = key0.as_u64; if (clib_bihash_search_8_8 (&sm->out2in, &kv0, &value0)) @@ -1186,12 +1186,12 @@ snat_out2in_node_fn (vlib_main_t * vm, if (snat_static_mapping_match(sm, key0, &sm0, 1, 0)) { b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; - /* + /* * Send DHCP packets to the ipv4 stack, or we won't * be able to use dhcp client on the outside interface */ - if (proto0 != SNAT_PROTOCOL_UDP - || (udp0->dst_port + if (proto0 != SNAT_PROTOCOL_UDP + || (udp0->dst_port != clib_host_to_net_u16(UDP_DST_PORT_dhcp_to_client))) next0 = SNAT_OUT2IN_NEXT_DROP; @@ -1261,10 +1261,10 @@ snat_out2in_node_fn (vlib_main_t * vm, } trace00: - if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) - && (b0->flags & VLIB_BUFFER_IS_TRACED))) + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) { - snat_out2in_trace_t *t = + snat_out2in_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t)); t->sw_if_index = sw_if_index0; t->next_index = next0; @@ -1284,24 +1284,24 @@ snat_out2in_node_fn (vlib_main_t * vm, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } - vlib_node_increment_counter (vm, snat_out2in_node.index, - SNAT_OUT2IN_ERROR_OUT2IN_PACKETS, + vlib_node_increment_counter (vm, snat_out2in_node.index, + SNAT_OUT2IN_ERROR_OUT2IN_PACKETS, pkts_processed); return frame->n_vectors; } VLIB_REGISTER_NODE (snat_out2in_node) = { .function = snat_out2in_node_fn, - .name = "snat-out2in", + .name = "nat44-out2in", .vector_size = sizeof (u32), .format_trace = format_snat_out2in_trace, .type = VLIB_NODE_TYPE_INTERNAL, - + .n_errors = ARRAY_LEN(snat_out2in_error_strings), .error_strings = snat_out2in_error_strings, .runtime_data_bytes = sizeof (snat_runtime_t), - + .n_next_nodes = SNAT_OUT2IN_N_NEXT, /* edit / add dispositions here */ @@ -1779,7 +1779,7 @@ snat_det_out2in_node_fn (vlib_main_t * vm, VLIB_REGISTER_NODE (snat_det_out2in_node) = { .function = snat_det_out2in_node_fn, - .name = "snat-det-out2in", + .name = "nat44-det-out2in", .vector_size = sizeof (u32), .format_trace = format_snat_out2in_trace, .type = VLIB_NODE_TYPE_INTERNAL, @@ -1801,11 +1801,11 @@ VLIB_REGISTER_NODE (snat_det_out2in_node) = { VLIB_NODE_FUNCTION_MULTIARCH (snat_det_out2in_node, snat_det_out2in_node_fn); /** - * Get address and port values to be used for packet SNAT translation + * Get address and port values to be used for ICMP packet translation * and create session if needed * - * @param[in,out] sm SNAT main - * @param[in,out] node SNAT node runtime + * @param[in,out] sm NAT main + * @param[in,out] node NAT node runtime * @param[in] thread_index thread index * @param[in,out] b0 buffer containing packet to be translated * @param[out] p_proto protocol used for matching @@ -2089,11 +2089,11 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm, VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node) = { .function = snat_out2in_worker_handoff_fn, - .name = "snat-out2in-worker-handoff", + .name = "nat44-out2in-worker-handoff", .vector_size = sizeof (u32), .format_trace = format_snat_out2in_worker_handoff_trace, .type = VLIB_NODE_TYPE_INTERNAL, - + .n_next_nodes = 1, .next_nodes = { @@ -2105,7 +2105,7 @@ VLIB_NODE_FUNCTION_MULTIARCH (snat_out2in_worker_handoff_node, snat_out2in_worke static uword snat_out2in_fast_node_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, + vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 n_left_from, * from, * to_next; @@ -2272,16 +2272,16 @@ snat_out2in_fast_node_fn (vlib_main_t * vm, VLIB_REGISTER_NODE (snat_out2in_fast_node) = { .function = snat_out2in_fast_node_fn, - .name = "snat-out2in-fast", + .name = "nat44-out2in-fast", .vector_size = sizeof (u32), .format_trace = format_snat_out2in_fast_trace, .type = VLIB_NODE_TYPE_INTERNAL, - + .n_errors = ARRAY_LEN(snat_out2in_error_strings), .error_strings = snat_out2in_error_strings, .runtime_data_bytes = sizeof (snat_runtime_t), - + .n_next_nodes = SNAT_OUT2IN_N_NEXT, /* edit / add dispositions here */