aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-03-16 11:32:09 +0100
committerDave Barach <openvpp@barachs.net>2017-03-16 13:06:27 +0000
commite9f929b52ddb741ec1e4cb2d92c6be1e798933a0 (patch)
tree1843d4798292dbd17d27ad3fab3c833388eaaf62 /src/vnet
parent3cc4971882235a539bc6177e8e4b4d92129b3a12 (diff)
vlib: make runtime_data thread-local
Change-Id: I4aa3e7e42fb81211de1aed07dc7befee87a1e18b Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/gre/node.c26
-rw-r--r--src/vnet/hdlc/node.c27
-rw-r--r--src/vnet/l2/l2_input_classify.c15
-rw-r--r--src/vnet/l2/l2_output_classify.c16
-rw-r--r--src/vnet/l2tp/l2tp.c10
-rw-r--r--src/vnet/mpls/node.c13
-rw-r--r--src/vnet/ppp/node.c27
-rw-r--r--src/vnet/tcp/tcp_syn_filter4.c23
-rw-r--r--src/vnet/udp/udp_local.c74
9 files changed, 170 insertions, 61 deletions
diff --git a/src/vnet/gre/node.c b/src/vnet/gre/node.c
index 86f7a6eeea4..dd16db5e9fc 100644
--- a/src/vnet/gre/node.c
+++ b/src/vnet/gre/node.c
@@ -448,7 +448,6 @@ gre_register_input_protocol (vlib_main_t * vm,
{
gre_main_t * em = &gre_main;
gre_protocol_info_t * pi;
- gre_input_runtime_t * rt;
u16 * n;
{
@@ -464,10 +463,13 @@ gre_register_input_protocol (vlib_main_t * vm,
node_index);
/* Setup gre protocol -> next index sparse vector mapping. */
- rt = vlib_node_get_runtime_data (vm, gre_input_node.index);
- n = sparse_vec_validate (rt->next_by_protocol,
- clib_host_to_net_u16 (protocol));
- n[0] = pi->next_index;
+ foreach_vlib_main ({
+ gre_input_runtime_t * rt;
+ rt = vlib_node_get_runtime_data (this_vlib_main, gre_input_node.index);
+ n = sparse_vec_validate (rt->next_by_protocol,
+ clib_host_to_net_u16 (protocol));
+ n[0] = pi->next_index;
+ });
}
static void
@@ -529,3 +531,17 @@ static clib_error_t * gre_input_init (vlib_main_t * vm)
}
VLIB_INIT_FUNCTION (gre_input_init);
+
+static clib_error_t * gre_input_worker_init (vlib_main_t * vm)
+{
+ gre_input_runtime_t * rt;
+
+ rt = vlib_node_get_runtime_data (vm, gre_input_node.index);
+
+ rt->next_by_protocol = sparse_vec_new
+ (/* elt bytes */ sizeof (rt->next_by_protocol[0]),
+ /* bits in index */ BITS (((gre_header_t *) 0)->protocol));
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (gre_input_worker_init);
diff --git a/src/vnet/hdlc/node.c b/src/vnet/hdlc/node.c
index 4fe0296aca1..57e04c85bae 100644
--- a/src/vnet/hdlc/node.c
+++ b/src/vnet/hdlc/node.c
@@ -285,18 +285,9 @@ VLIB_REGISTER_NODE (hdlc_input_node) = {
.unformat_buffer = unformat_hdlc_header,
};
-static clib_error_t * hdlc_input_init (vlib_main_t * vm)
+static clib_error_t * hdlc_input_runtime_init (vlib_main_t * vm)
{
hdlc_input_runtime_t * rt;
-
- {
- clib_error_t * error = vlib_call_init_function (vm, hdlc_init);
- if (error)
- clib_error_report (error);
- }
-
- hdlc_setup_node (vm, hdlc_input_node.index);
-
rt = vlib_node_get_runtime_data (vm, hdlc_input_node.index);
rt->next_by_protocol = sparse_vec_new
@@ -313,7 +304,23 @@ static clib_error_t * hdlc_input_init (vlib_main_t * vm)
return 0;
}
+static clib_error_t * hdlc_input_init (vlib_main_t * vm)
+{
+
+ {
+ clib_error_t * error = vlib_call_init_function (vm, hdlc_init);
+ if (error)
+ clib_error_report (error);
+ }
+
+ hdlc_setup_node (vm, hdlc_input_node.index);
+ hdlc_input_runtime_init (vm);
+
+ return 0;
+}
+
VLIB_INIT_FUNCTION (hdlc_input_init);
+VLIB_WORKER_INIT_FUNCTION (hdlc_input_runtime_init);
void
hdlc_register_input_protocol (vlib_main_t * vm,
diff --git a/src/vnet/l2/l2_input_classify.c b/src/vnet/l2/l2_input_classify.c
index 497df192f39..485b9abd47e 100644
--- a/src/vnet/l2/l2_input_classify.c
+++ b/src/vnet/l2/l2_input_classify.c
@@ -505,6 +505,21 @@ l2_input_classify_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (l2_input_classify_init);
+clib_error_t *
+l2_input_classify_worker_init (vlib_main_t * vm)
+{
+ l2_input_classify_main_t *cm = &l2_input_classify_main;
+ l2_input_classify_runtime_t *rt;
+
+ rt = vlib_node_get_runtime_data (vm, l2_input_classify_node.index);
+
+ rt->l2cm = cm;
+ rt->vcm = cm->vnet_classify_main;
+
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (l2_input_classify_worker_init);
/** Enable/disable l2 input classification on a specific interface. */
void
diff --git a/src/vnet/l2/l2_output_classify.c b/src/vnet/l2/l2_output_classify.c
index 832be1a11c0..c1bdaddc06e 100644
--- a/src/vnet/l2/l2_output_classify.c
+++ b/src/vnet/l2/l2_output_classify.c
@@ -505,6 +505,22 @@ l2_output_classify_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (l2_output_classify_init);
+clib_error_t *
+l2_output_classify_worker_init (vlib_main_t * vm)
+{
+ l2_output_classify_main_t *cm = &l2_output_classify_main;
+ l2_output_classify_runtime_t *rt;
+
+ rt = vlib_node_get_runtime_data (vm, l2_output_classify_node.index);
+
+ rt->l2cm = cm;
+ rt->vcm = cm->vnet_classify_main;
+
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (l2_output_classify_worker_init);
+
/** Enable/disable l2 input classification on a specific interface. */
void
vnet_l2_output_classify_enable_disable (u32 sw_if_index, int enable_disable)
diff --git a/src/vnet/l2tp/l2tp.c b/src/vnet/l2tp/l2tp.c
index 2d3233972a8..cb94d7e7287 100644
--- a/src/vnet/l2tp/l2tp.c
+++ b/src/vnet/l2tp/l2tp.c
@@ -747,6 +747,16 @@ l2tp_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (l2tp_init);
+clib_error_t *
+l2tp_worker_init (vlib_main_t * vm)
+{
+ l2tp_encap_init (vm);
+
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (l2tp_worker_init);
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/mpls/node.c b/src/vnet/mpls/node.c
index 1810091252e..03bfaf56ce9 100644
--- a/src/vnet/mpls/node.c
+++ b/src/vnet/mpls/node.c
@@ -301,3 +301,16 @@ static clib_error_t * mpls_input_init (vlib_main_t * vm)
}
VLIB_INIT_FUNCTION (mpls_input_init);
+
+static clib_error_t * mpls_input_worker_init (vlib_main_t * vm)
+{
+ mpls_input_runtime_t * rt;
+ rt = vlib_node_get_runtime_data (vm, mpls_input_node.index);
+ rt->last_label = (u32) ~0;
+ rt->last_inner_fib_index = 0;
+ rt->last_outer_fib_index = 0;
+ rt->mpls_main = &mpls_main;
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (mpls_input_worker_init);
diff --git a/src/vnet/ppp/node.c b/src/vnet/ppp/node.c
index 4f1f6a715e6..2f6e0c337e1 100644
--- a/src/vnet/ppp/node.c
+++ b/src/vnet/ppp/node.c
@@ -295,18 +295,10 @@ VLIB_REGISTER_NODE (ppp_input_node) = {
/* *INDENT-ON* */
static clib_error_t *
-ppp_input_init (vlib_main_t * vm)
+ppp_input_runtime_init (vlib_main_t * vm)
{
ppp_input_runtime_t *rt;
- {
- clib_error_t *error = vlib_call_init_function (vm, ppp_init);
- if (error)
- clib_error_report (error);
- }
-
- ppp_setup_node (vm, ppp_input_node.index);
-
rt = vlib_node_get_runtime_data (vm, ppp_input_node.index);
rt->next_by_protocol = sparse_vec_new
@@ -323,7 +315,24 @@ ppp_input_init (vlib_main_t * vm)
return 0;
}
+static clib_error_t *
+ppp_input_init (vlib_main_t * vm)
+{
+
+ {
+ clib_error_t *error = vlib_call_init_function (vm, ppp_init);
+ if (error)
+ clib_error_report (error);
+ }
+
+ ppp_setup_node (vm, ppp_input_node.index);
+ ppp_input_runtime_init (vm);
+
+ return 0;
+}
+
VLIB_INIT_FUNCTION (ppp_input_init);
+VLIB_WORKER_INIT_FUNCTION (ppp_input_runtime_init);
void
ppp_register_input_protocol (vlib_main_t * vm,
diff --git a/src/vnet/tcp/tcp_syn_filter4.c b/src/vnet/tcp/tcp_syn_filter4.c
index c7605a30c98..9b2a8ac7c87 100644
--- a/src/vnet/tcp/tcp_syn_filter4.c
+++ b/src/vnet/tcp/tcp_syn_filter4.c
@@ -450,18 +450,21 @@ syn_filter_enable_disable (u32 sw_if_index, int enable_disable)
if (enable_disable)
{
- vlib_main_t *vm = vlib_get_main ();
syn_filter4_runtime_t *rt;
- rt = vlib_node_get_runtime_data (vm, syn_filter4_node.index);
- vec_validate (rt->syn_counts, 1023);
- /*
- * Given perfect disperson / optimal hashing results:
- * Allow 128k (successful) syns/sec. 1024, buckets each of which
- * absorb 128 syns before filtering. Reset table once a second.
- * Reality bites, lets try resetting once every 100ms.
- */
- rt->reset_interval = 0.1; /* reset interval in seconds */
+ /* *INDENT-OFF* */
+ foreach_vlib_main ({
+ rt = vlib_node_get_runtime_data (this_vlib_main, syn_filter4_node.index);
+ vec_validate (rt->syn_counts, 1023);
+ /*
+ * Given perfect disperson / optimal hashing results:
+ * Allow 128k (successful) syns/sec. 1024, buckets each of which
+ * absorb 128 syns before filtering. Reset table once a second.
+ * Reality bites, lets try resetting once every 100ms.
+ */
+ rt->reset_interval = 0.1; /* reset interval in seconds */
+ });
+ /* *INDENT-ON* */
}
rv = vnet_feature_enable_disable ("ip4-local", "syn-filter-4",
diff --git a/src/vnet/udp/udp_local.c b/src/vnet/udp/udp_local.c
index 6b239f73481..3a60b29b990 100644
--- a/src/vnet/udp/udp_local.c
+++ b/src/vnet/udp/udp_local.c
@@ -520,11 +520,15 @@ udp_register_dst_port (vlib_main_t * vm,
: udp6_input_node.index, node_index);
/* Setup udp protocol -> next index sparse vector mapping. */
- rt = vlib_node_get_runtime_data
- (vm, is_ip4 ? udp4_input_node.index : udp6_input_node.index);
- n = sparse_vec_validate (rt->next_by_dst_port,
- clib_host_to_net_u16 (dst_port));
- n[0] = pi->next_index;
+ /* *INDENT-OFF* */
+ foreach_vlib_main({
+ rt = vlib_node_get_runtime_data
+ (this_vlib_main, is_ip4 ? udp4_input_node.index : udp6_input_node.index);
+ n = sparse_vec_validate (rt->next_by_dst_port,
+ clib_host_to_net_u16 (dst_port));
+ n[0] = pi->next_index;
+ });
+ /* *INDENT-ON* */
}
void
@@ -541,11 +545,15 @@ udp_unregister_dst_port (vlib_main_t * vm, udp_dst_port_t dst_port, u8 is_ip4)
return;
/* Kill the mapping. Don't bother killing the pi, it may be back. */
- rt = vlib_node_get_runtime_data
- (vm, is_ip4 ? udp4_input_node.index : udp6_input_node.index);
- n = sparse_vec_validate (rt->next_by_dst_port,
- clib_host_to_net_u16 (dst_port));
- n[0] = SPARSE_VEC_INVALID_INDEX;
+ /* *INDENT-OFF* */
+ foreach_vlib_main({
+ rt = vlib_node_get_runtime_data
+ (this_vlib_main, is_ip4 ? udp4_input_node.index : udp6_input_node.index);
+ n = sparse_vec_validate (rt->next_by_dst_port,
+ clib_host_to_net_u16 (dst_port));
+ n[0] = SPARSE_VEC_INVALID_INDEX;
+ });
+ /* *INDENT-ON* */
}
void
@@ -604,10 +612,27 @@ udp_setup_node (vlib_main_t * vm, u32 node_index)
pn->unformat_edit = unformat_pg_udp_header;
}
+static void
+udp_local_node_runtime_init (vlib_main_t * vm)
+{
+ udp_input_runtime_t *rt;
+
+ rt = vlib_node_get_runtime_data (vm, udp4_input_node.index);
+ rt->next_by_dst_port = sparse_vec_new
+ ( /* elt bytes */ sizeof (rt->next_by_dst_port[0]),
+ /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
+ rt->punt_unknown = 0;
+
+ rt = vlib_node_get_runtime_data (vm, udp6_input_node.index);
+ rt->next_by_dst_port = sparse_vec_new
+ ( /* elt bytes */ sizeof (rt->next_by_dst_port[0]),
+ /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
+ rt->punt_unknown = 0;
+}
+
clib_error_t *
udp_local_init (vlib_main_t * vm)
{
- udp_input_runtime_t *rt;
udp_main_t *um = &udp_main;
int i;
@@ -628,27 +653,13 @@ udp_local_init (vlib_main_t * vm)
udp_setup_node (vm, udp4_input_node.index);
udp_setup_node (vm, udp6_input_node.index);
- rt = vlib_node_get_runtime_data (vm, udp4_input_node.index);
-
- rt->next_by_dst_port = sparse_vec_new
- ( /* elt bytes */ sizeof (rt->next_by_dst_port[0]),
- /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
-
- rt->punt_unknown = 0;
+ udp_local_node_runtime_init (vm);
#define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 1 /* is_ip4 */);
foreach_udp4_dst_port
#undef _
- rt = vlib_node_get_runtime_data (vm, udp6_input_node.index);
-
- rt->next_by_dst_port = sparse_vec_new
- ( /* elt bytes */ sizeof (rt->next_by_dst_port[0]),
- /* bits in index */ BITS (((udp_header_t *) 0)->dst_port));
-
- rt->punt_unknown = 0;
-
#define _(n,s) add_dst_port (um, UDP_DST_PORT_##s, #s, 0 /* is_ip4 */);
- foreach_udp6_dst_port
+ foreach_udp6_dst_port
#undef _
ip4_register_protocol (IP_PROTOCOL_UDP, udp4_input_node.index);
/* Note: ip6 differs from ip4, UDP is hotwired to ip6-udp-lookup */
@@ -657,6 +668,15 @@ udp_local_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (udp_local_init);
+clib_error_t *
+udp_local_worker_init (vlib_main_t * vm)
+{
+ udp_local_node_runtime_init (vm);
+ return 0;
+}
+
+VLIB_WORKER_INIT_FUNCTION (udp_local_worker_init);
+
/*
* fd.io coding-style-patch-verification: ON
*