From 6f98d9900d1c35292be94307724c6c897c24dfe2 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Tue, 29 Jun 2021 12:58:34 +0200 Subject: [PATCH] nat: remove unusued parameters and use correct parameter types Type: improvement Signed-off-by: Klement Sekera Change-Id: I4f7b3d5354a7658d7271c28444f2f4641f05b28b --- src/plugins/nat/nat44-ed/nat44_ed_in2out.c | 23 ++++++++++------------- src/plugins/nat/nat44-ed/nat44_ed_out2in.c | 12 +++++------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/plugins/nat/nat44-ed/nat44_ed_in2out.c b/src/plugins/nat/nat44-ed/nat44_ed_in2out.c index 53b1eaecc05..0e330e17b36 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_in2out.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_in2out.c @@ -106,14 +106,13 @@ format_nat_in2out_ed_trace (u8 * s, va_list * args) * @param rt NAT runtime data * @param sw_if_index0 index of the inside interface * @param ip0 IPv4 header - * @param proto0 NAT protocol * @param rx_fib_index0 RX FIB index * * @returns 0 if packet should be translated otherwise 1 */ static inline int snat_not_translate_fast (snat_main_t *sm, vlib_node_runtime_t *node, - u32 sw_if_index0, ip4_header_t *ip0, u32 proto0, + u32 sw_if_index0, ip4_header_t *ip0, u32 rx_fib_index0) { fib_node_index_t fei = FIB_NODE_INDEX_INVALID; @@ -233,7 +232,7 @@ nat_ed_alloc_addr_and_port (snat_main_t *sm, u32 rx_fib_index, u32 nat_proto, if (vec_len (sm->addresses) > 0) { - int s_addr_offset = s_addr.as_u32 % vec_len (sm->addresses); + u32 s_addr_offset = s_addr.as_u32 % vec_len (sm->addresses); for (i = s_addr_offset; i < vec_len (sm->addresses); ++i) { @@ -557,7 +556,7 @@ static_always_inline int nat44_ed_not_translate (vlib_main_t *vm, snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index, vlib_buffer_t *b, ip4_header_t *ip, u32 proto, - u32 rx_fib_index, u32 thread_index) + u32 rx_fib_index) { clib_bihash_kv_16_8_t kv, value; @@ -584,8 +583,7 @@ nat44_ed_not_translate (vlib_main_t *vm, snat_main_t *sm, if (sm->forwarding_enabled) return 1; - return snat_not_translate_fast (sm, node, sw_if_index, ip, proto, - rx_fib_index); + return snat_not_translate_fast (sm, node, sw_if_index, ip, rx_fib_index); } static_always_inline int @@ -736,8 +734,7 @@ icmp_in2out_ed_slow_path (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, icmp46_header_t *icmp, u32 sw_if_index, u32 rx_fib_index, vlib_node_runtime_t *node, u32 next, f64 now, u32 thread_index, - nat_protocol_t nat_proto, snat_session_t **s_p, - int is_multi_worker) + snat_session_t **s_p, int is_multi_worker) { vlib_main_t *vm = vlib_get_main (); u16 checksum; @@ -769,7 +766,7 @@ icmp_in2out_ed_slow_path (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, { if (PREDICT_FALSE (nat44_ed_not_translate (vm, sm, node, sw_if_index, b, ip, NAT_PROTOCOL_ICMP, - rx_fib_index, thread_index))) + rx_fib_index))) { return next; } @@ -1359,7 +1356,7 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, { next[0] = icmp_in2out_ed_slow_path ( sm, b0, ip0, icmp0, rx_sw_if_index0, rx_fib_index0, node, next[0], - now, thread_index, proto0, &s0, is_multi_worker); + now, thread_index, &s0, is_multi_worker); if (NAT_NEXT_DROP != next[0] && s0 && NAT_ED_TRNSL_ERR_SUCCESS != (translation_error = nat_6t_flow_buf_translate_i2o ( @@ -1419,9 +1416,9 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, } else { - if (PREDICT_FALSE (nat44_ed_not_translate ( - vm, sm, node, rx_sw_if_index0, b0, ip0, proto0, - rx_fib_index0, thread_index))) + if (PREDICT_FALSE ( + nat44_ed_not_translate (vm, sm, node, rx_sw_if_index0, b0, + ip0, proto0, rx_fib_index0))) goto trace0; } diff --git a/src/plugins/nat/nat44-ed/nat44_ed_out2in.c b/src/plugins/nat/nat44-ed/nat44_ed_out2in.c index 5e6db63b2bf..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; } @@ -1270,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; } -- 2.16.6