X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat44-ed%2Fnat44_ed_out2in.c;h=cb21b0f62c5bc42677b689d79acb95bedf1e15d1;hb=f059a3452;hp=454555769940f58b8dde7ca2864f8725008d78e3;hpb=1ca6c65e5109b220d25dace08ae758c31e5ea5a2;p=vpp.git diff --git a/src/plugins/nat/nat44-ed/nat44_ed_out2in.c b/src/plugins/nat/nat44-ed/nat44_ed_out2in.c index 45455576994..cb21b0f62c5 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_out2in.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_out2in.c @@ -123,7 +123,7 @@ format_nat44_ed_out2in_trace (u8 * s, va_list * args) static int next_src_nat (snat_main_t *sm, ip4_header_t *ip, u16 src_port, u16 dst_port, - u32 thread_index, u32 rx_fib_index) + u32 rx_fib_index) { clib_bihash_kv_16_8_t kv, value; @@ -198,8 +198,7 @@ icmp_out2in_ed_slow_path (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, } else { - if (next_src_nat (sm, ip, lookup_sport, lookup_dport, thread_index, - rx_fib_index)) + if (next_src_nat (sm, ip, lookup_sport, lookup_dport, rx_fib_index)) { next = NAT_NEXT_IN2OUT_ED_FAST_PATH; } @@ -432,7 +431,6 @@ create_session_for_static_mapping_ed ( s->flags |= SNAT_SESSION_FLAG_LOAD_BALANCING; if (lb_nat == AFFINITY_LB_NAT) s->flags |= SNAT_SESSION_FLAG_AFFINITY; - s->flags |= SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT; s->out2in.addr = o2i_addr; s->out2in.port = o2i_port; s->out2in.fib_index = o2i_fib_index; @@ -472,7 +470,7 @@ create_session_for_static_mapping_ed ( snat_address_t *filter = 0; // if exact address is specified use this address - if (is_exact_address (mapping)) + if (is_sm_exact_address (mapping->flags)) { snat_address_t *ap; vec_foreach (ap, sm->twice_nat_addresses) @@ -593,7 +591,7 @@ create_session_for_static_mapping_ed ( s->in2out.port, &s->ext_host_nat_addr, s->ext_host_nat_port, &s->out2in.addr, s->out2in.port, &s->ext_host_addr, s->ext_host_port, s->nat_proto, - is_twice_nat_session (s)); + nat44_ed_is_twice_nat_session (s)); per_vrf_sessions_register_session (s, thread_index); @@ -754,7 +752,6 @@ nat44_ed_out2in_slowpath_unknown_proto (snat_main_t *sm, vlib_buffer_t *b, s->ext_host_addr.as_u32 = ip->src_address.as_u32; s->flags |= SNAT_SESSION_FLAG_UNKNOWN_PROTO; s->flags |= SNAT_SESSION_FLAG_STATIC_MAPPING; - s->flags |= SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT; s->out2in.addr.as_u32 = ip->dst_address.as_u32; s->out2in.fib_index = rx_fib_index; s->in2out.addr.as_u32 = m->local_addr.as_u32; @@ -838,7 +835,7 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, vlib_prefetch_buffer_header (p2, LOAD); - CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, LOAD); + clib_prefetch_load (p2->data); } next[0] = vnet_buffer2 (b0)->nat.arc_next; @@ -933,6 +930,8 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, ed_value_get_session_index (&value0)); skip_lookup: + ASSERT (thread_index == s0->thread_index); + if (PREDICT_FALSE (per_vrf_sessions_is_expired (s0, thread_index))) { // session is closed, go slow path @@ -1018,16 +1017,18 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, nat_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); next[0] = NAT_NEXT_DROP; + b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED]; goto trace0; } } } if (NAT_ED_TRNSL_ERR_SUCCESS != - (translation_error = nat_6t_flow_buf_translate ( - sm, b0, ip0, f, proto0, 0 /* is_output_feature */))) + (translation_error = nat_6t_flow_buf_translate_o2i ( + vm, sm, b0, ip0, f, proto0, 0 /* is_output_feature */))) { next[0] = NAT_NEXT_DROP; + b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED]; goto trace0; } @@ -1178,11 +1179,14 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm, if (!s0) next[0] = NAT_NEXT_DROP; } - if (NAT_NEXT_DROP != next[0] && + if (NAT_NEXT_DROP != next[0] && s0 && NAT_ED_TRNSL_ERR_SUCCESS != - (translation_error = nat_6t_flow_buf_translate ( - sm, b0, ip0, &s0->o2i, proto0, 0 /* is_output_feature */))) + (translation_error = nat_6t_flow_buf_translate_o2i ( + vm, sm, b0, ip0, &s0->o2i, proto0, + 0 /* is_output_feature */))) { + next[0] = NAT_NEXT_DROP; + b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED]; goto trace0; } @@ -1199,9 +1203,12 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm, if (NAT_NEXT_DROP != next[0] && s0 && NAT_ED_TRNSL_ERR_SUCCESS != - (translation_error = nat_6t_flow_buf_translate ( - sm, b0, ip0, &s0->o2i, proto0, 0 /* is_output_feature */))) + (translation_error = nat_6t_flow_buf_translate_o2i ( + vm, sm, b0, ip0, &s0->o2i, proto0, + 0 /* is_output_feature */))) { + next[0] = NAT_NEXT_DROP; + b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED]; goto trace0; } @@ -1262,10 +1269,9 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm, } else { - if (next_src_nat - (sm, ip0, vnet_buffer (b0)->ip.reass.l4_src_port, - vnet_buffer (b0)->ip.reass.l4_dst_port, - thread_index, rx_fib_index0)) + if (next_src_nat ( + sm, ip0, vnet_buffer (b0)->ip.reass.l4_src_port, + vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0)) { next[0] = NAT_NEXT_IN2OUT_ED_FAST_PATH; } @@ -1309,8 +1315,8 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm, } if (NAT_ED_TRNSL_ERR_SUCCESS != - (translation_error = nat_6t_flow_buf_translate ( - sm, b0, ip0, &s0->o2i, proto0, 0 /* is_output_feature */))) + (translation_error = nat_6t_flow_buf_translate_o2i ( + vm, sm, b0, ip0, &s0->o2i, proto0, 0 /* is_output_feature */))) { next[0] = NAT_NEXT_DROP; goto trace0; @@ -1397,7 +1403,6 @@ VLIB_NODE_FN (nat44_ed_out2in_node) (vlib_main_t * vm, } } -/* *INDENT-OFF* */ VLIB_REGISTER_NODE (nat44_ed_out2in_node) = { .name = "nat44-ed-out2in", .vector_size = sizeof (u32), @@ -1408,7 +1413,6 @@ VLIB_REGISTER_NODE (nat44_ed_out2in_node) = { .error_strings = nat_out2in_ed_error_strings, .runtime_data_bytes = sizeof (snat_runtime_t), }; -/* *INDENT-ON* */ VLIB_NODE_FN (nat44_ed_out2in_slowpath_node) (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -1417,7 +1421,6 @@ VLIB_NODE_FN (nat44_ed_out2in_slowpath_node) (vlib_main_t * vm, return nat44_ed_out2in_slow_path_node_fn_inline (vm, node, frame); } -/* *INDENT-OFF* */ VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node) = { .name = "nat44-ed-out2in-slowpath", .vector_size = sizeof (u32), @@ -1428,7 +1431,6 @@ VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node) = { .error_strings = nat_out2in_ed_error_strings, .runtime_data_bytes = sizeof (snat_runtime_t), }; -/* *INDENT-ON* */ static u8 * format_nat_pre_trace (u8 * s, va_list * args) @@ -1448,7 +1450,6 @@ VLIB_NODE_FN (nat_pre_out2in_node) (vlib_main_t * vm, NAT_NEXT_OUT2IN_ED_FAST_PATH); } -/* *INDENT-OFF* */ VLIB_REGISTER_NODE (nat_pre_out2in_node) = { .name = "nat-pre-out2in", .vector_size = sizeof (u32), @@ -1457,7 +1458,6 @@ VLIB_REGISTER_NODE (nat_pre_out2in_node) = { .type = VLIB_NODE_TYPE_INTERNAL, .n_errors = 0, }; -/* *INDENT-ON* */ /* * fd.io coding-style-patch-verification: ON