diff options
Diffstat (limited to 'src/vnet/ip-neighbor/ip6_neighbor.c')
-rw-r--r-- | src/vnet/ip-neighbor/ip6_neighbor.c | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c index ec323543e32..ca8aed3d4ca 100644 --- a/src/vnet/ip-neighbor/ip6_neighbor.c +++ b/src/vnet/ip-neighbor/ip6_neighbor.c @@ -16,8 +16,10 @@ */ #include <vnet/ip-neighbor/ip6_neighbor.h> +#include <vnet/ip-neighbor/ip_neighbor.api_enum.h> #include <vnet/util/throttle.h> #include <vnet/fib/fib_sas.h> +#include <vnet/ip/ip_sas.h> /** ND throttling */ static throttle_t nd_throttle; @@ -30,19 +32,20 @@ VLIB_REGISTER_LOG_CLASS (ip6_neighbor_log, static) = { #define log_debug(fmt, ...) \ vlib_log_debug (ip6_neighbor_log.class, fmt, __VA_ARGS__) void -ip6_neighbor_probe_dst (u32 sw_if_index, const ip6_address_t * dst) +ip6_neighbor_probe_dst (u32 sw_if_index, u32 thread_index, + const ip6_address_t *dst) { ip6_address_t src; - if (fib_sas6_get (sw_if_index, dst, &src)) - ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), - sw_if_index, &src, dst); + if (fib_sas6_get (sw_if_index, dst, &src) || + ip6_sas_by_sw_if_index (sw_if_index, dst, &src)) + ip6_neighbor_probe (vlib_get_main (), vnet_get_main (), sw_if_index, + thread_index, &src, dst); } void -ip6_neighbor_advertise (vlib_main_t * vm, - vnet_main_t * vnm, - u32 sw_if_index, const ip6_address_t * addr) +ip6_neighbor_advertise (vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, + u32 thread_index, const ip6_address_t *addr) { vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); ip6_main_t *i6m = &ip6_main; @@ -103,6 +106,10 @@ ip6_neighbor_advertise (vlib_main_t * vm, to_next[0] = bi; f->n_vectors = 1; vlib_put_frame_to_node (vm, hi->output_node_index, f); + + vlib_increment_simple_counter ( + &ip_neighbor_counters[AF_IP6].ipnc[VLIB_TX][IP_NEIGHBOR_CTR_GRAT], + thread_index, sw_if_index, 1); } } @@ -113,14 +120,6 @@ typedef enum IP6_NBR_N_NEXT, } ip6_discover_neighbor_next_t; -typedef enum -{ - IP6_NBR_ERROR_DROP, - IP6_NBR_ERROR_REQUEST_SENT, - IP6_NBR_ERROR_NO_SOURCE_ADDRESS, - IP6_NBR_ERROR_NO_BUFFERS, -} ip6_discover_neighbor_error_t; - static uword ip6_discover_neighbor_inline (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -186,6 +185,12 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, to_next_drop += 1; n_left_to_next_drop -= 1; + if (drop0) + { + p0->error = node->errors[IP6_NEIGHBOR_ERROR_THROTTLED]; + continue; + } + hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index0); /* If the interface is link-down, drop the pkt */ @@ -204,7 +209,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, if (drop0) { - p0->error = node->errors[IP6_NBR_ERROR_DROP]; + p0->error = node->errors[IP6_NEIGHBOR_ERROR_DROP]; continue; } @@ -212,15 +217,17 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, * Choose source address based on destination lookup * adjacency. */ - if (!fib_sas6_get (sw_if_index0, &ip0->dst_address, &src)) + const ip6_address_t *ll = ip6_get_link_local_address (sw_if_index0); + if (!ll) { /* There is no address on the interface */ - p0->error = node->errors[IP6_NBR_ERROR_NO_SOURCE_ADDRESS]; + p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_SOURCE_ADDRESS]; continue; } + ip6_address_copy (&src, ll); - b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0, - &src, &ip0->dst_address); + b0 = ip6_neighbor_probe (vm, vnm, sw_if_index0, thread_index, &src, + &ip0->dst_address); if (PREDICT_TRUE (NULL != b0)) { @@ -228,12 +235,12 @@ ip6_discover_neighbor_inline (vlib_main_t * vm, sizeof (p0->opaque2)); b0->flags |= p0->flags & VLIB_BUFFER_IS_TRACED; b0->trace_handle = p0->trace_handle; - p0->error = node->errors[IP6_NBR_ERROR_REQUEST_SENT]; + p0->error = node->errors[IP6_NEIGHBOR_ERROR_REQUEST_SENT]; } else { /* There is no address on the interface */ - p0->error = node->errors[IP6_NBR_ERROR_NO_BUFFERS]; + p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_BUFFERS]; continue; } } @@ -257,22 +264,14 @@ ip6_glean (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) return (ip6_discover_neighbor_inline (vm, node, frame, 1)); } -static char *ip6_discover_neighbor_error_strings[] = { - [IP6_NBR_ERROR_DROP] = "address overflow drops", - [IP6_NBR_ERROR_REQUEST_SENT] = "neighbor solicitations sent", - [IP6_NBR_ERROR_NO_SOURCE_ADDRESS] = "no source address for ND solicitation", - [IP6_NBR_ERROR_NO_BUFFERS] = "no buffers", -}; - -/* *INDENT-OFF* */ VLIB_REGISTER_NODE (ip6_glean_node) = { .function = ip6_glean, .name = "ip6-glean", .vector_size = sizeof (u32), .format_trace = format_ip6_forward_next_trace, - .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings), - .error_strings = ip6_discover_neighbor_error_strings, + .n_errors = IP6_NEIGHBOR_N_ERROR, + .error_counters = ip6_neighbor_error_counters, .n_next_nodes = IP6_NBR_N_NEXT, .next_nodes = { @@ -286,8 +285,8 @@ VLIB_REGISTER_NODE (ip6_discover_neighbor_node) = .name = "ip6-discover-neighbor", .vector_size = sizeof (u32), .format_trace = format_ip6_forward_next_trace, - .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings), - .error_strings = ip6_discover_neighbor_error_strings, + .n_errors = IP6_NEIGHBOR_N_ERROR, + .error_counters = ip6_neighbor_error_counters, .n_next_nodes = IP6_NBR_N_NEXT, .next_nodes = { @@ -295,7 +294,6 @@ VLIB_REGISTER_NODE (ip6_discover_neighbor_node) = [IP6_NBR_NEXT_REPLY_TX] = "ip6-rewrite-mcast", }, }; -/* *INDENT-ON* */ /* Template used to generate IP6 neighbor solicitation packets. */ vlib_packet_template_t ip6_neighbor_packet_template; @@ -339,7 +337,7 @@ 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); + throttle_init (&nd_throttle, tm->n_vlib_mains, THROTTLE_BITS, 1e-3); return 0; } |