From 070387d3f4b0b5a5742b95fca19404cb50fa9927 Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Tue, 2 Feb 2021 20:15:59 +0100 Subject: nat: improve type safety and remove unused param Type: improvement Change-Id: I456f9b14e6a4eb46c9c49f6e09acccae530e4ebc Signed-off-by: Klement Sekera --- src/plugins/nat/nat44-ei/nat44_ei_out2in.c | 55 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'src/plugins/nat/nat44-ei/nat44_ei_out2in.c') diff --git a/src/plugins/nat/nat44-ei/nat44_ei_out2in.c b/src/plugins/nat/nat44-ei/nat44_ei_out2in.c index f0b6427613a..ca3c272a26c 100644 --- a/src/plugins/nat/nat44-ei/nat44_ei_out2in.c +++ b/src/plugins/nat/nat44-ei/nat44_ei_out2in.c @@ -315,12 +315,11 @@ icmp_get_key (vlib_buffer_t * b, ip4_header_t * ip0, * @param e optional parameter */ u32 -icmp_match_out2in_slow (snat_main_t * sm, vlib_node_runtime_t * node, - u32 thread_index, vlib_buffer_t * b0, - ip4_header_t * ip0, ip4_address_t * addr, - u16 * port, u32 * fib_index, - nat_protocol_t * proto, void *d, void *e, - u8 * dont_translate) +icmp_match_out2in_slow (snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, + ip4_address_t *addr, u16 *port, u32 *fib_index, + nat_protocol_t *proto, snat_session_t **p_s0, + u8 *dont_translate) { snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index]; u32 sw_if_index0; @@ -434,8 +433,8 @@ out: *port = s0->in2out.port; *fib_index = s0->in2out.fib_index; } - if (d) - *(snat_session_t **) d = s0; + if (p_s0) + *p_s0 = s0; return next0; } #endif @@ -456,12 +455,11 @@ out: * @param e optional parameter */ u32 -icmp_match_out2in_fast (snat_main_t * sm, vlib_node_runtime_t * node, - u32 thread_index, vlib_buffer_t * b0, - ip4_header_t * ip0, ip4_address_t * mapping_addr, - u16 * mapping_port, u32 * mapping_fib_index, - nat_protocol_t * proto, void *d, void *e, - u8 * dont_translate) +icmp_match_out2in_fast (snat_main_t *sm, vlib_node_runtime_t *node, + u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, + ip4_address_t *mapping_addr, u16 *mapping_port, + u32 *mapping_fib_index, nat_protocol_t *proto, + snat_session_t **p_s0, u8 *dont_translate) { u32 sw_if_index0; u32 rx_fib_index0; @@ -514,16 +512,17 @@ out: } #endif +u32 icmp_out2in (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, + icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, + vlib_node_runtime_t *node, u32 next0, u32 thread_index, + snat_session_t **p_s0); + #ifndef CLIB_MARCH_VARIANT u32 -icmp_out2in (snat_main_t * sm, - vlib_buffer_t * b0, - ip4_header_t * ip0, - icmp46_header_t * icmp0, - u32 sw_if_index0, - u32 rx_fib_index0, - vlib_node_runtime_t * node, - u32 next0, u32 thread_index, void *d, void *e) +icmp_out2in (snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, + icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, + vlib_node_runtime_t *node, u32 next0, u32 thread_index, + snat_session_t **p_s0) { icmp_echo_header_t *echo0, *inner_echo0 = 0; ip4_header_t *inner_ip0 = 0; @@ -543,9 +542,9 @@ icmp_out2in (snat_main_t * sm, echo0 = (icmp_echo_header_t *) (icmp0 + 1); - next0_tmp = sm->icmp_match_out2in_cb (sm, node, thread_index, b0, ip0, - &addr, &port, &fib_index, &proto, - d, e, &dont_translate); + next0_tmp = + sm->icmp_match_out2in_cb (sm, node, thread_index, b0, ip0, &addr, &port, + &fib_index, &proto, p_s0, &dont_translate); if (next0_tmp != ~0) next0 = next0_tmp; if (next0 == SNAT_OUT2IN_NEXT_DROP || dont_translate) @@ -670,7 +669,7 @@ icmp_out2in_slow_path (snat_main_t * sm, vlib_main_t *vm = vlib_get_main (); next0 = icmp_out2in (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, - next0, thread_index, p_s0, 0); + next0, thread_index, p_s0); snat_session_t *s0 = *p_s0; if (PREDICT_TRUE (next0 != SNAT_OUT2IN_NEXT_DROP && s0)) { @@ -1442,8 +1441,8 @@ VLIB_NODE_FN (snat_out2in_fast_node) (vlib_main_t * vm, if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_ICMP)) { - next0 = icmp_out2in (sm, b0, ip0, icmp0, sw_if_index0, - rx_fib_index0, node, next0, ~0, 0, 0); + next0 = icmp_out2in (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, + node, next0, ~0, 0); goto trace00; } -- cgit 1.2.3-korg