X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip-neighbor%2Fip6_neighbor.c;h=478eca7fa278354f26080be043719378a03161bf;hb=e2fe09742;hp=325db8c62773eabcb5663f5c7647e3727ede2636;hpb=cbe25aab3be72154f2c706c39eeba6a77f34450f;p=vpp.git diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c index 325db8c6277..478eca7fa27 100644 --- a/src/vnet/ip-neighbor/ip6_neighbor.c +++ b/src/vnet/ip-neighbor/ip6_neighbor.c @@ -16,20 +16,20 @@ */ #include +#include +#include + +/** ND throttling */ +static throttle_t nd_throttle; void -ip6_neighbor_probe_dst (const ip_adjacency_t * adj, const ip6_address_t * dst) +ip6_neighbor_probe_dst (u32 sw_if_index, const ip6_address_t * dst) { - ip_interface_address_t *ia; - ip6_address_t *src; - - src = ip6_interface_address_matching_destination - (&ip6_main, dst, adj->rewrite_header.sw_if_index, &ia); - - if (!src) - return; + ip6_address_t src; - ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), adj, src, dst); + if (fib_sas6_get (sw_if_index, dst, &src)) + ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), + sw_if_index, &src, dst); } void @@ -121,7 +121,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 +129,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 +172,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; @@ -207,15 +206,15 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, * Choose source address based on destination lookup * adjacency. */ - if (!ip6_src_address_for_packet (sw_if_index0, - &ip0->dst_address, &src)) + if (!fib_sas6_get (sw_if_index0, &ip0->dst_address, &src)) { /* There is no address on the interface */ p0->error = node->errors[IP6_NBR_ERROR_NO_SOURCE_ADDRESS]; continue; } - b0 = ip6_neighbor_probe (vm, vnm, adj0, &src, &ip0->dst_address); + b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0, + &src, &ip0->dst_address); if (PREDICT_TRUE (NULL != b0)) { @@ -329,6 +328,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 *