diff options
Diffstat (limited to 'plugins/snat-plugin/snat')
-rw-r--r-- | plugins/snat-plugin/snat/out2in.c | 27 | ||||
-rw-r--r-- | plugins/snat-plugin/snat/snat.c | 50 | ||||
-rw-r--r-- | plugins/snat-plugin/snat/snat.h | 6 |
3 files changed, 25 insertions, 58 deletions
diff --git a/plugins/snat-plugin/snat/out2in.c b/plugins/snat-plugin/snat/out2in.c index 190350ad..35edcc5f 100644 --- a/plugins/snat-plugin/snat/out2in.c +++ b/plugins/snat-plugin/snat/out2in.c @@ -284,8 +284,6 @@ snat_out2in_node_fn (vlib_main_t * vm, snat_out2in_next_t next_index; u32 pkts_processed = 0; snat_main_t * sm = &snat_main; - ip_lookup_main_t * lm = sm->ip4_lookup_main; - vnet_feature_config_main_t * cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT]; f64 now = vlib_time_now (vm); from = vlib_frame_vector_args (frame); @@ -355,10 +353,7 @@ snat_out2in_node_fn (vlib_main_t * vm, rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index0); - vnet_get_config_data (&cm->config_main, - &b0->current_config_index, - &next0, - 0 /* sizeof config data */); + vnet_feature_next (sw_if_index0, &next0, b0); proto0 = ~0; proto0 = (ip0->protocol == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : proto0; @@ -474,10 +469,8 @@ snat_out2in_node_fn (vlib_main_t * vm, rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index1); - vnet_get_config_data (&cm->config_main, - &b1->current_config_index, - &next1, - 0 /* sizeof config data */); + vnet_feature_next (sw_if_index1, &next1, b1); + proto1 = ~0; proto1 = (ip1->protocol == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : proto1; @@ -628,10 +621,8 @@ snat_out2in_node_fn (vlib_main_t * vm, rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, sw_if_index0); - vnet_get_config_data (&cm->config_main, - &b0->current_config_index, - &next0, - 0 /* sizeof config data */); + vnet_feature_next (sw_if_index0, &next0, b0); + proto0 = ~0; proto0 = (ip0->protocol == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : proto0; @@ -853,8 +844,6 @@ snat_out2in_fast_node_fn (vlib_main_t * vm, snat_out2in_next_t next_index; u32 pkts_processed = 0; snat_main_t * sm = &snat_main; - ip_lookup_main_t * lm = sm->ip4_lookup_main; - vnet_feature_config_main_t * cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT]; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -902,10 +891,8 @@ snat_out2in_fast_node_fn (vlib_main_t * vm, sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; rx_fib_index0 = ip4_fib_table_get_index_for_sw_if_index(sw_if_index0); - vnet_get_config_data (&cm->config_main, - &b0->current_config_index, - &next0, - 0 /* sizeof config data */); + vnet_feature_next (sw_if_index0, &next0, b0); + proto0 = ~0; proto0 = (ip0->protocol == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : proto0; diff --git a/plugins/snat-plugin/snat/snat.c b/plugins/snat-plugin/snat/snat.c index 0b972110..66c03817 100644 --- a/plugins/snat-plugin/snat/snat.c +++ b/plugins/snat-plugin/snat/snat.c @@ -93,25 +93,25 @@ do { \ /* Hook up input features */ -VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_in2out, static) = { +VNET_FEATURE_INIT (ip4_snat_in2out, static) = { + .arc_name = "ip4-unicast", .node_name = "snat-in2out", - .runs_before = (char *[]){"snat-out2in", 0}, - .feature_index = &snat_main.rx_feature_in2out, + .runs_before = VNET_FEATURES ("snat-out2in"), }; -VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_out2in, static) = { +VNET_FEATURE_INIT (ip4_snat_out2in, static) = { + .arc_name = "ip4-unicast", .node_name = "snat-out2in", - .runs_before = (char *[]){"ip4-lookup", 0}, - .feature_index = &snat_main.rx_feature_out2in, + .runs_before = VNET_FEATURES ("ip4-lookup"), }; -VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_in2out_fast, static) = { +VNET_FEATURE_INIT (ip4_snat_in2out_fast, static) = { + .arc_name = "ip4-unicast", .node_name = "snat-in2out-fast", - .runs_before = (char *[]){"snat-out2in-fast", 0}, - .feature_index = &snat_main.rx_feature_in2out_fast, + .runs_before = VNET_FEATURES ("snat-out2in-fast"), }; -VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_out2in_fast, static) = { +VNET_FEATURE_INIT (ip4_snat_out2in_fast, static) = { + .arc_name = "ip4-unicast", .node_name = "snat-out2in-fast", - .runs_before = (char *[]){"ip4-lookup", 0}, - .feature_index = &snat_main.rx_feature_out2in_fast, + .runs_before = VNET_FEATURES ("ip4-lookup"), }; @@ -540,29 +540,15 @@ static int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del) { snat_main_t *sm = &snat_main; snat_interface_t *i; - u32 ci; - ip4_main_t * im = &ip4_main; - ip_lookup_main_t * lm = &im->lookup_main; - vnet_feature_config_main_t * rx_cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT]; - u32 feature_index; + const char * feature_name; if (sm->static_mapping_only && !(sm->static_mapping_connection_tracking)) - feature_index = is_inside ? sm->rx_feature_in2out_fast - : sm->rx_feature_out2in_fast; + feature_name = is_inside ? "snat-in2out-fast" : "snat-out2in-fast"; else - feature_index = is_inside ? sm->rx_feature_in2out - : sm->rx_feature_out2in; - - ci = rx_cm->config_index_by_sw_if_index[sw_if_index]; - ci = (is_del - ? vnet_config_del_feature - : vnet_config_add_feature) - (sm->vlib_main, &rx_cm->config_main, - ci, - feature_index, - 0 /* config struct */, - 0 /* sizeof config struct*/); - rx_cm->config_index_by_sw_if_index[sw_if_index] = ci; + feature_name = is_inside ? "snat-in2out" : "snat-out2in"; + + vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index, + !is_del, 0, 0); pool_foreach (i, sm->interfaces, ({ diff --git a/plugins/snat-plugin/snat/snat.h b/plugins/snat-plugin/snat/snat.h index 1469f60e..ca10b76a 100644 --- a/plugins/snat-plugin/snat/snat.h +++ b/plugins/snat-plugin/snat/snat.h @@ -166,12 +166,6 @@ typedef struct { /* Randomize port allocation order */ u32 random_seed; - /* ip4 feature path indices */ - u32 rx_feature_in2out; - u32 rx_feature_out2in; - u32 rx_feature_in2out_fast; - u32 rx_feature_out2in_fast; - /* Config parameters */ u8 static_mapping_only; u8 static_mapping_connection_tracking; |