aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip-neighbor/ip6_neighbor.c
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2020-10-26 13:00:06 +0000
committerDamjan Marion <dmarion@me.com>2020-10-28 16:55:35 +0000
commite4031131ccddd7c4eb683b36f1a97a65dcff008a (patch)
treeef469ab6a2188bd3ce7ab0daacb0d9ef14fca632 /src/vnet/ip-neighbor/ip6_neighbor.c
parent224a3c03d9aa34259ac3816c0039f2776d6da5ef (diff)
misc: Break the big IP header files to improve compile time
Type: refactor Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Change-Id: Id1801519638a9b97175847d7ed58824fb83433d6
Diffstat (limited to 'src/vnet/ip-neighbor/ip6_neighbor.c')
-rw-r--r--src/vnet/ip-neighbor/ip6_neighbor.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c
index 325db8c6277..ca67d85778d 100644
--- a/src/vnet/ip-neighbor/ip6_neighbor.c
+++ b/src/vnet/ip-neighbor/ip6_neighbor.c
@@ -16,6 +16,10 @@
*/
#include <vnet/ip-neighbor/ip6_neighbor.h>
+#include <vnet/util/throttle.h>
+
+/** ND throttling */
+static throttle_t nd_throttle;
void
ip6_neighbor_probe_dst (const ip_adjacency_t * adj, const ip6_address_t * dst)
@@ -121,7 +125,6 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
vlib_frame_t * frame, int is_glean)
{
vnet_main_t *vnm = vnet_get_main ();
- ip6_main_t *im = &ip6_main;
u32 *from, *to_next_drop;
uword n_left_from, n_left_to_next_drop;
u64 seed;
@@ -130,7 +133,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
if (node->flags & VLIB_NODE_FLAG_TRACE)
ip6_forward_next_trace (vm, node, frame, VLIB_TX);
- seed = throttle_seed (&im->nd_throttle, thread_index, vlib_time_now (vm));
+ seed = throttle_seed (&nd_throttle, thread_index, vlib_time_now (vm));
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -173,7 +176,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
/* combine the address and interface for a hash */
r0 = ip6_address_hash_to_u64 (&ip0->dst_address) ^ sw_if_index0;
- drop0 = throttle_check (&im->nd_throttle, thread_index, r0, seed);
+ drop0 = throttle_check (&nd_throttle, thread_index, r0, seed);
from += 1;
n_left_from -= 1;
@@ -329,6 +332,18 @@ ip6_neighbor_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (ip6_neighbor_init);
+static clib_error_t *
+ip6_nd_main_loop_enter (vlib_main_t * vm)
+{
+ vlib_thread_main_t *tm = &vlib_thread_main;
+
+ throttle_init (&nd_throttle, tm->n_vlib_mains, 1e-3);
+
+ return 0;
+}
+
+VLIB_MAIN_LOOP_ENTER_FUNCTION (ip6_nd_main_loop_enter);
+
/*
* fd.io coding-style-patch-verification: ON
*