summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip-neighbor
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
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')
-rw-r--r--src/vnet/ip-neighbor/ip4_neighbor.c22
-rw-r--r--src/vnet/ip-neighbor/ip6_neighbor.c21
2 files changed, 38 insertions, 5 deletions
diff --git a/src/vnet/ip-neighbor/ip4_neighbor.c b/src/vnet/ip-neighbor/ip4_neighbor.c
index 2a9e2675a78..7c0cbdcb2a2 100644
--- a/src/vnet/ip-neighbor/ip4_neighbor.c
+++ b/src/vnet/ip-neighbor/ip4_neighbor.c
@@ -39,6 +39,10 @@
#include <vnet/ip-neighbor/ip4_neighbor.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/util/throttle.h>
+
+/** ARP throttling */
+static throttle_t arp_throttle;
void
ip4_neighbor_probe_dst (const ip_adjacency_t * adj, const ip4_address_t * dst)
@@ -128,7 +132,7 @@ ip4_arp_inline (vlib_main_t * vm,
if (node->flags & VLIB_NODE_FLAG_TRACE)
ip4_forward_next_trace (vm, node, frame, VLIB_TX);
- seed = throttle_seed (&im->arp_throttle, thread_index, vlib_time_now (vm));
+ seed = throttle_seed (&arp_throttle, thread_index, vlib_time_now (vm));
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -186,7 +190,7 @@ ip4_arp_inline (vlib_main_t * vm,
r0 = (u64) resolve0.data_u32 << 32;
r0 |= sw_if_index0;
- if (throttle_check (&im->arp_throttle, thread_index, r0, seed))
+ if (throttle_check (&arp_throttle, thread_index, r0, seed))
{
p0->error = node->errors[IP4_ARP_ERROR_THROTTLED];
continue;
@@ -310,6 +314,20 @@ arp_notrace_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (arp_notrace_init);
+static clib_error_t *
+ip4_neighbor_main_loop_enter (vlib_main_t * vm)
+{
+ vlib_thread_main_t *tm = &vlib_thread_main;
+ u32 n_vlib_mains = tm->n_vlib_mains;
+
+ throttle_init (&arp_throttle, n_vlib_mains, 1e-3);
+
+ return (NULL);
+}
+
+VLIB_MAIN_LOOP_ENTER_FUNCTION (ip4_neighbor_main_loop_enter);
+
+
/*
* fd.io coding-style-patch-verification: ON
*
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
*