summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-09 19:54:20 +0100
committerDave Barach <openvpp@barachs.net>2016-11-11 14:39:00 +0000
commit8b3191e6d715760deefe550b59c7d92be4b5cda9 (patch)
tree721dd977986d12864346081fec6b245ea5a250e0 /plugins
parent0178d52384e0428368f1acf3163e664ecda7b64c (diff)
feature: convert all feature nodes to new feature infra
Change-Id: I34c527ba910fb282a95458b78d1d684eb337905e Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c24
-rw-r--r--plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h3
-rw-r--r--plugins/flowperpkt-plugin/flowperpkt/node.c20
-rw-r--r--plugins/ila-plugin/ila/ila.c39
-rw-r--r--plugins/ila-plugin/ila/ila.h2
-rw-r--r--plugins/snat-plugin/snat/out2in.c27
-rw-r--r--plugins/snat-plugin/snat/snat.c50
-rw-r--r--plugins/snat-plugin/snat/snat.h6
8 files changed, 44 insertions, 127 deletions
diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c
index ac508582669..dbdb189865d 100644
--- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c
+++ b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c
@@ -59,10 +59,10 @@ flowperpkt_main_t flowperpkt_main;
/* Define the per-interface configurable feature */
/* *INDENT-OFF* */
-VNET_IP4_TX_FEATURE_INIT (flow_perpacket, static) = {
+VNET_FEATURE_INIT (flow_perpacket, static) = {
+ .arc_name = "ip4-output",
.node_name = "flowperpkt",
- .runs_before = (char *[]){"interface-output", 0},
- .feature_index = &flowperpkt_main.ip4_tx_feature_index,
+ .runs_before = VNET_FEATURES ("interface-output"),
};
/* *INDENT-ON* */
@@ -249,11 +249,6 @@ flowperpkt_data_callback (flow_report_main_t * frm,
static int flowperpkt_tx_interface_add_del_feature
(flowperpkt_main_t * fm, u32 sw_if_index, int is_add)
{
- u32 ci;
- ip4_main_t *im = &ip4_main;
- ip_lookup_main_t *lm = &im->lookup_main;
- vnet_feature_config_main_t *cm = &lm->feature_config_mains[VNET_IP_TX_FEAT];
- u32 feature_index;
flow_report_main_t *frm = &flow_report_main;
vnet_flow_report_add_del_args_t _a, *a = &_a;
int rv;
@@ -276,18 +271,9 @@ static int flowperpkt_tx_interface_add_del_feature
}
}
- feature_index = fm->ip4_tx_feature_index;
+ vnet_feature_enable_disable ("ip4-output", "flowperpkt", sw_if_index,
+ is_add, 0, 0);
- ci = cm->config_index_by_sw_if_index[sw_if_index];
- ci = (is_add
- ? vnet_config_add_feature
- : vnet_config_del_feature)
- (fm->vlib_main, &cm->config_main,
- ci, feature_index, 0 /* config struct */ ,
- 0 /* sizeof config struct */ );
- cm->config_index_by_sw_if_index[sw_if_index] = ci;
-
- vnet_config_update_tx_feature_count (lm, cm, sw_if_index, is_add);
return 0;
}
diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h
index 5ddba9ce1da..31e685eb68d 100644
--- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h
+++ b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h
@@ -35,9 +35,6 @@ typedef struct
/** API message ID base */
u16 msg_id_base;
- /** ip4 feature index */
- u32 ip4_tx_feature_index;
-
/** Has the report been created? */
int report_created;
diff --git a/plugins/flowperpkt-plugin/flowperpkt/node.c b/plugins/flowperpkt-plugin/flowperpkt/node.c
index b01f2be3a05..86da3a1cf59 100644
--- a/plugins/flowperpkt-plugin/flowperpkt/node.c
+++ b/plugins/flowperpkt-plugin/flowperpkt/node.c
@@ -284,9 +284,6 @@ flowperpkt_node_fn (vlib_main_t * vm,
{
u32 n_left_from, *from, *to_next;
flowperpkt_next_t next_index;
- ip4_main_t *im = &ip4_main;
- ip_lookup_main_t *lm = &im->lookup_main;
- vnet_feature_config_main_t *cm = &lm->feature_config_mains[VNET_IP_TX_FEAT];
flowperpkt_main_t *fm = &flowperpkt_main;
u64 now;
@@ -337,14 +334,10 @@ flowperpkt_node_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
-
- vnet_get_config_data (&cm->config_main,
- &b0->current_config_index,
- &next0, 0 /* sizeof config data */ );
-
- vnet_get_config_data (&cm->config_main,
- &b1->current_config_index,
- &next1, 0 /* sizeof config data */ );
+ vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX],
+ &next0, b0);
+ vnet_feature_next (vnet_buffer (b1)->sw_if_index[VLIB_TX],
+ &next1, b1);
ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) +
vnet_buffer (b0)->ip.save_rewrite_length);
@@ -413,9 +406,8 @@ flowperpkt_node_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
- vnet_get_config_data (&cm->config_main,
- &b0->current_config_index,
- &next0, 0 /* sizeof config data */ );
+ vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX],
+ &next0, b0);
ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) +
vnet_buffer (b0)->ip.save_rewrite_length);
diff --git a/plugins/ila-plugin/ila/ila.c b/plugins/ila-plugin/ila/ila.c
index 61ce0f7bacd..336f4cf560c 100644
--- a/plugins/ila-plugin/ila/ila.c
+++ b/plugins/ila-plugin/ila/ila.c
@@ -425,9 +425,6 @@ static uword
ila_sir2ila (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- ip6_main_t *im = &ip6_main;
- ip_lookup_main_t *lm = &im->lookup_main;
- vnet_feature_config_main_t *cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
ila_main_t *ilm = &ila_main;
@@ -519,11 +516,8 @@ ila_sir2ila (vlib_main_t * vm,
ip61->dst_address.as_u64[0] = ila_address1->as_u64[0];
ip61->dst_address.as_u64[1] = ila_address1->as_u64[1];
- vnet_get_config_data (&cm->config_main,
- &p0->current_config_index, &next0, 0);
-
- vnet_get_config_data (&cm->config_main,
- &p1->current_config_index, &next1, 0);
+ vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0);
+ vnet_feature_next (vnet_buffer (p1)->sw_if_index[VLIB_RX], &next1, p1);
vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
n_left_to_next, pi0, pi1, next0,
@@ -574,8 +568,7 @@ ila_sir2ila (vlib_main_t * vm,
ip60->dst_address.as_u64[0] = ila_address0->as_u64[0];
ip60->dst_address.as_u64[1] = ila_address0->as_u64[1];
- vnet_get_config_data (&cm->config_main,
- &p0->current_config_index, &next0, 0);
+ vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0);
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, pi0, next0);
@@ -603,11 +596,11 @@ VLIB_REGISTER_NODE (ila_sir2ila_node, static) =
/** *INDENT-ON* */
/** *INDENT-OFF* */
-VNET_IP6_UNICAST_FEATURE_INIT (ila_sir2ila, static) =
+VNET_FEATURE_INIT (ila_sir2ila, static) =
{
+ .arc_name = "ip6-unicast",
.node_name = "sir-to-ila",
- .runs_before = ORDER_CONSTRAINTS{"ip6-lookup", 0},
- .feature_index = &ila_main.ila_sir2ila_feature_index,
+ .runs_before = VNET_FEATURES ("ip6-lookup"),
};
/** *INDENT-ON* */
@@ -823,24 +816,8 @@ ila_add_del_entry (ila_add_del_entry_args_t * args)
int
ila_interface (u32 sw_if_index, u8 disable)
{
- vlib_main_t *vm = vlib_get_main ();
- ila_main_t *ilm = &ila_main;
- ip6_main_t *im = &ip6_main;
- ip_lookup_main_t *lm = &im->lookup_main;
- vnet_feature_config_main_t *cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
- vnet_config_main_t *vcm = &cm->config_main;
- u32 ci, feature_index;
-
- vec_validate_init_empty (cm->config_index_by_sw_if_index, sw_if_index, ~0);
- ci = cm->config_index_by_sw_if_index[sw_if_index];
- feature_index = ilm->ila_sir2ila_feature_index;
-
- ci = ((disable) ? vnet_config_del_feature : vnet_config_add_feature)
- (vm, vcm, ci, feature_index,
- /* config data */ 0,
- /* # bytes of config data */ 0);
-
- cm->config_index_by_sw_if_index[sw_if_index] = ci;
+ vnet_feature_enable_disable ("ip4-unicast", "sir-to-ila", sw_if_index,
+ !disable, 0, 0);
return 0;
}
diff --git a/plugins/ila-plugin/ila/ila.h b/plugins/ila-plugin/ila/ila.h
index 657511f00f2..26620983823 100644
--- a/plugins/ila-plugin/ila/ila.h
+++ b/plugins/ila-plugin/ila/ila.h
@@ -94,8 +94,6 @@ typedef struct {
u64 lookup_table_size;
clib_bihash_24_8_t id_to_entry_table;
- u32 ila_sir2ila_feature_index;
-
u32 ip6_lookup_next_index;
} ila_main_t;
diff --git a/plugins/snat-plugin/snat/out2in.c b/plugins/snat-plugin/snat/out2in.c
index 190350ada2b..35edcc5f7b3 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 0b972110f19..66c03817ca0 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 1469f60e59d..ca10b76adce 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;